├── .gitignore ├── .jshintrc ├── .npmignore ├── .travis.yml ├── Gruntfile.js ├── README.md ├── bower.json ├── lib ├── cli.js ├── couch-views │ ├── metrics_data.js │ ├── pagelist.js │ └── runs.js ├── couchData.js ├── couchSite.js ├── couchViews.js ├── index.js ├── init.js ├── mime.js ├── options.js ├── perfTests.js └── utils.js ├── migrations ├── cli.js ├── index.js ├── migrate-0.2.0.js ├── migrate-0.3.0.js ├── migrate-0.4.0.js └── utility.js ├── package.json ├── tasks ├── metricsgen.js └── task.js ├── test ├── index.spec.js ├── res │ ├── local.config.json │ ├── sample-perf-results.json │ ├── test1.html │ └── test2.html ├── seedData.js └── util.js └── www ├── app ├── all-metrics │ ├── all-metrics.html │ ├── all-metrics.less │ └── allmetrics.js ├── app.js ├── backend.js ├── font.less ├── main-page │ ├── error.less │ ├── navbar.html │ ├── navbar.less │ ├── no-pj-brand.less │ ├── sidebar.html │ ├── sidebar.js │ └── sidebar.less ├── main.less ├── metric-details │ ├── metric-detail.html │ ├── metric-detail.less │ ├── metricDetail.js │ └── metricDetailsGraph.js ├── page-select │ ├── page-select.html │ ├── page-select.less │ └── pageSelect.js └── summary │ ├── networkTimingGraph.js │ ├── paintCycleGraph.js │ ├── summary.html │ ├── summary.js │ ├── summary.less │ ├── tiles.js │ ├── tiles.less │ └── tiles.tpl.html ├── assets ├── css │ ├── animation.css │ ├── config.json │ └── fontello-codes.css └── fonts │ ├── fontello-codes.css │ ├── fontello.eot │ ├── fontello.svg │ ├── fontello.ttf │ └── fontello.woff ├── index.html └── server └── endpoints.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | bower_components/ 3 | bin/ 4 | bin-site/ 5 | *.log 6 | .DS_Store 7 | .idea/* 8 | .tmp/* 9 | dist/* 10 | _replicator/* 11 | _users/* 12 | pouch__all_dbs__/* 13 | version/* 14 | log.txt 15 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "curly": true, 3 | "eqeqeq": true, 4 | "immed": true, 5 | "latedef": true, 6 | "newcap": true, 7 | "noarg": true, 8 | "sub": true, 9 | "undef": true, 10 | "boss": true, 11 | "eqnull": true, 12 | "node": true, 13 | "shadow": true, 14 | "expr": true, 15 | "globals": { 16 | "angular": false, 17 | "$": false, 18 | "window": false, 19 | "ENDPOINTS": false, 20 | "describe": false, 21 | "it": false, 22 | "beforeEach": false, 23 | "before": false, 24 | "xit": false, 25 | "xdescribe": false 26 | } 27 | } -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | bower_components/ 3 | Gruntfile.js 4 | test/ 5 | www/ 6 | bower.json 7 | .jshintrc 8 | .gitignore 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - "0.12" 5 | - "4.0" 6 | - "4.3" 7 | - "4" 8 | - "5.0" 9 | - "5" 10 | - "6" 11 | - "stable" 12 | env: 13 | - NPM_VERSION=2 14 | - NPM_VERSION=3 15 | 16 | services: couchdb 17 | 18 | before_install: 19 | - npm install -g npm@$NPM_VERSION 20 | - npm install -g grunt-cli 21 | before_script: 22 | - npm install 23 | - "export DISPLAY=:99.0" 24 | - "sh -e /etc/init.d/xvfb start" 25 | - sleep 3 # give xvfb some time to start 26 | script: npm test 27 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | 3 | var couchdb = require('./test/util').config({ 4 | log: 1 5 | }).couch; 6 | var serveStatic = require('serve-static'); 7 | var path = require('path'); 8 | var jqplot = [ 9 | 'jquery.jqplot.min.js', 10 | 'plugins/jqplot.categoryAxisRenderer.min.js', 11 | 'plugins/jqplot.highlighter.min.js', 12 | 'plugins/jqplot.canvasTextRenderer.min.js', 13 | 'plugins/jqplot.canvasAxisTickRenderer.min.js', 14 | 'plugins/jqplot.canvasAxisLabelRenderer.min.js', 15 | 'plugins/jqplot.barRenderer.min.js', 16 | 'plugins/jqplot.trendline.min.js', 17 | 'plugins/jqplot.pieRenderer.min.js' 18 | ]; 19 | 20 | grunt.initConfig({ 21 | jshint: { 22 | all: [ 23 | 'Gruntfile.js', 24 | 'lib/*.js', 25 | 'test/**/*.js', 26 | 'www/**/*.js' 27 | ], 28 | options: { 29 | jshintrc: '.jshintrc' 30 | }, 31 | }, 32 | 33 | metricsgen: { 34 | files: { 35 | dest: 'bin-site/metrics.js' 36 | } 37 | }, 38 | 39 | uglify: { 40 | options: { 41 | mangle: false, 42 | sourceMap: true, 43 | sourceMapName: 'bin-site/main.js.map', 44 | }, 45 | js: { 46 | files: { 47 | 'bin-site/main.js': ['www/**/*.js', 'bin-site/**/*.js'] 48 | } 49 | } 50 | }, 51 | 52 | concat: { 53 | jqplot: { 54 | src: jqplot.map(function(file) { 55 | return 'bower_components/jqplot-bower/dist/' + file; 56 | }), 57 | dest: 'bin-site/jqplot.js' 58 | }, 59 | less: { 60 | src: ['bower_components/jqplot-bower/dist/jquery.jqplot.min.css', 'www/app/**/*.less', 'www/assets/css/*.css'], 61 | dest: 'bin-site/main.less' 62 | } 63 | }, 64 | 65 | less: { 66 | dev: { 67 | files: { 68 | 'bin-site/main.css': 'bin-site/main.less' 69 | } 70 | }, 71 | dist: { 72 | options: { 73 | compress: true 74 | }, 75 | files: { 76 | 'bin-site/main.css': 'bin-site/main.less' 77 | } 78 | } 79 | }, 80 | 81 | autoprefixer: { 82 | less: { 83 | src: 'bin-site/main.css', 84 | dest: 'bin-site/main.css' 85 | } 86 | }, 87 | 88 | copy: { 89 | partials: { 90 | expand: true, 91 | cwd: 'www/app', 92 | src: ['**/*.html'], 93 | dest: 'bin-site/app' 94 | }, 95 | fonts: { 96 | expand: true, 97 | cwd: 'www/assets', 98 | src: ['fonts/*.*'], 99 | dest: 'bin-site/assets' 100 | }, 101 | endpoints: { 102 | src: ['www/server/endpoints.js'], 103 | dest: 'bin-site/server/endpoints.js' 104 | } 105 | }, 106 | 107 | processhtml: { 108 | dev: { 109 | options: { 110 | strip: true, 111 | data: { 112 | scripts: jqplot.map(function(file) { 113 | return 'jqplot-bower/dist/' + file; 114 | }).concat(grunt.file.expand({ 115 | cwd: 'www' 116 | }, 'app/**/*.js')), 117 | } 118 | }, 119 | files: { 120 | 'bin-site/index.html': 'www/index.html' 121 | } 122 | }, 123 | dist: { 124 | options: { 125 | data: { 126 | scripts: ['main.js'] 127 | } 128 | }, 129 | files: { 130 | 'bin-site/index.html': 'www/index.html' 131 | } 132 | } 133 | }, 134 | htmlmin: { 135 | dist: { 136 | options: { 137 | removeComments: true, 138 | collapseWhitespace: true, 139 | conservativeCollapse: true, 140 | collapseBooleanAttributes: true 141 | }, 142 | files: { 143 | 'bin-site/index.html': 'bin-site/index.html' 144 | } 145 | }, 146 | }, 147 | connect: { 148 | proxies: [{ 149 | changeOrigin: false, 150 | host: 'localhost', 151 | port: '5984', 152 | context: grunt.file.expand('lib/couch-views/**/*.js').map(function(file) { 153 | return '/' + path.basename(file, '.js'); 154 | }), 155 | rewrite: (function(files) { 156 | var res = {}; 157 | files.forEach(function(file) { 158 | var view = path.basename(file, '.js'); 159 | res[view + '/_view'] = ['/', couchdb.database, '/_design/', view, '/_view'].join(''); 160 | }); 161 | return res; 162 | }(grunt.file.expand('lib/couch-views/**/*.js'))) 163 | }], 164 | dev: { 165 | options: { 166 | hostname: '*', 167 | port: 9000, 168 | base: ['test/res', 'bower_components', 'bin-site', 'www'], 169 | livereload: true, 170 | middleware: function(connect, options) { 171 | var middlewares = []; 172 | if (!Array.isArray(options.base)) { 173 | options.base = [options.base]; 174 | } 175 | middlewares.push(require('grunt-connect-proxy/lib/utils').proxyRequest); 176 | options.base.forEach(function(base) { 177 | middlewares.push(serveStatic(base)); 178 | }); 179 | return middlewares; 180 | }, 181 | useAvailablePort: true, 182 | } 183 | } 184 | }, 185 | watch: { 186 | options: { 187 | livereload: true, 188 | }, 189 | views: { 190 | files: ['lib/couch-views/*.js'], 191 | tasks: ['deployViews'] 192 | }, 193 | less: { 194 | files: ['www/**/*.less'], 195 | tasks: ['concat:less', 'less:dev', 'autoprefixer'] 196 | }, 197 | html: { 198 | files: ['www/index.html'], 199 | tasks: ['processhtml:dev'] 200 | }, 201 | others: { 202 | files: ['www/app/**/*.html', 'www/app/**/*.js'], 203 | tasks: [] 204 | } 205 | }, 206 | 207 | mochaTest: { 208 | options: { 209 | reporter: 'dot', 210 | timeout: 1000 * 60 * 10 211 | }, 212 | unit: { 213 | src: ['test/**/*.spec.js'], 214 | } 215 | }, 216 | clean: { 217 | all: ['bin-site', 'test.log'], 218 | dist: ['bin-site/jqplot.js', 'bin-site/main.less', 'bin-site/metrics.js'] 219 | } 220 | }); 221 | 222 | require('load-grunt-tasks')(grunt); 223 | require('./tasks/metricsgen')(grunt); 224 | 225 | grunt.registerTask('seedData', function() { 226 | var done = this.async(); 227 | require('./test/seedData')(done, 100); 228 | }); 229 | 230 | grunt.registerTask('deployViews', function() { 231 | var done = this.async(); 232 | require('./lib/couchViews')(require('./test/util.js').config(), function(err, res) { 233 | console.log(err, res); 234 | done(!err); 235 | }); 236 | }); 237 | 238 | grunt.registerTask('dev', ['metricsgen', 'concat:less', 'less:dev', 'autoprefixer', 'processhtml:dev', 'configureProxies:server', 'connect:dev', 'watch']); 239 | grunt.registerTask('dist', ['jshint', 'concat', 'metricsgen', 'uglify', 'less:dist', 'autoprefixer', 'copy', 'processhtml:dist', 'htmlmin', 'clean:dist']); 240 | grunt.registerTask('test', ['clean', 'dist', 'mochaTest']); 241 | 242 | grunt.registerTask('default', ['dev']); 243 | }; 244 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # perfjankie 2 | 3 | PerfJankie is a tool to monitor smoothness and responsiveness of websites and Cordova/Hybrid apps over time. It runs performance tests using [browser-perf](http://github.com/axemclion/browser-perf) and saves the results in a CouchDB server. 4 | It also has a dashboard that displays graphs of the performance metrics collected over time that you help identify performance trends, or locate a single commit that can slow down a site. 5 | 6 | After running the tests, navigate to the following url to see the results dashboard. 7 | 8 | > http://couchdb.serverl.url/databasename/_design/site/index.html 9 | 10 | Here is a [dashboard](http://nparashuram.com/perfslides/perfjankie) created from a [sample project](http://github.com/axemclion/perfslides). 11 | 12 | ![Perfjankie sample dashboard](http://i.imgur.com/3VO8T4C.png "A sample dashboard for perfjankie") 13 | 14 | ## Why ? 15 | Checking for performance regressions is hard. Though most modern browsers have excellent performance measurement tools, it is hard for a developer to check these tools for every commit. Just as unit tests check for regressions in functionality, perfjankie will help with checking regressions in browser rendering performance when integrated into systems like Travis or Jenkins. 16 | 17 | The results dashboard 18 | ## Setup 19 | Perfjankie requires Selenium as the driver to run tests and CouchDB to store the results. Since this is based on browser-perf, look at [setting up browser-perf](https://github.com/axemclion/browser-perf/wiki/Setup-Instructions) for more information. 20 | 21 | ## Usage 22 | 23 | Perfjankie can be used as a node module, from the command line, or as a Grunt task and can be installed from npm using `npm install perfjankie`. 24 | 25 | ### Node Module 26 | 27 | The API call looks like the following 28 | 29 | ```javascript 30 | 31 | var perfjankie = require('perfjankie'); 32 | perfjankie({ 33 | "url": "http://localhost:9000/testpage.html", // URL of the page that you would like to test. 34 | 35 | /* The next set of values identify the test */ 36 | name: "Component or Webpage Name", // A friendly name for the URL. This is shown as component name in the dashboard 37 | suite: "optional suite name", // Displayed as the title in the dashboard. Only 1 suite name for all components 38 | time: new Date().getTime(), // Used to sort the data when displaying graph. Can be the time when a commit was made 39 | run: "commit#Hash", // A hash for the commit, displayed in the x-axis in the dashboard 40 | repeat: 3, // Run the tests 3 times. Default is 1 time 41 | 42 | /* Identifies where the data and the dashboard are saved */ 43 | couch: { 44 | server: 'http://localhost:5984', 45 | requestOptions : { "proxy" : "http://someproxy" }, // optional, e.g. useful for http basic auth, see Please check [request] for more information on the defaults. They support features like cookie jar, proxies, ssl, etc. 46 | database: 'performance', 47 | updateSite: !process.env.CI, // If true, updates the couchApp that shows the dashboard. Set to false in when running Continuous integration, run this the first time using command line. 48 | onlyUpdateSite: false // No data to upload, just update the site. Recommended to do from dev box as couchDB instance may require special access to create views. 49 | }, 50 | 51 | callback: function(err, res) { 52 | // The callback function, err is falsy if all of the following happen 53 | // 1. Browsers perf tests ran 54 | // 2. Data has been saved in couchDB 55 | // err is not falsy even if update site fails. 56 | }, 57 | 58 | /* OPTIONS PASSED TO BROWSER-PERF */ 59 | // Properties identifying the test environment */ 60 | browsers: [{ // This can also be a ["chrome", "firefox"] or "chrome,firefox" 61 | browserName: "chrome", 62 | version: 32, 63 | platform: "Windows 8.1" 64 | }], // See browser perf browser configuration for all options. 65 | 66 | selenium: { 67 | hostname: "ondemand.saucelabs.com", // or localhost or hub.browserstack.com 68 | port: 80, 69 | }, 70 | 71 | BROWSERSTACK_USERNAME: process.env.BROWSERSTACK_USERNAME, // If using browserStack 72 | BROWSERSTACK_KEY: process.env.BROWSERSTACK_KEY, // If using browserStack, this is automatically added to browsers object 73 | 74 | SAUCE_USERNAME: process.env.SAUCE_USERNAME, // If using Saucelabs 75 | SAUCE_ACCESSKEY: process.env.SAUCE_ACCESSKEY, // If using Saucelabs 76 | 77 | /* A way to log the information - can be bunyan, or grunt logs. */ 78 | log: { // Expects the following methods, 79 | fatal: grunt.fail.fatal.bind(grunt.fail), 80 | error: grunt.fail.warn.bind(grunt.fail), 81 | warn: grunt.log.error.bind(grunt.log), 82 | info: grunt.log.ok.bind(grunt.log), 83 | debug: grunt.verbose.writeln.bind(grunt.verbose), 84 | trace: grunt.log.debug.bind(grunt.log) 85 | } 86 | 87 | }); 88 | 89 | ``` 90 | 91 | Other options that can be passed include `preScript`, `actions`, `metrics`, `preScriptFile`, etc. Note that most of these options are similar to the options passed to browser-perf. Refer to the [browser-perf options](https://github.com/axemclion/browser-perf/wiki/Node-Module---API) for a mode detailed explanation. 92 | 93 | ### Grunt Task 94 | To run perfjankie as a Grunt task, simple load task using `grunt.loadNpmTasks('perfjankie');`, define a `perfjankie` task and pass in all the options from above as options to the Grunt task. [Here](https://github.com/axemclion/perfslides/blob/38b4f6e246c5ab971ce2957ec78bb701dbbc3038/Gruntfile.js#L57) is an example. 95 | 96 | ### Command line 97 | Run `perfjankie --help` to see a list of all the options. 98 | Quick Note - to only update site the first time, run the following from the command line. You need to quote the URL to work with parameters, e.g. https://www.google.de/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=angular 99 | 100 | ```bash 101 | $ perfjankie --config-file=local.config.json --only-update-site 'example.com' 102 | ``` 103 | Or without a config file 104 | 105 | ```bash 106 | $ perfjankie --couch-server=http://localhost:5984 --couch-database=perfjankie-test --couch-user=admin_user --couch-pwd=admin_pass --name=Google 'https://www.google.de/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=angular' 107 | ``` 108 | 109 | The config file can contain server configuration and can look like [this](https://github.com/axemclion/perfjankie/blob/master/test/res/local.config.json). 110 | 111 | ## Hosting dashboard on a different server 112 | You can also host the HTML/CSS/JS for displaying the results dashboard on not on CouchDB, but a different static server, possibly behind a CDN. In such cases, 113 | 1. Use the npm module and host the contents of the `site` folder. 114 | 2. Open index.html and insert the following snippet in the `` section 115 | 116 | ```html 117 | 118 | ``` 119 | 120 | 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. 121 | 122 | ## Login before running tests 123 | 124 | 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. 125 | 126 | ## Migrating data from older versions 127 | 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 128 | 129 | ```bash 130 | $ perfjankie --config-file=local.config.json --migrate=newDatabaseName 131 | ``` 132 | 133 | 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` 134 | 135 | ## What does it measure? 136 | 137 | 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 138 | * long, scrollable web pages (like a search result page, an article page, etc). The impact of changes to CSS, sticky headers and scrolling event handlers can be seen in the results. 139 | * components (like bootstrap, jQuery UI components, ReactJS components, AngularJS components, etc). Component developers just have to place the component multiple times on a page and will know if they caused perf regressions as they continue developing the component. 140 | For more information, see the documentation for [browser-perf](http://github.com/axemclion/browser-perf) 141 | 142 | # Development 143 | 144 | ## Dev setup 145 | 146 | Any changes should be verified with unit tests, see `test`-folder. 147 | To run the tests you local couchdb installed with a database, see `test/res/local.config.json` for details: 148 | 149 | 1. start couchdb 150 | 2. start a local selenium grd: `java -jar node_modules/selenium-server/lib/runner/selenium-server-standalone-2.53.0.jar -Dwebdriver.chrome.driver=$(pwd)/chromedriver/lib/chromedriver/chromedriver` 151 | 3. run tests via `npm test` -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "perfjankie", 3 | "main": "index.js", 4 | "version": "0.0.0", 5 | "homepage": "https://github.com/axemclion/perfjankie", 6 | "authors": [ 7 | "Parashuram " 8 | ], 9 | "description": "Website for Perfjankie", 10 | "license": "MIT", 11 | "private": true, 12 | "ignore": [ 13 | "**/.*", 14 | "node_modules", 15 | "bower_components", 16 | "test", 17 | "tests" 18 | ], 19 | "dependencies": { 20 | "angular": "~1.2.18", 21 | "bootstrap": "~3.1.1", 22 | "jqplot-bower": "~1.0.8", 23 | "jquery": "~2.1.1", 24 | "angular-route": "~1.2.25" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var program = require('commander'), 4 | fs = require('fs'); 5 | 6 | program 7 | .version('0.0.1') 8 | .option('-c --config-file ', 'Specify a configuration file. If other options are specified, they have precedence over options in config file') 9 | .option('-s, --selenium ', 'Specify Selenium Server, like localhost:4444 or ondemand.saucelabs.com:80', 'localhost:4444') 10 | .option('-u --username ', 'Sauce, BrowserStack or Selenium User Name') 11 | .option('-a --accesskey ', 'Sauce, BrowserStack or Selenium Access Key') 12 | .option('--browsers ', 'List of browsers to run the tests on') 13 | .option('--couch-server ', 'Location of the couchDB server') 14 | .option('--couch-database ', 'Name of the couch database') 15 | .option('--couch-user ', 'Username of the couch user that can create design documents and save data') 16 | .option('--couch-pwd ', 'Password of the couchDB user') 17 | .option('--name ', 'A friendly name for the URL. This is shown as component name in the dashboard') 18 | .option('--run ', 'A hash for the commit, or any identifier displayed in the x-axis in the dashboard') 19 | .option('--time