{"id":17937861,"url":"https://github.com/axemclion/protractor-perf","last_synced_at":"2025-05-07T19:06:18.728Z","repository":{"id":23342444,"uuid":"26703027","full_name":"axemclion/protractor-perf","owner":"axemclion","description":"E2E test framework to check for performance regressions in Angular apps","archived":false,"fork":false,"pushed_at":"2016-12-17T17:28:56.000Z","size":26,"stargazers_count":91,"open_issues_count":13,"forks_count":23,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-15T01:05:35.278Z","etag":null,"topics":["angular","perf","perfmatters","performance-regressions","protractor","web-performance"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/axemclion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-16T03:56:56.000Z","updated_at":"2025-01-17T19:29:11.000Z","dependencies_parsed_at":"2022-08-21T16:20:40.568Z","dependency_job_id":null,"html_url":"https://github.com/axemclion/protractor-perf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axemclion%2Fprotractor-perf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axemclion%2Fprotractor-perf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axemclion%2Fprotractor-perf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axemclion%2Fprotractor-perf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/axemclion","download_url":"https://codeload.github.com/axemclion/protractor-perf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252940883,"owners_count":21828766,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","perf","perfmatters","performance-regressions","protractor","web-performance"],"created_at":"2024-10-28T23:08:05.499Z","updated_at":"2025-05-07T19:06:18.660Z","avatar_url":"https://github.com/axemclion.png","language":"JavaScript","readme":"# Protractor-Perf\n\nJust like [Protractor](https://github.com/angular/protractor) is the end to end test case runner for [AngularJS](https://github.com/angular/angular.js/) to check for functional regressions, [this project](htto://npmjs.org/package/protractor-perf) is a way check for performance regressions while reusing the same test cases. \n\n## Usage\n\nInstall protractor-perf using `npm install -g protractor-perf`. \n\nProtractor test cases are re-used to run scenarios where performance needs to be measured. Protractor-perf can be used just like protractor, just that the test-cases need to be instrumented to indicated when to start and stop measuring performance. \n\nProtractor is usually invoked using `$ protractor conf.js`. Use `$ protractor-perf conf.js` instead to start measuring performance. \n\nThe config file is the same configuration file used for protractor tests. \n\n_Note_: If you run selenium using protractor's `webdriver-manager`, you would need to specify `seleniumPort` and `selenium` keys in the config file, to explicitly specify the port on which the selenium server will run. This port will also be picked up by `protractor-perf`. See `./test/conf.js` as an example.  \n\n\u003e When the instrumented test cases are run using protractor, the code related to performance is a no-op. This way, adding instrumentation does not break your ability to run protractor to just test for functionality.  \n\n## Instrumenting the test cases\n\nThe test case need to specify when to start and stop measuring performance metrics for a certain scenario. The following code is an example of a test case, with perf code snippets added. \n\n```javascript\nvar PerfRunner = require('..');\ndescribe('angularjs homepage todo list', function() {\n\tvar perfRunner = new PerfRunner(protractor, browser);\n\n\tit('should add a todo', function() {\n\t\tbrowser.get('http://www.angularjs.org');\n\t\tperfRunner.start();\n\n\t\telement(by.model('todoList.todoText')).sendKeys('write a protractor test');\n\t\telement(by.css('[value=\"add\"]')).click();\n\n\t\tperfRunner.stop();\n\n\t\tif (perfRunner.isEnabled) {\n\t\t\texpect(perfRunner.getStats('meanFrameTime')).toBeLessThan(60);\n\t\t};\n\n\t\tvar todoList = element.all(by.repeater('todo in todoList.todos'));\n\t\texpect(todoList.count()).toEqual(3);\n\t\texpect(todoList.get(2).getText()).toEqual('write a protractor test');\n\n\t});\n});\n```\n\nThe four statements to note are \n\n1. Initialize the Perf monitor using `new ProtractorPerf(protractor, browser)`\n2. To start measuring the perf, use `perf.start()`\n3. Once the scenario that you would like to perf test completes, use `perf.stop()`\n4. Finally, use `perf.getStats('statName')` in `expect` statements to ensure that all the performance metrics are within the acceptable range.\n\nThe `perf.isEnabled` is needed to ensure that perf metrics are not tested when the test case is run using `protractor` directly. \n\n\n### Metrics measured   \n\n`protractor-perf` is based on [browser-perf](http://github.com/axemclion/browser-perf). `browser-perf` measures the metrics that can be tested for regressions. Look at [browser-perf's wiki page](https://github.com/axemclion/browser-perf/wiki) for more information about the project. \n\n### Grunt Integration\nInvoke `protractor-perf` from a GruntFile as below\n```javascript\nmodule.exports = function(grunt) {\n  var protractorperf = require('protractor-perf');\n  grunt.registerTask('protractorperf', function() {\n    var donerun = this.async();\n    // Optional config Object that overwrites properties of conf.js.\n    // Useful to set property values from grunt.option()\n    var argv = {\n      selenium: 'http://localhost:54321/wd/hub',\n      seleniumPort: 54321\n    };\n    protractorperf.run('./merci-perf-conf.js', donerun, argv); // config file\n  });\n  grunt.registerTask('run', ['protractorperf']);\n};\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxemclion%2Fprotractor-perf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxemclion%2Fprotractor-perf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxemclion%2Fprotractor-perf/lists"}