Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
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 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0
Browser:
Firefox 122
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
Multiple if Conditions
264.9M/s
Array.includes
13.0M/s
String.match
6.8M/s
View exact numbers
Test name
Executions per second
✓
Multiple if Conditions
264,869,440 Ops/sec
Array.includes
13,043,796 Ops/sec
String.match
6,752,355 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') {}