@percy/webdriver-utils 1.27.0 → 1.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,10 +3,8 @@ import GenericProvider from './genericProvider.js';
|
|
|
3
3
|
import Cache from '../util/cache.js';
|
|
4
4
|
import Tile from '../util/tile.js';
|
|
5
5
|
import NormalizeData from '../metadata/normalizeData.js';
|
|
6
|
+
import TimeIt from '../util/timing.js';
|
|
6
7
|
const log = utils.logger('webdriver-utils:automateProvider');
|
|
7
|
-
const {
|
|
8
|
-
TimeIt
|
|
9
|
-
} = utils;
|
|
10
8
|
export default class AutomateProvider extends GenericProvider {
|
|
11
9
|
constructor(sessionId, commandExecutorUrl, capabilities, sessionCapabilites, clientInfo, environmentInfo, options, buildInfo) {
|
|
12
10
|
super(sessionId, commandExecutorUrl, capabilities, sessionCapabilites, clientInfo, environmentInfo, options, buildInfo);
|
package/dist/util/cache.js
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Undefined } from './validations.js';
|
|
2
|
+
export default class TimeIt {
|
|
3
|
+
static data = {};
|
|
4
|
+
static enabled = process.env.PERCY_METRICS === 'true';
|
|
5
|
+
static async run(store, func) {
|
|
6
|
+
if (!this.enabled) return await func();
|
|
7
|
+
const t1 = Date.now();
|
|
8
|
+
try {
|
|
9
|
+
return await func();
|
|
10
|
+
} finally {
|
|
11
|
+
if (Undefined(this.data[store])) this.data[store] = [];
|
|
12
|
+
this.data[store].push(Date.now() - t1);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
static min(store) {
|
|
16
|
+
return Math.min(...this.data[store]);
|
|
17
|
+
}
|
|
18
|
+
static max(store) {
|
|
19
|
+
return Math.max(...this.data[store]);
|
|
20
|
+
}
|
|
21
|
+
static avg(store) {
|
|
22
|
+
const vals = this.data[store];
|
|
23
|
+
return vals.reduce((a, b) => a + b, 0) / vals.length;
|
|
24
|
+
}
|
|
25
|
+
static summary({
|
|
26
|
+
includeVals
|
|
27
|
+
} = {}) {
|
|
28
|
+
const agg = {};
|
|
29
|
+
for (const key of Object.keys(this.data)) {
|
|
30
|
+
agg[key] = {
|
|
31
|
+
min: this.min(key),
|
|
32
|
+
max: this.max(key),
|
|
33
|
+
avg: this.avg(key),
|
|
34
|
+
count: this.data[key].length
|
|
35
|
+
};
|
|
36
|
+
if (includeVals) agg[key].vals = this.data[key];
|
|
37
|
+
}
|
|
38
|
+
return agg;
|
|
39
|
+
}
|
|
40
|
+
static reset() {
|
|
41
|
+
this.data = {};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/webdriver-utils",
|
|
3
|
-
"version": "1.27.
|
|
3
|
+
"version": "1.27.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"test:coverage": "yarn test --coverage"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@percy/config": "1.27.
|
|
33
|
-
"@percy/sdk-utils": "1.27.
|
|
32
|
+
"@percy/config": "1.27.1",
|
|
33
|
+
"@percy/sdk-utils": "1.27.1"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "a6f6441483b9c092ee1de1832f53c9a774968202"
|
|
36
36
|
}
|