mathiasbynens/jsperf.com — Issue #37: Startup within lexical scope
Author: bhk
Created: 2011-10-23 18:11:45+00:00
State: open

Since startup and teardown snippets are placed in separate functions (distinct from each other and from the test snippets), data shared with the text snippet must use a global variable. In many VMs access to global variables can be slower than access to lexically scoped variables, distorting measurements for snippets that use variables initialized during setup.

Workarounds are possible, but they are ugly and decrease the quality of the measurement:

http://jsperf.com/current-time

One solution would be to define the iteration functions (and teardown) within the lexical scope of the startup function.