axemclion / browser-perf

Performance Metrics for Web Browsers
BSD 2-Clause "Simplified" License
937 stars 61 forks source link

Run the node module multiple times #90

Closed PatrickDai closed 6 years ago

PatrickDai commented 6 years ago

How could I run browserPerf(...) 5 times in a row ?

I tried to do that within a for loop, it opens me 5 Chrome but it seems that only the 1st one ends correctly. The others don't return me any metrics

const browserPerf = require('browser-perf');

for (let i = 0; i < 5; i++) {
  browserPerf(myUrl, (err, res) => console.log('res: ', res)); 
} 

output:

res: [ { connectedEnd: ..., ...}] res: [] res: [] res: [] res: []

axemclion commented 6 years ago

browserPerf returns a callback - so you cannot just use a sync loop. You would have to call the furthur iterations in a callback.