isByte

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
original
function isByte(n) {
  return [...Array.from({ length: 256 }).keys()].includes(n);
}

for (let i = 0; i < 100_000; i++) {
	isByte(i);
}
ready
new
function isByte(n) {
  return Number.isInteger(n) && n >= 0 && n <= 255;
}

for (let i = 0; i < 100_000; i++) {
	isByte(i);
}
ready

Revisions

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