repositories
/
benchmarks-js.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build(deps-dev): apply updates
[benchmarks-js.git]
/
quick-select.mjs
diff --git
a/quick-select.mjs
b/quick-select.mjs
index d4270268fc58e25763684dff27533d643fbfdcdb..5fc3ef379d9ee7af6e82c5226f25cfb3d36d4f51 100644
(file)
--- a/
quick-select.mjs
+++ b/
quick-select.mjs
@@
-1,5
+1,6
@@
import { randomInt } from 'node:crypto'
import { randomInt } from 'node:crypto'
-import Benchmark from 'benny'
+
+import { bench, group, run } from 'tatami-ng'
/**
* @param numberOfWorkers
/**
* @param numberOfWorkers
@@
-26,7
+27,7
@@
const tasksMap = generateRandomTasksMap(60, 20)
*/
function loopSelect (tasksMap) {
let minKey
*/
function loopSelect (tasksMap) {
let minKey
- let minValue =
Infinity
+ let minValue =
Number.POSITIVE_INFINITY
for (const [key, value] of tasksMap) {
if (value === 0) {
return key
for (const [key, value] of tasksMap) {
if (value === 0) {
return key
@@
-227,41
+228,27
@@
function quickSelectRecursionRandomPivot (tasksMap) {
)
}
)
}
-Benchmark.suite(
- 'Quick select',
- Benchmark.add('Loop select', () => {
+group('Quick select', () => {
+ bench('Loop select', () => {
loopSelect(tasksMap)
loopSelect(tasksMap)
- })
,
-
Benchmark.add
('Array sort select', () => {
+ })
+
bench
('Array sort select', () => {
arraySortSelect(tasksMap)
arraySortSelect(tasksMap)
- })
,
-
Benchmark.add
('Quick select loop', () => {
+ })
+
bench
('Quick select loop', () => {
quickSelectLoop(tasksMap)
quickSelectLoop(tasksMap)
- })
,
-
Benchmark.add
('Quick select loop with random pivot', () => {
+ })
+
bench
('Quick select loop with random pivot', () => {
quickSelectLoopRandomPivot(tasksMap)
quickSelectLoopRandomPivot(tasksMap)
- })
,
-
Benchmark.add
('Quick select recursion', () => {
+ })
+
bench
('Quick select recursion', () => {
quickSelectRecursion(tasksMap)
quickSelectRecursion(tasksMap)
- })
,
-
Benchmark.add
('Quick select recursion with random pivot', () => {
+ })
+
bench
('Quick select recursion with random pivot', () => {
quickSelectRecursionRandomPivot(tasksMap)
quickSelectRecursionRandomPivot(tasksMap)
- }),
- Benchmark.cycle(),
- Benchmark.complete(),
- Benchmark.save({
- file: 'quick-select',
- format: 'json',
- details: true
- }),
- Benchmark.save({
- file: 'quick-select',
- format: 'chart.html',
- details: true
- }),
- Benchmark.save({
- file: 'quick-select',
- format: 'table.html',
- details: true
})
})
-).catch(console.error)
+})
+
+await run({
+ units: true,
+})