Skip to content

Latest commit

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

JS benchmark framework

A tiny framework for quick benchmarking with Benchmark.js.

Motivation

JSPerf.com was down!

Usage

Create an HTML doc for your perf tests like this:

<html><body><!-- Step 1: Include framework --><scriptsrc="benchmark-framework.min.js"></script><!-- Step 2 [optional]: Define setup code --><scripttype="benchmark-opt" name="setup">console.log("Setting stuff up!");</script><!-- Step 3 [optional]: Define teardown code --><scripttype="benchmark-opt" name="teardown">console.log("I'm tearing stuff down!");</script><!-- Step 4: Define test cases --><scripttype="benchmark-test" name="reverse loop">varsum=0;vari=1000;while(i--){sum+=i;}</script><scripttype="benchmark-test" name="forward loop">varsum=0;vari=0;varlimit=1000;while(i++<limit){sum+=i;}</script></body></html>

Open this document in any browser (or multiple browsers!) and observe the perf results in the console.

See also the example in test/test_perf.html.

Advanced

The benchmark-opt and benchmark-event script types accept any parameter that Benchmark.js can accept for options and events, respectively. For example, <script type="benchmark-event" name="abort">/* stuff */</script> will compile that inner code and use it as the onAbort event handler.

The event scripts accept one parameter named event. You can use this to customize how results are reported.

About

Tiny JS benchmark framework

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages