Skip to content

Fix fps emit #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,8 @@ Also, `index.html` must be modified to include these lines:
<script type="text/javascript" src="react-dom.production.min.js"></script>
<script type="text/javascript" src="react-redux.min.js"></script>
```


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`
7 changes: 5 additions & 2 deletions fps-emit/package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
Expand Down
6 changes: 6 additions & 0 deletions fps-emit/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
23 changes: 10 additions & 13 deletions runBenchmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}};

Expand Down
4 changes: 2 additions & 2 deletions utils/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down