Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
predefined values to check
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
use predefined
72674784.0 Ops/sec
use inline
173916480.0 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
class Utility { static allowedValues = [true, false, 'true', 'false', 1, 0, '1', '0']; static isBooleanInline(value) { return value === true || value === false || value === 'true' || value === 'false' || value === 1 || value === 0 || value === '1' || value === '0'; } static isBooleanPredefined(value) { return this.allowedValues.includes(value); } } let value = 2;
Tests:
use predefined (no cache, false)
const valid = Utility.isBooleanPredefined(++value);
use inline (no cache, false)
const valid = Utility.isBooleanInline(++value);
use predefined (cache, false)
const valid = Utility.isBooleanPredefined('a');
use inline (cache, false)
const valid = Utility.isBooleanInline('a');
use predefined (no cache, true)
const valid = Utility.isBooleanPredefined(++value % 2);
use inline (no cache, true)
const valid = Utility.isBooleanInline(++value % 2);
use predefined (cache, true)
const valid = Utility.isBooleanPredefined(1);
use inline (cache, true)
const valid = Utility.isBooleanInline(1);