Baseline {
total_runtime: 171,
total_step_runtime: 8,
average_step_runtime: 0.00008
}
Speed /static/1 {
total_runtime: 280,
total_step_runtime: 104,
average_step_runtime: 0.00104,
total_off_baseline: 109,
total_step_off_baseline: 96,
average_step_off_baseline: 0.0009599999999999999
}
Speed /static/50 {
total_runtime: 258,
total_step_runtime: 90,
average_step_runtime: 0.0009,
total_off_baseline: 87,
total_step_off_baseline: 82,
average_step_off_baseline: 0.00082
}
Speed /static/100 {
total_runtime: 278,
total_step_runtime: 103,
average_step_runtime: 0.00103,
total_off_baseline: 107,
total_step_off_baseline: 95,
average_step_off_baseline: 0.0009500000000000001
}
Last active
January 30, 2022 13:41
-
-
Save iurisilvio/a916ce2de16336ec97aab8db5525f7f9 to your computer and use it in GitHub Desktop.
vue-router optimization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*eslint-disable no-undef*/ | |
import timeit from 'timeit' | |
import { createMatcher } from '../../../src/create-matcher' | |
fdescribe('Bench', function () { | |
const data = [] | |
for (let i = 0; i < 100; i++) { | |
const path = `/static/${i}` | |
const name = `static-${i}` | |
data.push({ path, name, component: { name }}) | |
} | |
it('bench', function (done) { | |
_timeit(data, ['/static/1', '/static/50', '/static/100'], done) | |
}) | |
}) | |
function _timeit (data, paths, done) { | |
function factory (path) { | |
return function match (done) { | |
matcher.match(path) | |
done() | |
} | |
} | |
const matcher = createMatcher(data) | |
const iterations = 100000 | |
timeit.howlong(iterations, paths.map(factory), function (err, results) { | |
if (err) { | |
console.log('DO NOTHING') | |
} | |
console.log('Baseline', results[0]) | |
paths.forEach((path, index) => { | |
console.log(`Speed ${path}`, results[index + 1]) | |
}) | |
done() | |
}) | |
} |
Baseline {
total_runtime: 193,
total_step_runtime: 12,
average_step_runtime: 0.00012
}
Speed /static/1 {
total_runtime: 311,
total_step_runtime: 142,
average_step_runtime: 0.00142,
total_off_baseline: 118,
total_step_off_baseline: 130,
average_step_off_baseline: 0.0013
}
Speed /static/50 {
total_runtime: 935,
total_step_runtime: 753,
average_step_runtime: 0.00753,
total_off_baseline: 742,
total_step_off_baseline: 741,
average_step_off_baseline: 0.00741
}
Speed /static/100 {
total_runtime: 1573,
total_step_runtime: 1413,
average_step_runtime: 0.01413,
total_off_baseline: 1380,
total_step_off_baseline: 1401,
average_step_off_baseline: 0.01401
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment