Skip to content

Commit

Permalink
Pick up DB version from package.json, changed DB version to 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Parashuram committed Mar 1, 2015
1 parent 915021b commit aee5dd1
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 25 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,18 @@ You can also host the HTML/CSS/JS for displaying the results dashboard on not on
This will ensure that all requests for data are made to the other CouchDB server. Also ensure that the CouchDB server has CORS turned on.

## Login before running tests

You can login a user, or perform other kinds of page setup using the [preScript](https://github.com/axemclion/browser-perf/wiki/Node-Module---API#prescript) or the [preScriptFile](https://github.com/axemclion/browser-perf/wiki/Node-Module---API#prescriptfile) options. Here is an [example](https://github.com/axemclion/browser-perf/wiki/FAQ#how-can-i-test-a-page-that-requires-login) of a login action that can be passed in the preScript option.

## Migrating data from older versions
If you have older data and want to move to the latest release of perfjankie, you may also have to migrate your data. You can migrate from older version of a database to a newer version using

```bash
$ perfjankie --config-file=local.config.json --migrate=newDatabaseName
```

This simply transforms all the old data into a format that will work with the newer version of perfjankie. Your version of the database is stored under a document called `version`, and the version supported by your installed version of perfjankie is the key `dbVersion` in the `package.json`

## What does it measure?

Perfjankie measures page rendering times. It collects metrics like frame times, page load time, first paint time, scroll time, etc. It can be used on
Expand Down
2 changes: 1 addition & 1 deletion lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = function(config) {
var db = server.use(config.couch.database);
return Q.ninvoke(db, 'get', 'version').catch(function(err) {
return Q.ninvoke(db, 'insert', {
version: '0.2.0'
version: require('../package.json').dbVersion
}, 'version');
});
});
Expand Down
50 changes: 50 additions & 0 deletions migrations/migrate-0.3.0.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Migrating from 0.2.x to 1.2.x

var Q = require('q');

var utility = require('./utility');

module.exports = function(oldDb, newDb, config) {
var log = config.log;

return utility.forEachDoc(oldDb, newDb, function(doc) {
if (doc.type !== 'perfData') {
return null;
}
delete doc._id;
delete doc._rev;

for (var key in doc.data) {
if (typeof doc.data.mean_frame_time === 'number') { // From TracingMetrics
doc.data.frames_per_sec = 1000 / doc.data.mean_frame_time;
}
if (typeof doc.data.meanFrameTime === 'number') { // from RAF
doc.data.framesPerSec_raf = 1000 / doc.data.meanFrameTime;

}
}

return doc;
});
};

var getFramesPerSec = function(val, metrics) {
var mft;
// Iterate over each candidate to calculate FPS
for (var i = 0; i < metrics.length; i++) {
if (val[metrics[i]]) {
mft = val[metrics[i]].sum / val[metrics[i]].count;
}
if (mft >= 10 && mft <= 60) {
break;
} else {
mft = null;
}
}
if (mft) {
return {
sum: 1000 / mft,
count: 1
};
}
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "perfjankie",
"version": "1.2.2",
"dbVersion": "0.3.0",
"description": "Browser Performance regression suite",
"main": "lib/index.js",
"scripts": {
Expand Down
26 changes: 2 additions & 24 deletions www/app/summary/tiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,16 @@ angular
}
};

var getFramesPerSec = function(val, metrics) {
var mft;
// Iterate over each candidate to calculate FPS
for (var i = 0; i < metrics.length; i++) {
if (val[metrics[i]]) {
mft = val[metrics[i]].sum / val[metrics[i]].count;
}
if (mft >= 10 && mft <= 60) {
break;
} else {
mft = null;
}
}
if (mft) {
return {
sum: 1000 / mft,
count: 1
};
}
};

var prepareData = function(val) {
var tiles = [];
val.frames_per_sec = getFramesPerSec(val, ['mean_frame_time', 'meanFrameTime']);
return metricsList().then(function(metricsList) {
angular.forEach(['frames_per_sec', 'firstPaint', 'ExpensivePaints', 'NodePerLayout_avg', 'ExpensiveEventHandlers', ], function(metric) {
angular.forEach(['frames_per_sec', 'framesPerSec_raf', 'firstPaint', 'ExpensivePaints', 'NodePerLayout_avg', 'ExpensiveEventHandlers', ], function(metric) {
if (typeof val[metric] === 'object') {
tiles.push({
metric: metric,
unit: metricsList[metric].unit,
value: val[metric].sum / val[metric].count,
link: metric === 'frames_per_sec' ? 'meanFrameTime' : metric
link: metric
});
}
});
Expand Down

0 comments on commit aee5dd1

Please sign in to comment.