diff --git a/README.md b/README.md index e31bddb..419f268 100644 --- a/README.md +++ b/README.md @@ -98,3 +98,8 @@ Also, `index.html` must be modified to include these lines: ``` + + +If you need to make changes to the `fps-emit` package, bump the version number in its `package.json`, +then update each benchmark to use the newest version using `yarn upgrade-interactive` and selecting `fps-emit` +for an update. Then rebuild all the benchmarks using `yarn initialize` diff --git a/fps-emit/package.json b/fps-emit/package.json index 344b3c6..44d0046 100644 --- a/fps-emit/package.json +++ b/fps-emit/package.json @@ -1,11 +1,14 @@ { "name": "fps-emit", "private": true, - "version": "1.0.0", + "version": "1.0.1", "description": "fps emitter", "main": "src/index.js", "scripts": { - "build": "cross-env BABEL_ENV=rollup NODE_ENV=production rollup -c -o dist/fps-emit.min.js", + "build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib", + "build:es": "babel src --out-dir es", + "build:umd:min": "cross-env NODE_ENV=production rollup -c -o dist/react-redux.min.js", + "build": "yarn run build:commonjs && yarn run build:es && yarn run build:umd:min", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "Gregory Beaver ", diff --git a/fps-emit/src/index.js b/fps-emit/src/index.js index 03652d0..d64a9b9 100644 --- a/fps-emit/src/index.js +++ b/fps-emit/src/index.js @@ -13,6 +13,12 @@ fps.on("update", function(FPS) { }); const getFpsStats = () => { + // fake a final entry with the same FPS + const finalFPS = fps.__fps + marker.mark("FPS", { + details: { FPS : finalFPS, isFinal : true } + }); + const logData = performance.getEntriesByType("mark").map(entry => { const meta = marker.getEntryMetadata(entry); return { diff --git a/runBenchmarks.js b/runBenchmarks.js index 412c4c9..b5f611d 100644 --- a/runBenchmarks.js +++ b/runBenchmarks.js @@ -83,32 +83,29 @@ async function runBenchmarks() { const averageFPS = fpsValuesWithoutFirst.reduce((sum, entry) => sum + entry.FPS, 0) / fpsValuesWithoutFirst.length || 0; - const fpsValuesPlusFakeEntries = [ - ...fpsValuesWithoutFirst, - {...lastEntry, timestamp : length * 1000} - ] - - const pairwiseEntries = pairwise(fpsValuesPlusFakeEntries); + const pairwiseEntries = pairwise(fpsValuesWithoutFirst); const fpsValuesWithDurations = pairwiseEntries.map(pair => { const [first, second] = pair; const duration = second.timestamp - first.timestamp; + const durationSeconds = duration / 1000.0 - return {FPS : second.FPS, duration} + return {FPS : first.FPS, durationSeconds} }) const sums = fpsValuesWithDurations.reduce( (prev, current) => { + const weightedFPS = current.FPS * current.durationSeconds; + return { - FPS : prev.FPS + current.FPS, - duration : prev.duration + current.duration + weightedFPS : prev.weightedFPS + weightedFPS, + durationSeconds : prev.durationSeconds + current.durationSeconds, } - }, {FPS : 0, duration : 0}); + }, {FPS : 0, weightedFPS : 0, durationSeconds : 0}); - const durationSeconds = sums.duration / 1000.0; - const weightedFPS = sums.FPS / durationSeconds; + const weightedFPS = sums.weightedFPS / sums.durationSeconds; - const fps = {averageFPS, weightedFPS, values : fpsValues} + const fps = {averageFPS, weightedFPS, values : fpsValuesWithoutFirst} versionPerfEntries[version] = {fps, profile : {categories}}; diff --git a/utils/server.js b/utils/server.js index f446166..e77ff00 100644 --- a/utils/server.js +++ b/utils/server.js @@ -64,8 +64,8 @@ module.exports = { ) || [] fpsValues = fpsStatsEntries.map(entry => { - const {FPS} = entry.meta.details; - return {FPS, timestamp : entry.timeStamp}; + const {FPS, isFinal} = entry.meta.details; + return {FPS, timestamp : entry.timeStamp, isFinal}; }); await page.close();