Is even function comparison

Benchmark created on


Setup

const isEven = x => !!(~x & 1)
const isEven2 = x => Boolean(~x & 1)
const restEven = x => !(x % 2 !== 0)

const n = Math.floor(Math.random() * 999)

Test runner

Ready to run.

Testing in
TestOps/sec
Bitwise comparison (double negate operators)
isEven(n)
isEven(-n)
ready
Bitwise comparison (with boolean function)
isEven2(n)
isEven2(-n)
ready
classic isEven function (with suport to negative numbers)
restEven(n)
restEven(-n)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.