Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array.includes vs String.match
Matching a string against more than one possibility.
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 128
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
Array.includes
27064550.0 Ops/sec
String.match
4158945.0 Ops/sec
Multiple if Conditions
56460076.0 Ops/sec
Tests:
Array.includes
const testStrFirst = 'foo'; ['foo', 'bar'].includes(testStrFirst); const testStrSecond = 'bar'; ['foo', 'bar'].includes(testStrSecond); const testStrNotMatch = 'baz'; ['foo', 'bar'].includes(testStrNotMatch);
String.match
const testStrFirst = 'foo'; testStrFirst.match(/^(foo|bar)$/); const testStrSecond = 'bar'; testStrSecond.match(/^(foo|bar)$/); const testStrNotMatch = 'baz'; testStrNotMatch.match(/^(foo|bar)$/);
Multiple if Conditions
const testStrFirst = 'foo'; if (testStrFirst == 'foo' || testStrFirst == 'bar') {} const testStrSecond = 'bar'; if (testStrFirst == 'foo' || testStrFirst == 'bar') {} const testStrNotMatch = 'baz'; if (testStrFirst == 'foo' || testStrFirst == 'bar') {}