@oino-ts/types 0.8.2 → 0.9.0

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.
@@ -2,11 +2,23 @@
2
2
  * Static class for benchmarking functions.
3
3
  *
4
4
  */
5
- export declare class OINOBenchmark {
6
- private static _benchmarkCount;
7
- private static _benchmarkData;
8
- private static _benchmarkEnabled;
9
- private static _benchmarkStart;
5
+ export declare abstract class OINOBenchmark {
6
+ protected static _instance: OINOBenchmark;
7
+ protected static _enabled: Record<string, boolean>;
8
+ /**
9
+ * Create a new OINOBenchmark instance.
10
+ *
11
+ * @param enabledModules array of those benchmarks that are enabled
12
+ */
13
+ constructor(enabledModules?: string[]);
14
+ /**
15
+ * Set active benchmarking instance.
16
+ *
17
+ * @param instance OINOBenchmark instance
18
+ *
19
+ */
20
+ static setInstance(instance: OINOBenchmark): void;
21
+ protected abstract _reset(): void;
10
22
  /**
11
23
  * Reset benchmark data (but not what is enabled).
12
24
  *
@@ -15,9 +27,10 @@ export declare class OINOBenchmark {
15
27
  /**
16
28
  * Set benchmark names that are enabled.
17
29
  *
18
- * @param module array of those benchmarks that are enabled
30
+ * @param modules array of those benchmarks that are enabled
19
31
  */
20
- static setEnabled(module: string[]): void;
32
+ static setEnabled(modules: string[]): void;
33
+ protected abstract _start(module: string, method: string): void;
21
34
  /**
22
35
  * Start benchmark timing.
23
36
  *
@@ -25,6 +38,7 @@ export declare class OINOBenchmark {
25
38
  * @param method of the benchmark
26
39
  */
27
40
  static start(module: string, method: string): void;
41
+ protected abstract _end(module: string, method: string, category?: string): number;
28
42
  /**
29
43
  * Complete benchmark timing
30
44
  *
@@ -33,6 +47,7 @@ export declare class OINOBenchmark {
33
47
  * @param category optional subcategory of the benchmark
34
48
  */
35
49
  static end(module: string, method: string, category?: string): number;
50
+ protected abstract _get(module: string, method: string): number;
36
51
  /**
37
52
  * Get given benchmark data.
38
53
  *
@@ -41,9 +56,53 @@ export declare class OINOBenchmark {
41
56
  *
42
57
  */
43
58
  static get(module: string, method: string): number;
59
+ protected abstract _getAll(): Record<string, number>;
60
+ /**
61
+ * Get all benchmark data.
62
+ *
63
+ */
64
+ static getAll(): Record<string, number>;
65
+ }
66
+ /**
67
+ * OINOMemoryBenchmark is a memory-based benchmark implementation.
68
+ * It stores the benchmark data in memory and allows to reset, start, end and get benchmark data.
69
+ *
70
+ */
71
+ export declare class OINOMemoryBenchmark extends OINOBenchmark {
72
+ private _benchmarkCount;
73
+ private _benchmarkData;
74
+ private _benchmarkStart;
75
+ /**
76
+ * Reset benchmark data (but not what is enabled).
77
+ *
78
+ */
79
+ protected _reset(): void;
80
+ /**
81
+ * Start benchmark timing.
82
+ *
83
+ * @param module of the benchmark
84
+ * @param method of the benchmark
85
+ */
86
+ protected _start(module: string, method: string): void;
87
+ /**
88
+ * Complete benchmark timing
89
+ *
90
+ * @param module of the benchmark
91
+ * @param method of the benchmark
92
+ * @param category optional subcategory of the benchmark
93
+ */
94
+ protected _end(module: string, method: string, category?: string): number;
95
+ /**
96
+ * Get given benchmark data.
97
+ *
98
+ * @param module of the benchmark
99
+ * @param method of the benchmark
100
+ *
101
+ */
102
+ protected _get(module: string, method: string): number;
44
103
  /**
45
104
  * Get all benchmark data.
46
105
  *
47
106
  */
48
- static getAll(): number;
107
+ protected _getAll(): Record<string, number>;
49
108
  }
@@ -51,12 +51,12 @@ export declare abstract class OINOLog {
51
51
  */
52
52
  protected static _log(level: OINOLogLevel, levelStr: string, domain: string, channel: string, method: string, message: string, data?: any): void;
53
53
  /**
54
- * Set active logger and log level.
54
+ * Set active logger instance.
55
55
  *
56
- * @param logger logger instance
56
+ * @param instance OINOLog instance
57
57
  *
58
58
  */
59
- static setLogger(logger: OINOLog): void;
59
+ static setInstance(instance: OINOLog): void;
60
60
  /**
61
61
  * Set log level for given combination of domain/channel/method. Not defining dimension(s) means they match any value.
62
62
  * Multiple settings can be combined to set different logging accuracy specifically
@@ -1,4 +1,4 @@
1
- export { OINOBenchmark } from "./OINOBenchmark.js";
1
+ export { OINOBenchmark, OINOMemoryBenchmark } from "./OINOBenchmark.js";
2
2
  export { OINOLog, OINOLogLevel, OINOConsoleLog } from "./OINOLog.js";
3
3
  export { OINOResult, OINOHttpResult } from "./OINOResult.js";
4
4
  export { OINOStr } from "./OINOStr.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oino-ts/types",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "description": "OINO TS package for types.",
5
5
  "author": "Matias Kiviniemi (pragmatta)",
6
6
  "license": "MPL-2.0",