floor vs trunc

Benchmark created on


Setup

const arr = [1.123, 2.234, 3.345, 4.456, 5.567]

Test runner

Ready to run.

Testing in
TestOps/sec
floor
const a = Math.floor(arr[0]);
const b = Math.floor(arr[1]);
const c = Math.floor(arr[2]);
const d = Math.floor(arr[3]);
const e = Math.floor(arr[4]);
ready
trunc
const a = Math.trunc(arr[0]);
const b = Math.trunc(arr[1]);
const c = Math.trunc(arr[2]);
const d = Math.trunc(arr[3]);
const e = Math.trunc(arr[4]);
ready
bitwise or
const a = arr[0] | 0;
const b = arr[1] | 0;
const c = arr[2] | 0;
const d = arr[3] | 0;
const e = arr[4] | 0;
ready

Revisions

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