fontcolor_theme
package

API @deepkit/bench

npm install @deepkit/bench

用于基准测试代码片段的简单工具。

import { benchmark, run } from '@deepkit/bench';

// ASCII 二进制解析示例
const binaryString = Buffer.from('Hello World', 'utf8');
const codes = [

benchmark('Buffer.toString', () => {
    const utf8String = binaryString.toString('utf8');
});

benchmark('String.fromCodePoint', () => {
    const utf8String = String.fromCodePoint()
});

void run();
$ node --import @deepkit/run benchmarks/ascii-parsing.ts
Node v22.13.1
 🏎 x  20,326,482.53 ops/sec ± 4.95%   0.000049 ms/op 	▆▆▇▅▆▆▅▅▆▅▅▅▅▅▅▅▅▅▅▅▅▅ Buffer.toString 	19850001 samples
 🏎 x  36,012,545.69 ops/sec ± 1.78%   0.000028 ms/op 	▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ String.fromCodePoint 	35800001 samples
done

Functions

Functions

benchmark [source]
(name: string, fn: () => void): void

Registers a benchmark with the given name and function. Function can be synchronous or asynchronous.

run [source]
(seconds?: number): Promise<void>

Runs all registered benchmarks each for the given number of seconds.

English中文 (Chinese)한국어 (Korean)日本語 (Japanese)Deutsch (German)