Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Test for numbers
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:133.0) Gecko/20100101 Firefox/133.0
Browser:
Firefox 133
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
match
204769.3 Ops/sec
split
205348.8 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
function generateRandomString(length) { const randomValues = new Uint8Array(length); window.crypto.getRandomValues(randomValues); const randomChars = Array.from(randomValues, (value) => String.fromCharCode(value)); return randomChars.join(''); } const text = generateRandomString(1000); function extractNumbers(text) { if (typeof text !== 'string') { throw new Error('Invalid input: Must provide a valid string') } const numbers = text.match(/\d+/g) const result = [] for (let i = 0; i < numbers.length; i++) { result.push(+numbers[i]) } return result }
Tests:
match
const numbers = text.match(/\d+/g) console.log(numbers)
split
const numbers = text.split(/\d+/g) console.log(numbers)