mirror of
https://github.com/SukkaW/Surge.git
synced 2026-02-03 12:31:54 +08:00
Perf: use filesystem cache
This commit is contained in:
16
Build/lib/random-int.bench.ts
Normal file
16
Build/lib/random-int.bench.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { bench, group, run } from 'mitata';
|
||||
import { randomInt as nativeRandomInt } from 'crypto';
|
||||
|
||||
const randomInt = (min: number, max: number) => Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
|
||||
group('random-int', () => {
|
||||
bench('crypto.randomInt', () => {
|
||||
nativeRandomInt(3, 7);
|
||||
});
|
||||
|
||||
bench('Math.random', () => {
|
||||
randomInt(3, 7);
|
||||
});
|
||||
});
|
||||
|
||||
run();
|
||||
Reference in New Issue
Block a user