overtake 2.1.0 → 2.1.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.
package/build/index.d.ts CHANGED
@@ -71,7 +71,7 @@ export declare const printHistogramReports: <R extends ReportTypeList>(reports:
71
71
  export interface BaselineData {
72
72
  version: number;
73
73
  timestamp: string;
74
- results: Record<string, Record<string, number>>;
74
+ results: Record<string, Record<string, number | boolean>>;
75
75
  }
76
76
  export declare const reportsToBaseline: <R extends ReportTypeList>(reports: TargetReport<R>[]) => BaselineData;
77
77
  export declare const printComparisonReports: <R extends ReportTypeList>(reports: TargetReport<R>[], baseline: BaselineData, threshold?: number) => void;
package/build/index.js CHANGED
@@ -351,6 +351,19 @@ export const printComparisonReports = (reports, baseline, threshold = 5) => {
351
351
  continue;
352
352
  const current = value.valueOf();
353
353
  const baselineValue = baselineData?.[metric];
354
+ if (typeof current === 'boolean') {
355
+ if (baselineValue === undefined) {
356
+ console.log(` * ${metric}: ${current} (new)`);
357
+ }
358
+ else if (current === Boolean(baselineValue)) {
359
+ console.log(` ${metric}: ${current}`);
360
+ }
361
+ else {
362
+ const indicator = current ? '\x1b[31m!\x1b[0m' : '\x1b[32m+\x1b[0m';
363
+ console.log(` ${indicator} ${metric}: ${current} (was ${baselineValue})`);
364
+ }
365
+ continue;
366
+ }
354
367
  if (baselineValue !== undefined && baselineValue !== 0) {
355
368
  const change = ((current - baselineValue) / baselineValue) * 100;
356
369
  const isOps = metric === 'ops';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "overtake",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "NodeJS performance benchmark",
5
5
  "type": "module",
6
6
  "types": "build/index.d.ts",
package/src/index.ts CHANGED
@@ -394,11 +394,11 @@ export const printHistogramReports = <R extends ReportTypeList>(reports: TargetR
394
394
  export interface BaselineData {
395
395
  version: number;
396
396
  timestamp: string;
397
- results: Record<string, Record<string, number>>;
397
+ results: Record<string, Record<string, number | boolean>>;
398
398
  }
399
399
 
400
400
  export const reportsToBaseline = <R extends ReportTypeList>(reports: TargetReport<R>[]): BaselineData => {
401
- const results: Record<string, Record<string, number>> = {};
401
+ const results: Record<string, Record<string, number | boolean>> = {};
402
402
  for (const report of reports) {
403
403
  for (const { measure, feeds } of report.measures) {
404
404
  for (const { feed, data } of feeds) {
@@ -441,8 +441,20 @@ export const printComparisonReports = <R extends ReportTypeList>(reports: Target
441
441
  const current = (value as { valueOf(): number }).valueOf();
442
442
  const baselineValue = baselineData?.[metric];
443
443
 
444
+ if (typeof current === 'boolean') {
445
+ if (baselineValue === undefined) {
446
+ console.log(` * ${metric}: ${current} (new)`);
447
+ } else if (current === Boolean(baselineValue)) {
448
+ console.log(` ${metric}: ${current}`);
449
+ } else {
450
+ const indicator = current ? '\x1b[31m!\x1b[0m' : '\x1b[32m+\x1b[0m';
451
+ console.log(` ${indicator} ${metric}: ${current} (was ${baselineValue})`);
452
+ }
453
+ continue;
454
+ }
455
+
444
456
  if (baselineValue !== undefined && baselineValue !== 0) {
445
- const change = ((current - baselineValue) / baselineValue) * 100;
457
+ const change = ((current - (baselineValue as number)) / (baselineValue as number)) * 100;
446
458
  const isOps = metric === 'ops';
447
459
  const improved = isOps ? change > threshold : change < -threshold;
448
460
  const regressed = isOps ? change < -threshold : change > threshold;