Latest Benchmarks

Browse the latest JavaScript performance benchmarks created by the community.

Observables: loops versus EventTarget vs extended event

When the “observable” pattern is implemented in JavaScript, it's practically always done using a loop over callbacks. One problem with this approach is that an exception in one handler will crash the entire loop. You can work around this by wrapping the invocation in a try/catch block, but in doing so, you silently swallow the error. The browser provides an event dispatcher for DOM elements that runs each handler in a separate execution context, providing a better failure mode for independent listeners. `EventTarget` is an interface, so you can't directly instantiate one. But you can hijack the `EventTarget` implementation from a dummy object. This test compares multi-listener dispatches using loops and the built-in `EventTarget`. My expectation is that the native mechanism will carry some overhead, partly because of the bespoke execution context, and partly because of the extra properties instantiated on each `CustomEvent` instance. This method also has to look up events by their (string) names, rather than using direct object reference. See http://dean.edwards.name/weblog/2009/03/callbacks-vs-events/

Regex or string javascript replace

No description provided

getAttribute('data-foo') vs dataset.foo

No description provided

foreach vs for...of

Compare loop performance

Math.pow(x, 2) vs. x * x

No description provided

base64 vs json.stringify

No description provided

Regex vs Forloop Performance

-

myarr unshift vs push + reverse (small array)2

No description provided

myarr unshift vs push + reverse (small array)

No description provided

fastest way to convert set to array

No description provided

canvas clearRect vs fillRect

Testing performance between clearRect and fillRect on a canvas.

canvas quadraticCurveTo vs art

canvas quadraticCurveTo vs art

Add new element to array: push vs destructuring vs directly assign

No description provided

instanceof vs .prototype.isPrototypeOf vs .nodeName vs Object.prototype.toString.call vs objType vs objTypeS

Ways of detecting if a variable contains an iframe

Ramda vs. Lodash vs. VanillaJS 2022

Compares performance on the same task using Lodash vs two styles of Ramda vs two styles of "native" Javascript. In all cases the task is pulling "counter" property from each item in an array, filtering out odd items, squaring them, then returning those squared values that have less than two digits.

Fast Sqrt0

Compare Quakes fast inverse squareroot

slice vs filter (10000000)

No description provided

canvas fillStyle color format w/ rendering 2

canvas fillStyle color format

Self Closing vs Closed Tags

No description provided

Object.values overhead cost 1

No description provided

math.abs vs branchless absolute val

No description provided

Includes (array) vs Has (Set)

No description provided

Includes (array) vs Some (array)

No description provided

floor vs bitwise

No description provided

getOwnPropertyNames vs Object.keys - performance

No description provided

NEW BENCHMARK Your Benchmarks