Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Bearer Token Strip
(version: 0)
Benchmark.js
Comparing performance of:
Replace vs Split
Created:
2 years ago
by:
Guest
Go to the latest result
Script Preparation code:
var token = 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY5NjIwOGMwNTkzZWIyNDZjOWQ0ZTc1YmJhMmM0NDQ3MGJjMmVjZWY1YjI1YWYxMTYyZjk4ZTgyNDAyYjNjMWYiLCJpYXQiOjE3MDMxNDAwNDMsImV4cCI6MTcxMDkxNjA0M30.zuRKSUDRUL7yIF_aISawc6xuVVIk-RZg8G8cRoV79EgeyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY5NjIwOGMwNTkzZWIyNDZjOWQ0ZTc1YmJhMmM0NDQ3MGJjMmVjZWY1YjI1YWYxMTYyZjk4ZTgyNDAyYjNjMWYiLCJpYXQiOjE3MDMxNDAwNDMsImV4cCI6MTcxMDkxNjA0M30.zuRKSUDRUL7yIF_aISawc6xuVVIk-RZg8G8cRoV79Eg'
Tests:
Replace
const a = token.replace(/^Bearer\s/, '');
Split
const b = token.split(' ')[1];
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Replace
Split
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Browser/OS:
Chrome 119 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Split
16.7M/s
Replace
2.8M/s
View exact numbers
Test name
Executions per second
✓
Split
16,673,775 Ops/sec
Replace
2,776,168 Ops/sec
Related benchmarks
Remove bearer prefix from JWT token
Regexp vs split cookie
JWT token Split vs Basic string replace
Comments
Confirm delete:
Do you really want to delete benchmark?