当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript performance.now方法代码示例

本文整理汇总了TypeScript中perf_hooks.performance.now方法的典型用法代码示例。如果您正苦于以下问题:TypeScript performance.now方法的具体用法?TypeScript performance.now怎么用?TypeScript performance.now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在perf_hooks.performance的用法示例。


在下文中一共展示了performance.now方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: perfWrap

async function perfWrap(callback, args?) {
  isBuildingStyles = {} // 清空
  // 后期可以优化,不编译全部
  const t0 = performance.now()
  await callback(args)
  const t1 = performance.now()
  Util.printLog(processTypeEnum.COMPILE, `编译完成,花费${Math.round(t1 - t0)} ms`)
}
开发者ID:YangShaoQun,项目名称:taro,代码行数:8,代码来源:rn.ts

示例2: Date

 await app.listen(Config.Port, Config.IP, () => {
   Log.log.info(`┌`.padEnd(lineLength, '─') + `┐`);
   Log.log.info(`│       Server listening: ${Config.ApiUrl}`.padEnd(lineLength, ' ') + `│`);
   if (!Config.isProd()) {
     Log.log.info(`│  Swagger Documentation: ${Config.ApiUrl}${Config.DocsRoute}`.padEnd(lineLength, ' ') + `│`);
     Log.log.info(`│     GraphQL Playground: ${Config.ApiUrl}${Config.GraphRoute}`.padEnd(lineLength, ' ') + `│`);
   }
   Log.log.info(`├`.padEnd(lineLength, '─') + `┤`);
   Log.log.info(`│             Memory: ${readMem()}`.padEnd(lineLength, ' ') + `│`);
   Log.log.info(`│             Launch: ${new Date().toISOString()}`.padEnd(lineLength, ' ') + `│`);
   Log.log.info(`│      Time to start: ${(performance.now() - startTime).toFixed(3)}ms`.padEnd(lineLength, ' ') + `│`);
   Log.log.info(`│     Bootstrap time: ${(performance.now() - bootTime).toFixed(3)}ms`.padEnd(lineLength, ' ') + `│`);
   Log.log.info(`└`.padEnd(lineLength, '─') + `┘`);
 });
开发者ID:OysteinAmundsen,项目名称:gymsystems,代码行数:14,代码来源:main.ts

示例3: test

test('decoding and converting to RGB many frames', async (t) => {
    const budget = 120000000 / cpuSpeed;
    const byteStream = await readOggFile(mediumComplexOggFile);

    const startTime = performance.now();
    decodeAndConvertAllFrames(byteStream);
    const endTime = performance.now();
    const runTime = endTime - startTime;

    t.true(runTime < budget, `Performance budged exceeded: ${runTime}ms (limit: ${budget})`);

    if (runTime < budget) {
        t.log(`Performance budget ok: ${runTime}ms (limit: ${budget})`);
    }
});
开发者ID:lo1tuma,项目名称:theorajs,代码行数:15,代码来源:yCbCrToRgb.bench.ts

示例4: build

export async function build(appPath, buildConfig: IBuildConfig) {
  const {watch} = buildConfig
  process.env.TARO_ENV = BUILD_TYPES.RN
  fs.ensureDirSync(tempPath)
  const t0 = performance.now()
  await buildTemp()
  const t1 = performance.now()
  Util.printLog(processTypeEnum.COMPILE, `编译完成,花费${Math.round(t1 - t0)} ms`)

  if (watch) {
    watchFiles()
    startServerInNewWindow()
  } else {
    buildBundle()
  }
}
开发者ID:YangShaoQun,项目名称:taro,代码行数:16,代码来源:rn.ts

示例5:

}).on("complete", () => {
	const slowest = suite.filter("slowest").shift();
	const fastest = suite.filter("fastest").shift();
	console.log(`===\nFastest is ${fastest.name} with ~${mean(fastest)} μs/op`);
	if (slowest.name !== fastest.name) {
		console.log(`Slowest is ${slowest.name} with ~${mean(slowest)} μs/op`);
	}
	const d = ((performance.now() - _start)/1000).toFixed(2);
	console.log(`Benchmark took ${d} s`);
})
开发者ID:AhmadAlyTanany,项目名称:code-server,代码行数:10,代码来源:requirefs.bench.ts

示例6: async

const addMany = (names: string[]): benchmark.Suite => {
	for (let name of names) {
		for (let file of files) {
			suite = suite.add(`${name} -> ${file}`, async () => {
				let rfs = await toBench.byName(name).rfs;
				rfs.require(file);
			});
		}
	}
	_start = performance.now();
	return suite;
}
开发者ID:AhmadAlyTanany,项目名称:code-server,代码行数:12,代码来源:requirefs.bench.ts

示例7: function

export const logRequest = function(req: express.Request, res: express.Response, next: express.NextFunction) {
	const t = performance.now();
	const data = Object.assign({}, req.headers);

	if (req.query && Object.keys(req.query).length > 0) {
		data.querystring = req.query;
	}

	req.logger.info(`start handling request ${ req.id }: ${ req.method } ${ req.path }`, data);

	res.on("finish", () => {
		req.logger.info(`finished handling request ${ req.id }`, { time: performance.now() - t });
	});

	next();
} as express.RequestHandler;
开发者ID:nrudenko,项目名称:kin-devplatform-jwt-service,代码行数:16,代码来源:middleware.ts

示例8: bootstrap

/**
 * Bootstrap the application
 */
async function bootstrap() {
  Log.log.debug(` * ${new Date().toISOString()}: Bootstrapping application`);
  bootTime = performance.now();

  const expressInstance = express();
  // Configure Express Instance
  expressInstance.use(helmet()); //Helmet
  expressInstance.use(bodyParser.urlencoded({ extended: false }));
  expressInstance.use(bodyParser.json()); //Body Parser

  // Logging
  const logDirectory = './log';
  existsSync(logDirectory) || mkdirSync(logDirectory); // ensure log directory exists
  expressInstance.use(morgan('combined', { stream: Log.stream(logDirectory) }));
  morganBody(expressInstance); // Log every request body/response

  // Create NestJS APP
  Log.log.debug(` * ${new Date().toISOString()}: Creating NestJS app`);
  const app = await NestFactory.create(AppModule, new ExpressAdapter(expressInstance), { cors: true, logger: false });
  Log.log.debug(` * ${new Date().toISOString()}: Configuring NestJS app`);
  app.useLogger(app.get(LogService));

  // Global Route Prefix
  app.setGlobalPrefix(Config.GlobalRoutePrefix);

  // Do not err on fetching favicon (will only be called when surfing the api using a browser)
  // which you should not do anyway. You should use a REST explorer like i.e. Postman.
  app.use((req, res, next) => req.url === '/favicon.ico' ? res.status(204).send() : next());

  // Pipes
  app.useGlobalPipes(new ValidationPipe({ transform: true, disableErrorMessages: true }));

  // Http-Exception filter
  app.useGlobalFilters(new HttpExceptionFilter());

  // Interceptors

  // Swagger
  if (!Config.isProd()) {
    Log.log.debug(` * ${new Date().toISOString()}: Setting up swagger`);
    const pkg = require('../package.json');

    const swagger = await import('@nestjs/swagger');
    const options = new swagger.DocumentBuilder()
      .setBasePath(Config.GlobalRoutePrefix)
      .setTitle(pkg.name)
      .setDescription(pkg.description)
      .setVersion(pkg.version)
      .setContactEmail(pkg.author)
      .addBearerAuth(Config.JwtHeaderName, 'header', 'jwt')
      .build();
    const document = swagger.SwaggerModule.createDocument(app, options);
    swagger.SwaggerModule.setup(`/${Config.GlobalRoutePrefix}${Config.DocsRoute}`, app, document);

    // Generate .json API Documentation (easly import to Restlet Studio etc...)
    const apiDirectory = './api-docs';
    existsSync(apiDirectory) || mkdirSync(apiDirectory); // ensure api documentation directory exists
    await writeFile(`${apiDirectory}/swagger2.json`, JSON.stringify(document, null, 4), (err: NodeJS.ErrnoException) => {
      if (err) throw err;
    });
  }

  // Start listening
  await app.listen(Config.Port, Config.IP, () => {
    Log.log.info(`┌`.padEnd(lineLength, '─') + `┐`);
    Log.log.info(`│       Server listening: ${Config.ApiUrl}`.padEnd(lineLength, ' ') + `│`);
    if (!Config.isProd()) {
      Log.log.info(`│  Swagger Documentation: ${Config.ApiUrl}${Config.DocsRoute}`.padEnd(lineLength, ' ') + `│`);
      Log.log.info(`│     GraphQL Playground: ${Config.ApiUrl}${Config.GraphRoute}`.padEnd(lineLength, ' ') + `│`);
    }
    Log.log.info(`├`.padEnd(lineLength, '─') + `┤`);
    Log.log.info(`│             Memory: ${readMem()}`.padEnd(lineLength, ' ') + `│`);
    Log.log.info(`│             Launch: ${new Date().toISOString()}`.padEnd(lineLength, ' ') + `│`);
    Log.log.info(`│      Time to start: ${(performance.now() - startTime).toFixed(3)}ms`.padEnd(lineLength, ' ') + `│`);
    Log.log.info(`│     Bootstrap time: ${(performance.now() - bootTime).toFixed(3)}ms`.padEnd(lineLength, ' ') + `│`);
    Log.log.info(`└`.padEnd(lineLength, '─') + `┘`);
  });
}
开发者ID:OysteinAmundsen,项目名称:gymsystems,代码行数:81,代码来源:main.ts

示例9:

	res.on("finish", () => {
		req.logger.info(`finished handling request ${ req.id }`, { time: performance.now() - t });
	});
开发者ID:nrudenko,项目名称:kin-devplatform-jwt-service,代码行数:3,代码来源:middleware.ts


注:本文中的perf_hooks.performance.now方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。