1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var now = function () {
|
4 | return typeof performance !== 'undefined' && !!performance.now ? performance.now() : Date.now();
|
5 | };
|
6 | var RESET_INTERVAL = 3 * 60 * 1000;
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | var FabricPerformance = (function () {
|
14 | function FabricPerformance() {
|
15 | }
|
16 | |
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | FabricPerformance.measure = function (name, func) {
|
23 | if (FabricPerformance._timeoutId) {
|
24 | FabricPerformance.setPeriodicReset();
|
25 | }
|
26 | var start = now();
|
27 | func();
|
28 | var end = now();
|
29 | var measurement = FabricPerformance.summary[name] || {
|
30 | totalDuration: 0,
|
31 | count: 0,
|
32 | all: [],
|
33 | };
|
34 | var duration = end - start;
|
35 | measurement.totalDuration += duration;
|
36 | measurement.count++;
|
37 | measurement.all.push({
|
38 | duration: duration,
|
39 | timeStamp: end,
|
40 | });
|
41 | FabricPerformance.summary[name] = measurement;
|
42 | };
|
43 | FabricPerformance.reset = function () {
|
44 | FabricPerformance.summary = {};
|
45 | clearTimeout(FabricPerformance._timeoutId);
|
46 | FabricPerformance._timeoutId = NaN;
|
47 | };
|
48 | FabricPerformance.setPeriodicReset = function () {
|
49 | FabricPerformance._timeoutId = setTimeout(function () { return FabricPerformance.reset(); }, RESET_INTERVAL);
|
50 | };
|
51 | FabricPerformance.summary = {};
|
52 | return FabricPerformance;
|
53 | }());
|
54 | exports.FabricPerformance = FabricPerformance;
|
55 |
|
\ | No newline at end of file |