repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bump typedoc from 0.20.30 to 0.20.31 (#272)
[poolifier.git]
/
benchmarks
/
internal
/
choose-worker.js
diff --git
a/benchmarks/internal/choose-worker.js
b/benchmarks/internal/choose-worker.js
index fe98eff1e0123ad143d2e394ffa59c53ee8afe4a..560a395b69207ec6fede5d6abf39e3a2ad4ba2f3 100644
(file)
--- a/
benchmarks/internal/choose-worker.js
+++ b/
benchmarks/internal/choose-worker.js
@@
-1,17
+1,17
@@
const Benchmark = require('benchmark')
const Benchmark = require('benchmark')
+const { LIST_FORMATTER } = require('./benchmark-utils')
const suite = new Benchmark.Suite()
const suite = new Benchmark.Suite()
-const LIST_FORMATTER = new Intl.ListFormat('en-US', {
- style: 'long',
- type: 'conjunction'
-})
+function generateWorkersArray (numberOfWorkers) {
+ return [...Array(numberOfWorkers).keys()]
+}
-const workers =
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+const workers =
generateWorkersArray(60)
-let nextWorkerIndex
= 0
+let nextWorkerIndex
-function chooseWorkerTernary () {
+function chooseWorkerTernary
OffByOne
() {
nextWorkerIndex =
workers.length - 1 === nextWorkerIndex ? 0 : nextWorkerIndex + 1
return workers[nextWorkerIndex]
nextWorkerIndex =
workers.length - 1 === nextWorkerIndex ? 0 : nextWorkerIndex + 1
return workers[nextWorkerIndex]
@@
-40,15
+40,15
@@
function chooseWorkerIncrementModulo () {
}
suite
}
suite
- .add('Ternary', function () {
+ .add('Ternary
off by one
', function () {
nextWorkerIndex = 0
nextWorkerIndex = 0
- chooseWorkerTernary()
+ chooseWorkerTernary
OffByOne
()
})
.add('Ternary with negation', function () {
nextWorkerIndex = 0
chooseWorkerTernaryWithNegation()
})
})
.add('Ternary with negation', function () {
nextWorkerIndex = 0
chooseWorkerTernaryWithNegation()
})
- .add('Ternary with
PreC
hoosing', function () {
+ .add('Ternary with
pre-c
hoosing', function () {
nextWorkerIndex = 0
chooseWorkerTernaryWithPreChoosing()
})
nextWorkerIndex = 0
chooseWorkerTernaryWithPreChoosing()
})