872 B
872 B
speci.js - specialization benchmark test
Tests two-property objects with {x, y} or {y, x} and access in a tight loop When the array contains consistent elements it optimizes well, but the first run is much slower on a randomly mixed array.
Subsequent runs come up much faster as the higher-tier compilers in V8 can handle a couple of different variants -- but this might not be true of all possibilities. 256 randomized variants is linearly slower.
% make test
node speci.js x-first
** x-first
run 1
189 ms
run 2
293 ms
run 3
178 ms
node speci.js y-first
** y-first
run 1
196 ms
run 2
175 ms
run 3
174 ms
node speci.js mixed
** mixed
run 1
732 ms
run 2
716 ms
run 3
912 ms
node speci.js rand-suffix
** rand-suffix
run 1
15596 ms
run 2
15636 ms
run 3
15501 ms
node speci.js rand-prefix
** rand-prefix
run 1
18896 ms
run 2
18883 ms
run 3
18784 ms