1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
13 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
14 | };
|
15 | Object.defineProperty(exports, "__esModule", { value: true });
|
16 | exports.formatCsvRaw = exports.formatCsvStats = void 0;
|
17 | const sync_1 = __importDefault(require("csv-stringify/lib/sync"));
|
18 | const precision = 5;
|
19 |
|
20 |
|
21 |
|
22 | function formatCsvStats(results) {
|
23 |
|
24 |
|
25 | const h1 = ['', '', ''];
|
26 | const h2 = ['', 'ms', ''];
|
27 | const h3 = ['', 'min', 'max'];
|
28 | const rows = [];
|
29 | for (const result of results) {
|
30 | h1.push(`vs ${result.result.name}`, '', '', '');
|
31 | h2.push('% change', '', 'ms change', '');
|
32 | h3.push('min', 'max', 'min', 'max');
|
33 | const row = [];
|
34 | row.push(result.result.name, result.stats.meanCI.low.toFixed(precision), result.stats.meanCI.high.toFixed(precision));
|
35 | for (const diff of result.differences) {
|
36 | if (diff === null) {
|
37 | row.push('', '', '', '');
|
38 | }
|
39 | else {
|
40 | row.push((diff.relative.low * 100).toFixed(precision) + '%', (diff.relative.high * 100).toFixed(precision) + '%', diff.absolute.low.toFixed(precision), diff.absolute.high.toFixed(precision));
|
41 | }
|
42 | }
|
43 | rows.push(row);
|
44 | }
|
45 | return sync_1.default([h1, h2, h3, ...rows]);
|
46 | }
|
47 | exports.formatCsvStats = formatCsvStats;
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | function formatCsvRaw(results) {
|
62 | const headers = [];
|
63 | const rows = [];
|
64 | for (let r = 0; r < results.length; r++) {
|
65 | const { result } = results[r];
|
66 | headers.push(result.name);
|
67 | for (let m = 0; m < result.millis.length; m++) {
|
68 | if (rows[m] === undefined) {
|
69 | rows[m] = [];
|
70 | }
|
71 | rows[m][r] = result.millis[m];
|
72 | }
|
73 | }
|
74 | return sync_1.default([headers, ...rows]);
|
75 | }
|
76 | exports.formatCsvRaw = formatCsvRaw;
|
77 |
|
\ | No newline at end of file |