本文整理汇总了TypeScript中benchmark.Suite.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Suite.on方法的具体用法?TypeScript Suite.on怎么用?TypeScript Suite.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类benchmark.Suite
的用法示例。
在下文中一共展示了Suite.on方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: log
Promise.all(groupPromises).then(() => {
log('Running benchmarks.');
bsuite
.on('error', (error: any) => {
log('Error: ', error);
})
.on('cycle', (event: any) => {
log('Mean time in ms: ', event.target.stats.mean * 1000);
log(String(event.target));
})
.run({ async: false });
});
示例2: music
const extraSmallVideo = 'https://www.youtube.com/watch?v=oVXg7Grp1W8'; // 22s with music (9MB)
const smallVideo = 'https://www.youtube.com/watch?v=LXb3EKWsInQ'; // Costa Rica 4K, 5:14 (169MB)
const longVideo = 'https://www.youtube.com/watch?v=aqz-KE-bpKQ'; // Big Buck Bunny, 10:34 4K (281 MB)
const videoToDownload = smallVideo;
type BenchResolver = { resolve(): void };
let downloadSize = 0;
const modeSuite = new Suite('Download Mode');
modeSuite.on('cycle', function (event: Event) {
let bm = event.target as any;
let opsPerMin = formatOpsSpeed(bm);
let downloadSpeed = formatDownloadSpeed(bm);
let size = bm.stats.sample.length;
console.log(`${bm.name}: [${downloadSpeed}] ${opsPerMin} \xb1${bm.stats.rme.toFixed(2)}% (${size} run${size == 1 ? '' : 's'} sampled)`);
});
modeSuite
.add(downloadModeBenchmarkFor(DownloadMode.Merge))
.add(downloadModeBenchmarkFor(DownloadMode.Sequential))
.add(downloadModeBenchmarkFor(DownloadMode.Parallel))
.add(ytldCorBenchmark())
.run({ async: false });
function downloadModeBenchmarkFor(mode: DownloadMode): BenchmarkOptions {
let pully: Pully;
let i = 0;
let downloadPath: string;