measure.js
This file
Path
__performance_tests__/measure.js
20 lines · 499 bytes · JavaScript
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than fbae585 point at it.
docs: fix video player scrolling on chrome, fixes #520Michel Weststratebefore adoptionfbae585
lines 1–20why, one step back1"use strict"23function measureTime(setup, fn) {4 if (!fn) {5 fn = setup6 setup = () => {}7 }8 const args = setup()9 global.gc && global.gc()10 const startTime = Date.now()11 fn(args)12 const endTime = Date.now()13 return endTime - startTime14}1516export function measure(name, setup, fn) {17 const times = [...Array(5)].map(() => measureTime(setup, fn))18 const medianTime = times.sort()[Math.round(times.length / 2)]19 console.log(`${name}: ${medianTime}ms`)20}