repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update src/worker/worker-options.ts
[poolifier.git]
/
benchmarks
/
choose-worker.js
diff --git
a/benchmarks/choose-worker.js
b/benchmarks/choose-worker.js
index 38e6fc7c5a4a772f50fb08f899173db7e3763b25..fe98eff1e0123ad143d2e394ffa59c53ee8afe4a 100644
(file)
--- a/
benchmarks/choose-worker.js
+++ b/
benchmarks/choose-worker.js
@@
-17,7
+17,15
@@
function chooseWorkerTernary () {
return workers[nextWorkerIndex]
}
return workers[nextWorkerIndex]
}
-function chooseWorkerIncrementModuloWithPreChoosing () {
+function chooseWorkerTernaryWithNegation () {
+ nextWorkerIndex =
+ !nextWorkerIndex || workers.length - 1 === nextWorkerIndex
+ ? 0
+ : nextWorkerIndex + 1
+ return workers[nextWorkerIndex]
+}
+
+function chooseWorkerTernaryWithPreChoosing () {
const chosenWorker = workers[nextWorkerIndex]
nextWorkerIndex =
workers.length - 1 === nextWorkerIndex ? 0 : nextWorkerIndex + 1
const chosenWorker = workers[nextWorkerIndex]
nextWorkerIndex =
workers.length - 1 === nextWorkerIndex ? 0 : nextWorkerIndex + 1
@@
-36,9
+44,13
@@
suite
nextWorkerIndex = 0
chooseWorkerTernary()
})
nextWorkerIndex = 0
chooseWorkerTernary()
})
- .add('Increment+Modulo with PreChoosing', function () {
+ .add('Ternary with negation', function () {
+ nextWorkerIndex = 0
+ chooseWorkerTernaryWithNegation()
+ })
+ .add('Ternary with PreChoosing', function () {
nextWorkerIndex = 0
nextWorkerIndex = 0
- chooseWorker
IncrementModulo
WithPreChoosing()
+ chooseWorker
Ternary
WithPreChoosing()
})
.add('Increment+Modulo', function () {
nextWorkerIndex = 0
})
.add('Increment+Modulo', function () {
nextWorkerIndex = 0