1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
18 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
19 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
20 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
21 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
22 | };
|
23 | var __metadata = (this && this.__metadata) || function (k, v) {
|
24 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
25 | };
|
26 | Object.defineProperty(exports, "__esModule", { value: true });
|
27 | exports.NullBackendStopwatch = exports.DefaultBackendStopwatch = exports.BackendStopwatchOptions = exports.stopwatchPath = exports.BackendStopwatch = void 0;
|
28 |
|
29 | const inversify_1 = require("inversify");
|
30 | const stopwatch_1 = require("./stopwatch");
|
31 | exports.BackendStopwatch = Symbol('BackendStopwatch');
|
32 |
|
33 | exports.stopwatchPath = '/services/stopwatch';
|
34 | exports.BackendStopwatchOptions = Symbol('BackendStopwatchOptions');
|
35 |
|
36 |
|
37 |
|
38 | let DefaultBackendStopwatch = class DefaultBackendStopwatch {
|
39 | constructor() {
|
40 | this.measurements = new Map();
|
41 | this.idSequence = 0;
|
42 | }
|
43 | start(name, options) {
|
44 | const result = ++this.idSequence;
|
45 | this.measurements.set(result, this.stopwatch.start(name, options));
|
46 | return result;
|
47 | }
|
48 | stop(measurementToken, message, messageArgs) {
|
49 | const measurement = this.measurements.get(measurementToken);
|
50 | if (measurement) {
|
51 | this.measurements.delete(measurementToken);
|
52 | measurement.log(message, ...messageArgs);
|
53 | }
|
54 | }
|
55 | };
|
56 | __decorate([
|
57 | (0, inversify_1.inject)(stopwatch_1.Stopwatch),
|
58 | __metadata("design:type", stopwatch_1.Stopwatch)
|
59 | ], DefaultBackendStopwatch.prototype, "stopwatch", void 0);
|
60 | DefaultBackendStopwatch = __decorate([
|
61 | (0, inversify_1.injectable)()
|
62 | ], DefaultBackendStopwatch);
|
63 | exports.DefaultBackendStopwatch = DefaultBackendStopwatch;
|
64 |
|
65 |
|
66 |
|
67 | let NullBackendStopwatch = class NullBackendStopwatch {
|
68 | start() {
|
69 | return Promise.resolve(0);
|
70 | }
|
71 | stop() {
|
72 | return Promise.resolve();
|
73 | }
|
74 | };
|
75 | NullBackendStopwatch = __decorate([
|
76 | (0, inversify_1.injectable)()
|
77 | ], NullBackendStopwatch);
|
78 | exports.NullBackendStopwatch = NullBackendStopwatch;
|
79 |
|
\ | No newline at end of file |