mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
17 lines
368 B
TypeScript
17 lines
368 B
TypeScript
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();
|