@naturalcycles/bench-lib 1.6.3 → 1.6.4

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,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runBench = exports.runBenchScript = void 0;
4
4
  const js_lib_1 = require("@naturalcycles/js-lib");
5
+ const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
5
6
  const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
6
7
  const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
7
8
  const Benchmark = require("benchmark");
8
- const fs = require("fs-extra");
9
9
  const vega = require("vega");
10
10
  const vegaLite = require("vega-lite");
11
11
  const asciiChart_util_1 = require("./asciiChart.util");
@@ -46,18 +46,18 @@ async function runBench(opt) {
46
46
  // names.forEach(name => {
47
47
  // summary[name] = results.hz.map(map => map[name]!)
48
48
  // })
49
- fs.ensureDirSync(reportDirPath);
49
+ (0, nodejs_lib_1._ensureDirSync)(reportDirPath);
50
50
  const summaryJsonPath = `${reportDirPath}/${name}.json`;
51
- fs.writeJsonSync(summaryJsonPath, avg, { spaces: 2 });
51
+ (0, nodejs_lib_1._writeJsonSync)(summaryJsonPath, avg, { spaces: 2 });
52
52
  console.log(`saved ${(0, colors_1.dimGrey)(summaryJsonPath)}`);
53
53
  }
54
54
  if (writePlot) {
55
- fs.ensureDirSync(reportDirPath);
55
+ (0, nodejs_lib_1._ensureDirSync)(reportDirPath);
56
56
  const spec = benchResultsToVegaSpec(avg);
57
57
  const view = new vega.View(vega.parse(spec), { renderer: 'none' });
58
58
  const svg = await view.toSVG();
59
59
  const plotPath = `${reportDirPath}/${name}.svg`;
60
- fs.writeFileSync(plotPath, svg);
60
+ (0, nodejs_lib_1._writeFileSync)(plotPath, svg);
61
61
  console.log(`saved ${(0, colors_1.dimGrey)(plotPath)}`);
62
62
  }
63
63
  if (asciiPlot) {
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runCannon = exports.runCannonScript = void 0;
4
+ const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
4
5
  const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
5
6
  const js_lib_1 = require("@naturalcycles/js-lib");
6
7
  const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
7
- const fs = require("fs-extra");
8
8
  const vega = require("vega");
9
9
  const vegaLite = require("vega-lite");
10
10
  /**
@@ -53,7 +53,7 @@ async function runCannon(profiles, optInput = {}) {
53
53
  });
54
54
  }
55
55
  const { reportDirPath } = opt;
56
- fs.ensureDirSync(reportDirPath);
56
+ (0, nodejs_lib_1._ensureDirSync)(reportDirPath);
57
57
  const resultByProfile = {};
58
58
  const summaries = [];
59
59
  for await (const profileName of Object.keys(profiles)) {
@@ -67,11 +67,11 @@ async function runCannon(profiles, optInput = {}) {
67
67
  console.table(summaries);
68
68
  if (opt.writeSummary) {
69
69
  const summaryJsonPath = `${reportDirPath}/${opt.name}.summary.json`;
70
- fs.writeJsonSync(summaryJsonPath, summaries, { spaces: 2 });
70
+ (0, nodejs_lib_1._writeJsonSync)(summaryJsonPath, summaries, { spaces: 2 });
71
71
  console.log(`saved ${(0, colors_1.dimGrey)(summaryJsonPath)}`);
72
72
  }
73
73
  if (opt.writeRawSummary) {
74
- fs.writeJsonSync(`${reportDirPath}/${opt.name}.rawSummary.json`, resultByProfile, { spaces: 2 });
74
+ (0, nodejs_lib_1._writeJsonSync)(`${reportDirPath}/${opt.name}.rawSummary.json`, resultByProfile, { spaces: 2 });
75
75
  }
76
76
  if (opt.writePlots) {
77
77
  await writePlotFiles(opt, summaries);
@@ -135,7 +135,7 @@ function toSummary(name, result) {
135
135
  }
136
136
  async function writePlotFiles(opt, summaries) {
137
137
  const { reportDirPath, name } = opt;
138
- fs.ensureDirSync(reportDirPath);
138
+ (0, nodejs_lib_1._ensureDirSync)(reportDirPath);
139
139
  let fields = ['rpsAvg', 'latencyAvg', 'latency50', 'latency90', 'latency99', 'throughputAvg'];
140
140
  if (!opt.includeLatencyPercentiles) {
141
141
  fields = fields.filter(f => !f.startsWith('latency') || f === 'latencyAvg');
@@ -147,9 +147,9 @@ async function writePlotFiles(opt, summaries) {
147
147
  // generate a static SVG image
148
148
  const svg = await view.toSVG();
149
149
  // console.log(svg)
150
- fs.writeFileSync(`${reportDirPath}/${name}.${specName}.svg`, svg);
150
+ (0, nodejs_lib_1._writeFileSync)(`${reportDirPath}/${name}.${specName}.svg`, svg);
151
151
  });
152
- fs.writeFileSync(`${reportDirPath}/${name}.md`, mdContent(opt, Object.keys(specs)));
152
+ (0, nodejs_lib_1._writeFileSync)(`${reportDirPath}/${name}.md`, mdContent(opt, Object.keys(specs)));
153
153
  }
154
154
  function autocannonSummaryToVegaSpecs(fields, summaries) {
155
155
  // console.log(summary)
package/package.json CHANGED
@@ -9,7 +9,6 @@
9
9
  "autocannon": "^7.0.0",
10
10
  "benchmark": "^2.1.4",
11
11
  "express": "^4.17.1",
12
- "fs-extra": "^11.1.0",
13
12
  "helmet": "^7.0.0",
14
13
  "vega": "^5.10.1",
15
14
  "vega-lite": "^5.0.0"
@@ -37,7 +36,7 @@
37
36
  "engines": {
38
37
  "node": ">=16.10.0"
39
38
  },
40
- "version": "1.6.3",
39
+ "version": "1.6.4",
41
40
  "description": "Benchmarking library, based on Benchmark.js and Autocannon",
42
41
  "author": "Natural Cycles Team",
43
42
  "license": "MIT"