@oino-ts/common 0.21.0 → 0.21.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.
|
@@ -178,7 +178,7 @@ class OINOMemoryBenchmark extends OINOBenchmark {
|
|
|
178
178
|
_benchmarkCount = {};
|
|
179
179
|
_benchmarkData = {};
|
|
180
180
|
_benchmarkStart = {};
|
|
181
|
-
|
|
181
|
+
_healthRequests = 0;
|
|
182
182
|
_healthFailures = 0;
|
|
183
183
|
_exceptions = [];
|
|
184
184
|
/**
|
|
@@ -188,7 +188,7 @@ class OINOMemoryBenchmark extends OINOBenchmark {
|
|
|
188
188
|
_reset() {
|
|
189
189
|
this._benchmarkData = {};
|
|
190
190
|
this._benchmarkCount = {};
|
|
191
|
-
this.
|
|
191
|
+
this._healthRequests = 0;
|
|
192
192
|
this._healthFailures = 0;
|
|
193
193
|
}
|
|
194
194
|
/**
|
|
@@ -259,7 +259,7 @@ class OINOMemoryBenchmark extends OINOBenchmark {
|
|
|
259
259
|
}
|
|
260
260
|
if (OINOBenchmark._healthBenchmarks.includes(name)) {
|
|
261
261
|
// console.log(`Health benchmark ${name}: value=${value.toFixed(2)}ms, average=${(this._benchmarkData[name] / this._benchmarkCount[name]).toFixed(2)}ms, late=${late_ratio>=OINOBenchmark._healthLateRatio}, success=${success}`)
|
|
262
|
-
this.
|
|
262
|
+
this._healthRequests += 1;
|
|
263
263
|
if (!success) {
|
|
264
264
|
this._healthFailures += 1;
|
|
265
265
|
}
|
|
@@ -279,11 +279,11 @@ class OINOMemoryBenchmark extends OINOBenchmark {
|
|
|
279
279
|
return this._exceptions;
|
|
280
280
|
}
|
|
281
281
|
_getHealth() {
|
|
282
|
-
if ((OINOBenchmark._healthBenchmarks.length == 0) || (this.
|
|
282
|
+
if ((OINOBenchmark._healthBenchmarks.length == 0) || (this._healthRequests == 0)) {
|
|
283
283
|
return 1.0;
|
|
284
284
|
}
|
|
285
285
|
else {
|
|
286
|
-
return (this.
|
|
286
|
+
return (this._healthRequests - this._healthFailures) / this._healthRequests;
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
289
|
}
|
|
@@ -174,7 +174,7 @@ export class OINOMemoryBenchmark extends OINOBenchmark {
|
|
|
174
174
|
_benchmarkCount = {};
|
|
175
175
|
_benchmarkData = {};
|
|
176
176
|
_benchmarkStart = {};
|
|
177
|
-
|
|
177
|
+
_healthRequests = 0;
|
|
178
178
|
_healthFailures = 0;
|
|
179
179
|
_exceptions = [];
|
|
180
180
|
/**
|
|
@@ -184,7 +184,7 @@ export class OINOMemoryBenchmark extends OINOBenchmark {
|
|
|
184
184
|
_reset() {
|
|
185
185
|
this._benchmarkData = {};
|
|
186
186
|
this._benchmarkCount = {};
|
|
187
|
-
this.
|
|
187
|
+
this._healthRequests = 0;
|
|
188
188
|
this._healthFailures = 0;
|
|
189
189
|
}
|
|
190
190
|
/**
|
|
@@ -255,7 +255,7 @@ export class OINOMemoryBenchmark extends OINOBenchmark {
|
|
|
255
255
|
}
|
|
256
256
|
if (OINOBenchmark._healthBenchmarks.includes(name)) {
|
|
257
257
|
// console.log(`Health benchmark ${name}: value=${value.toFixed(2)}ms, average=${(this._benchmarkData[name] / this._benchmarkCount[name]).toFixed(2)}ms, late=${late_ratio>=OINOBenchmark._healthLateRatio}, success=${success}`)
|
|
258
|
-
this.
|
|
258
|
+
this._healthRequests += 1;
|
|
259
259
|
if (!success) {
|
|
260
260
|
this._healthFailures += 1;
|
|
261
261
|
}
|
|
@@ -275,11 +275,11 @@ export class OINOMemoryBenchmark extends OINOBenchmark {
|
|
|
275
275
|
return this._exceptions;
|
|
276
276
|
}
|
|
277
277
|
_getHealth() {
|
|
278
|
-
if ((OINOBenchmark._healthBenchmarks.length == 0) || (this.
|
|
278
|
+
if ((OINOBenchmark._healthBenchmarks.length == 0) || (this._healthRequests == 0)) {
|
|
279
279
|
return 1.0;
|
|
280
280
|
}
|
|
281
281
|
else {
|
|
282
|
-
return (this.
|
|
282
|
+
return (this._healthRequests - this._healthFailures) / this._healthRequests;
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
}
|
|
@@ -130,7 +130,7 @@ export declare class OINOMemoryBenchmark extends OINOBenchmark {
|
|
|
130
130
|
protected _benchmarkCount: Record<string, number>;
|
|
131
131
|
protected _benchmarkData: Record<string, number>;
|
|
132
132
|
protected _benchmarkStart: Record<string, number>;
|
|
133
|
-
protected
|
|
133
|
+
protected _healthRequests: number;
|
|
134
134
|
protected _healthFailures: number;
|
|
135
135
|
protected _exceptions: any[];
|
|
136
136
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oino-ts/common",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"description": "OINO TS package for common classes.",
|
|
5
5
|
"author": "Matias Kiviniemi (pragmatta)",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@oino-ts/types": "0.21.
|
|
22
|
+
"@oino-ts/types": "0.21.1",
|
|
23
23
|
"@types/node": "^22.0.0",
|
|
24
24
|
"typescript": "~5.9.0"
|
|
25
25
|
},
|
package/src/OINOBenchmark.ts
CHANGED
|
@@ -204,7 +204,7 @@ export class OINOMemoryBenchmark extends OINOBenchmark {
|
|
|
204
204
|
protected _benchmarkCount:Record<string, number> = {}
|
|
205
205
|
protected _benchmarkData:Record<string, number> = {}
|
|
206
206
|
protected _benchmarkStart:Record<string, number> = {}
|
|
207
|
-
protected
|
|
207
|
+
protected _healthRequests: number = 0
|
|
208
208
|
protected _healthFailures: number = 0
|
|
209
209
|
|
|
210
210
|
protected _exceptions:any[] = []
|
|
@@ -216,7 +216,7 @@ export class OINOMemoryBenchmark extends OINOBenchmark {
|
|
|
216
216
|
protected _reset():void {
|
|
217
217
|
this._benchmarkData = {}
|
|
218
218
|
this._benchmarkCount = {}
|
|
219
|
-
this.
|
|
219
|
+
this._healthRequests = 0
|
|
220
220
|
this._healthFailures = 0
|
|
221
221
|
}
|
|
222
222
|
|
|
@@ -291,7 +291,7 @@ export class OINOMemoryBenchmark extends OINOBenchmark {
|
|
|
291
291
|
}
|
|
292
292
|
if (OINOBenchmark._healthBenchmarks.includes(name)) {
|
|
293
293
|
// console.log(`Health benchmark ${name}: value=${value.toFixed(2)}ms, average=${(this._benchmarkData[name] / this._benchmarkCount[name]).toFixed(2)}ms, late=${late_ratio>=OINOBenchmark._healthLateRatio}, success=${success}`)
|
|
294
|
-
this.
|
|
294
|
+
this._healthRequests += 1
|
|
295
295
|
if (!success) {
|
|
296
296
|
this._healthFailures += 1
|
|
297
297
|
|
|
@@ -314,11 +314,11 @@ export class OINOMemoryBenchmark extends OINOBenchmark {
|
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
protected _getHealth(): number {
|
|
317
|
-
if ((OINOBenchmark._healthBenchmarks.length == 0) || (this.
|
|
317
|
+
if ((OINOBenchmark._healthBenchmarks.length == 0) || (this._healthRequests == 0)) {
|
|
318
318
|
return 1.0
|
|
319
319
|
|
|
320
320
|
} else {
|
|
321
|
-
return (this.
|
|
321
|
+
return (this._healthRequests - this._healthFailures) / this._healthRequests
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
}
|