regex-test_sashe

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
/([A-Za-z0-9_]){1,255}/g
// Setup
const sampleString = 'a1b2c3_' + 'x'.repeat(30 - 8); // 30chars
const regex1 = /([A-Za-z0-9_]){1,255}/g;

// Benchmark
function benchmark() {
    const startTime = performance.now();
    for (let i = 0; i < 1000; i++) {
        regex1.lastIndex = 0; 
        regex1.test(sampleString);
    }
    const endTime = performance.now();
    return endTime - startTime;
}

// Run the benchmark
benchmark();
ready
/([A-Za-z0-9_]+){1,255}/g
// Setup
const sampleString = 'a1b2c3_' + 'x'.repeat(30 - 8); // 30chars
const regex2 = /([A-Za-z0-9_]+){1,255}/g;

// Benchmark
function benchmark() {
    const startTime = performance.now();
    for (let i = 0; i < 1000; i++) { 
        regex2.lastIndex = 0; 
        regex2.test(sampleString);
    }
    const endTime = performance.now();
    return endTime - startTime;
}

// Run the benchmark
benchmark();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.