Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Test URI for File Extension
Tests methods of checking for a specific file extension
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Browser:
Chrome 120
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Split Positive
10081897.0 Ops/sec
Split Negative
9787709.0 Ops/sec
EndsWith Positive
14510161.0 Ops/sec
EndsWith Negative
17058216.0 Ops/sec
Script Preparation code:
function checkUsingSplit(uri) { return uri.split('.').pop() === 'html'; } function checkUsingEndsWith(uri) { return uri.endsWith('.html'); } function checkUsingSlice(uri) { return uri.slice(-5) === '.html'; }
Tests:
Split Positive
checkUsingSplit('/example/path/index.html');
Split Negative
checkUsingSplit('/example/path/index');
EndsWith Positive
checkUsingEndsWith('/example/path/index.html');
EndsWith Negative
checkUsingEndsWith('/example/path/index');
Slice Positive
checkUsingSlice('/example/path/index.html');
Slice Negative
checkUsingSlice('/example/path/index');