• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript perf_hooks.performance类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了performance类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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:

const performanceObserverCallback: PerformanceObserverCallback = (list, obs) => {
    const {
        duration,
        entryType,
        name,
        startTime,
    } = list.getEntries()[0];
    obs.disconnect();
    performance.clearFunctions();
};
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:10,代码来源:perf_hooks.ts


示例7: 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


示例8: 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


示例9: require

/*
----------------------
  Performance monitoring instrumentation code
  Will output the most expensive require resolutions to the console
  Usage: set `BP_DEBUG_REQUIRE` to `true`
------------------------
*/

if (global.process.env.BP_DEBUG_REQUIRE) {
  const { performance, PerformanceObserver } = require('perf_hooks')
  const os = require('os')

  const SAMPLING_INTERVAL = 5000
  const TOP_COUNT = 10

  Module.prototype.require = performance.timerify(Module.prototype.require)
  require = performance.timerify(require)

  let allRequires: { duration: Number; call: string }[] = []

  const obs = new PerformanceObserver(list => {
    const entries = list.getEntries()
    entries.forEach(e => allRequires.push({ duration: e.duration, call: e[0] }))
  })

  obs.observe({ entryTypes: ['function'], buffered: true })

  setInterval(() => {
    const significantCalls = _.take(_.orderBy(allRequires, 'duration', 'desc'), TOP_COUNT)
    const formattedCalls = significantCalls.map((x, i) => `${i}) ${x.duration}\t\t${x.call}`).join(os.EOL)
    console.log(formattedCalls)
开发者ID:seffalabdelaziz,项目名称:botpress,代码行数:31,代码来源:rewire.ts


示例10: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript perfect-scrollbar.destroy函数代码示例发布时间:2022-05-25
下一篇:
TypeScript pem.readPkcs12函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap