This is the new version of this: JavaScriptにおける各種yield方式のパフォーマンス計測
make
bench-simple.mjs
receives fnName
as a command line argument. Why is this needed?
Execution of "yield" seemed to be getting slower if every benchmarks are executed in a single process.
The result of mitata
shows much difference between yieldMsgChannel
and yieldMsgChannelOnMsg
.
yieldMsgChannel 66.04 µs/iter (14.88 µs … 3.21 ms)
yieldMsgChannelOnMsg 122.89 µs/iter (84.55 µs … 3.35 ms)
The result when I swap execution order of these functions:
yieldMsgChannelOnMsg 68.27 µs/iter (14.76 µs … 4.12 ms)
yieldMsgChannel 135.36 µs/iter (87.11 µs … 3.83 ms)
I think creation of a lot of MessageChannel is the cause of that.
Therefore, benchmarks are executed separately in bench-simple
.
concurrency = 50
yieldSetTimeout 1071.667169 µs/iter
yieldMsgChannel 81.651383 µs/iter
yieldThreadOnMessage 81.587442 µs/iter
yieldMsgChannelGlobal 1.249464 µs/iter
concurrentYieldSetTimeout 1089.949913 µs/iter
concurrentYieldMsgChannel 1457.519035 µs/iter
concurrentYieldMsgChannelOnMsg 1468.519564 µs/iter
concurrentYieldMsgChannelGlobal 75.619222 µs/iter
cpu: AMD Ryzen 7 PRO 7840U w/ Radeon 780M Graphics
runtime: node v21.3.0 (x64-linux)
benchmark time (avg) (min … max)
------------------------------------------------------------------------
yieldSetTimeout 1.07 ms/iter (1.03 ms … 1.63 ms)
yieldMsgChannel 66.04 µs/iter (14.88 µs … 3.21 ms)
yieldMsgChannelOnMsg 122.89 µs/iter (84.55 µs … 3.35 ms)
yieldMsgChannelGlobal 1.9 µs/iter (1.46 µs … 3.73 µs)
concurrent-yieldSetTimeout 1.09 ms/iter (18.84 µs … 1.8 ms)
concurrent-yieldMsgChannel 1.84 ms/iter (494.2 µs … 9.37 ms)
concurrent-yieldMsgChannelOnMsg 6.64 ms/iter (2.94 ms … 12.36 ms)
concurrent-yieldMsgChannelGlobal 309.1 µs/iter (55.63 µs … 9.44 ms)