JavaScript Benchmark Tool

This tool benchmarks and compares multiple snippets of code to see which is fastest.

The performance of each snippet is measured by repeatedly running it and measuring the total time. The slowest snippet is run for the specified benchmark time, and the faster snippets for a fraction of that. The results show what factor faster that other snippets are, such as 2.4x, relative to the slowest, which is always 1x. If you have only one snippet of code, it will just display the average time it takes. Choosing a longer benchmark time will produce more accurate results, but will take longer.

The code snippets are run as JavaScript functions, f(x), where x is always provided as 0. Use the variable x if you need an external dependency to prevent the optimizer from observing that your function is static, and precomputing the final value. Additionally, you can return a value to prevent the compiler from completely discarding your function because it does nothing to affect the state elsewhere. This is also handy if you want to verify that multiple snippets actually give the same answer. The return value will be displayed below the measured performance factor.

Examples:


Benchmark Time: sec.