This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtree_benchmark.spec.js
42 lines (41 loc) · 1.67 KB
/
tree_benchmark.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var benchpress = require('@angular/benchpress');
var runner = new benchpress.Runner([
//use protractor as Webdriver client
benchpress.SeleniumWebDriverAdapter.PROTRACTOR_PROVIDERS,
//use RegressionSlopeValidator to validate samples
{provide: benchpress.Validator, useExisting: benchpress.RegressionSlopeValidator},
//use 10 samples to calculate slope regression
{provide: benchpress.RegressionSlopeValidator.SAMPLE_SIZE, useValue: 20},
//use the script metric to calculate slope regression
{provide: benchpress.RegressionSlopeValidator.METRIC, useValue: 'scriptTime'},
{provide: benchpress.Options.FORCE_GC, useValue: true}
]);
describe('deep tree baseline', function() {
it('should be fast!', function(done) {
var depth = 11;
//Tells protractor this isn't an Angular 1 application
browser.ignoreSynchronization = true;
//Load the benchmark, with a tree depth of 9
browser.get('http://localhost:8080/tree.html?depth='+depth);
/*
* Tell benchpress to click the buttons to destroy and re-create the tree for each sample.
* Benchpress will log the collected metrics after each sample is collected, and will stop
* sampling as soon as the calculated regression slope for last 20 samples is stable.
*/
runner.sample({
id: 'deep-tree',
execute: function() {
/*
* Will call querySelector in the browser, but benchpress is smart enough to ignore injected
* script.
*/
$('#destroyDom').click();
$('#createDom').click();
},
providers: [{
provide: benchpress.Options.SAMPLE_DESCRIPTION,
useValue: { depth: depth }
}]
}).then(done, done.fail);
});
});