@rubensworks/process-sparql-benchmark-results 1.3.5 → 1.4.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/README.md +1 -1
- package/bin/psbr.js +4 -1
- package/bin/psbr.js.map +1 -1
- package/index.js +5 -1
- package/index.js.map +1 -1
- package/lib/TemplateUtils.js +23 -10
- package/lib/TemplateUtils.js.map +1 -1
- package/lib/cli/CliHelpers.js +27 -14
- package/lib/cli/CliHelpers.js.map +1 -1
- package/lib/cli/CliRunner.d.ts +1 -1
- package/lib/cli/CliRunner.js +5 -5
- package/lib/cli/CliRunner.js.map +1 -1
- package/lib/cli/ITaskContext.js.map +1 -1
- package/lib/cli/commands/CommandCsv.d.ts +1 -1
- package/lib/cli/commands/CommandCsv.js +7 -5
- package/lib/cli/commands/CommandCsv.js.map +1 -1
- package/lib/cli/commands/CommandStats.d.ts +1 -1
- package/lib/cli/commands/CommandStats.js +7 -5
- package/lib/cli/commands/CommandStats.js.map +1 -1
- package/lib/cli/commands/CommandTex.d.ts +1 -1
- package/lib/cli/commands/CommandTex.js +7 -5
- package/lib/cli/commands/CommandTex.js.map +1 -1
- package/lib/cli/commands/csv/CommandBsbm.d.ts +2 -2
- package/lib/cli/commands/csv/CommandBsbm.js +103 -85
- package/lib/cli/commands/csv/CommandBsbm.js.map +1 -1
- package/lib/cli/commands/csv/CommandGithubActionsBenchmark.d.ts +2 -2
- package/lib/cli/commands/csv/CommandGithubActionsBenchmark.js +149 -102
- package/lib/cli/commands/csv/CommandGithubActionsBenchmark.js.map +1 -1
- package/lib/cli/commands/csv/CommandQuery.d.ts +2 -2
- package/lib/cli/commands/csv/CommandQuery.js +111 -93
- package/lib/cli/commands/csv/CommandQuery.js.map +1 -1
- package/lib/cli/commands/csv/CommandSummary.d.ts +2 -2
- package/lib/cli/commands/csv/CommandSummary.js +230 -212
- package/lib/cli/commands/csv/CommandSummary.js.map +1 -1
- package/lib/cli/commands/csv/CommandWins.d.ts +2 -2
- package/lib/cli/commands/csv/CommandWins.js +134 -119
- package/lib/cli/commands/csv/CommandWins.js.map +1 -1
- package/lib/cli/commands/csv/TableSerializerCsv.d.ts +0 -1
- package/lib/cli/commands/csv/TableSerializerMarkdown.d.ts +0 -1
- package/lib/cli/commands/csv/TableSerializerMarkdown.js.map +1 -1
- package/lib/cli/commands/stats/CommandDocker.d.ts +2 -2
- package/lib/cli/commands/stats/CommandDocker.js +66 -48
- package/lib/cli/commands/stats/CommandDocker.js.map +1 -1
- package/lib/cli/commands/tex/CommandQuery.d.ts +2 -2
- package/lib/cli/commands/tex/CommandQuery.js +241 -223
- package/lib/cli/commands/tex/CommandQuery.js.map +1 -1
- package/lib/cli/commands/tex/CommandQueryTimes.d.ts +2 -2
- package/lib/cli/commands/tex/CommandQueryTimes.js +141 -123
- package/lib/cli/commands/tex/CommandQueryTimes.js.map +1 -1
- package/lib/cli/commands/tex/TexUtils.js +38 -20
- package/lib/cli/commands/tex/TexUtils.js.map +1 -1
- package/lib/correctness/CorrectnessCheckerUtils.js +2 -3
- package/lib/correctness/CorrectnessCheckerUtils.js.map +1 -1
- package/package.json +43 -52
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,18 +15,30 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
11
15
|
}) : function(o, v) {
|
|
12
16
|
o["default"] = v;
|
|
13
17
|
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
21
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
37
|
};
|
|
24
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.
|
|
39
|
+
exports.desc = exports.command = void 0;
|
|
40
|
+
exports.builder = builder;
|
|
41
|
+
exports.handler = handler;
|
|
26
42
|
const fs = __importStar(require("fs"));
|
|
27
43
|
const path_1 = __importDefault(require("path"));
|
|
28
44
|
const TemplateUtils_1 = require("../../../TemplateUtils");
|
|
@@ -30,237 +46,239 @@ const CliHelpers_1 = require("../../CliHelpers");
|
|
|
30
46
|
const TexUtils_1 = require("./TexUtils");
|
|
31
47
|
exports.command = 'query <experiment-dir...>';
|
|
32
48
|
exports.desc = 'Plot the query execution times from the given experiments';
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
49
|
+
function builder(yargs) {
|
|
50
|
+
return yargs
|
|
51
|
+
.options({
|
|
52
|
+
queryRegex: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
alias: 'q',
|
|
55
|
+
describe: 'Regex for queries to include (before any label overrides). Examples: \'^C\', \'^[^C]\', ...',
|
|
56
|
+
},
|
|
57
|
+
name: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
alias: 'n',
|
|
60
|
+
describe: 'Custom output file name',
|
|
61
|
+
default: 'plot_queries_data',
|
|
62
|
+
},
|
|
63
|
+
color: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
alias: 'c',
|
|
66
|
+
describe: 'Color scheme name from colorbrewer2.org',
|
|
67
|
+
},
|
|
68
|
+
shiftColorList: {
|
|
69
|
+
type: 'number',
|
|
70
|
+
describe: 'How many color list elements should be skipped',
|
|
71
|
+
default: 0,
|
|
72
|
+
},
|
|
73
|
+
maxY: {
|
|
74
|
+
type: 'number',
|
|
75
|
+
describe: 'The upper limit of the Y-axis. Defaults to maximum Y value',
|
|
76
|
+
},
|
|
77
|
+
legend: {
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
describe: 'If a legend should be included',
|
|
80
|
+
default: true,
|
|
81
|
+
},
|
|
82
|
+
legendPos: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
describe: 'The legend position X,Y (anchor north-east)',
|
|
85
|
+
default: '1.0,1.0',
|
|
86
|
+
},
|
|
87
|
+
logY: {
|
|
88
|
+
type: 'boolean',
|
|
89
|
+
describe: 'If the Y-Axis must have a log scale',
|
|
90
|
+
default: false,
|
|
91
|
+
},
|
|
92
|
+
inputName: {
|
|
93
|
+
type: 'string',
|
|
94
|
+
describe: 'Custom input file name per experiment',
|
|
95
|
+
default: 'query-times.csv',
|
|
96
|
+
},
|
|
97
|
+
inputDelimiter: {
|
|
98
|
+
type: 'string',
|
|
99
|
+
describe: 'Delimiter for the input CSV file',
|
|
100
|
+
default: ';',
|
|
101
|
+
},
|
|
102
|
+
overrideCombinationLabels: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
describe: 'Comma-separated list of combination labels to use',
|
|
105
|
+
},
|
|
106
|
+
overrideQueryLabels: {
|
|
107
|
+
type: 'string',
|
|
108
|
+
describe: 'Comma-separated list of query labels to use',
|
|
109
|
+
},
|
|
110
|
+
zeroReplacement: {
|
|
111
|
+
type: 'number',
|
|
112
|
+
describe: 'If zero values occur, what values they should be replaced with',
|
|
113
|
+
default: 0,
|
|
114
|
+
},
|
|
115
|
+
svg: {
|
|
116
|
+
type: 'boolean',
|
|
117
|
+
describe: 'If the tex file should be converted to svg via the tex2svg command',
|
|
118
|
+
default: false,
|
|
119
|
+
},
|
|
120
|
+
metric: {
|
|
121
|
+
type: 'string',
|
|
122
|
+
describe: 'The metric to plot',
|
|
123
|
+
choices: ['time', 'httpRequests'],
|
|
124
|
+
default: 'time',
|
|
125
|
+
},
|
|
126
|
+
outliers: {
|
|
127
|
+
type: 'boolean',
|
|
128
|
+
describe: 'If outliers should be included',
|
|
129
|
+
default: true,
|
|
130
|
+
},
|
|
131
|
+
relative: {
|
|
132
|
+
type: 'boolean',
|
|
133
|
+
describe: 'If the maximum value per query should be set to 1, and all other values made relative to that.',
|
|
134
|
+
default: false,
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function handler(argv) {
|
|
139
|
+
return (0, CliHelpers_1.wrapCommandHandler)(argv, async (context) => (0, CliHelpers_1.wrapVisualProgress)('Plotting data', async () => {
|
|
140
|
+
// Load CLI args
|
|
141
|
+
const { experimentDirectories, experimentNames, experimentIds } = (0, TexUtils_1.getExperimentNames)(argv);
|
|
142
|
+
const queryRegex = argv.queryRegex ? new RegExp(argv.queryRegex, 'u') : undefined;
|
|
143
|
+
const colorScheme = (0, TexUtils_1.getColorScheme)(argv, experimentDirectories);
|
|
144
|
+
const metric = argv.metric;
|
|
145
|
+
// Prepare query CSV file with averages per query group
|
|
146
|
+
let queryNames;
|
|
147
|
+
let outputCsvEntries = {};
|
|
148
|
+
const maxQueryValues = {};
|
|
149
|
+
for (const experimentDirectory of experimentDirectories) {
|
|
150
|
+
// Read CSV file
|
|
151
|
+
const totals = {};
|
|
152
|
+
const totalsFirst = {};
|
|
153
|
+
await (0, TexUtils_1.handleCsvFile)(experimentDirectory, argv, (data) => {
|
|
154
|
+
if (!queryRegex || queryRegex.test(data.name)) {
|
|
155
|
+
if (!(data.name in totals)) {
|
|
156
|
+
totals[data.name] = [];
|
|
157
|
+
}
|
|
158
|
+
let value = Number.parseFloat(data[metric] || '0');
|
|
159
|
+
value = Math.max(argv.zeroReplacement, value);
|
|
160
|
+
totals[data.name].push(value);
|
|
161
|
+
if (data.timestamps) {
|
|
162
|
+
if (!(data.name in totalsFirst)) {
|
|
163
|
+
totalsFirst[data.name] = [];
|
|
164
|
+
}
|
|
165
|
+
totalsFirst[data.name].push(Number.parseFloat(data.timestamps.split(' ')[0]));
|
|
146
166
|
}
|
|
147
|
-
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
// Calculate average
|
|
170
|
+
const averages = {};
|
|
171
|
+
const averageMinus = {};
|
|
172
|
+
const averagePlus = {};
|
|
173
|
+
for (const [query, times] of Object.entries(totals)) {
|
|
174
|
+
const average = times.reduce((sum, current) => sum + current) / times.length;
|
|
175
|
+
averages[query] = average;
|
|
176
|
+
averageMinus[query] = average - times.reduce((minV, value) => Math.min(value, minV));
|
|
177
|
+
const maxValue = times.reduce((maxV, value) => Math.max(value, maxV));
|
|
178
|
+
averagePlus[query] = maxValue - average;
|
|
179
|
+
if (!(query in maxQueryValues)) {
|
|
180
|
+
maxQueryValues[query] = maxValue;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
maxQueryValues[query] = Math.max(maxQueryValues[query], maxValue);
|
|
148
184
|
}
|
|
149
185
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const maxValue = times.reduce((maxV, value) => Math.max(value, maxV));
|
|
160
|
-
averagePlus[query] = maxValue - average;
|
|
161
|
-
if (!(query in maxQueryValues)) {
|
|
162
|
-
maxQueryValues[query] = maxValue;
|
|
186
|
+
const averagesFirst = {};
|
|
187
|
+
const averageFirstMinus = {};
|
|
188
|
+
const averageFirstPlus = {};
|
|
189
|
+
for (const [query, times] of Object.entries(totalsFirst)) {
|
|
190
|
+
const average = times.reduce((sum, current) => sum + current) / times.length;
|
|
191
|
+
averagesFirst[query] = average;
|
|
192
|
+
averageFirstMinus[query] = average - times.reduce((minV, value) => Math.min(value, minV));
|
|
193
|
+
const maxValue = times.reduce((maxV, value) => Math.max(value, maxV));
|
|
194
|
+
averageFirstPlus[query] = maxValue - average;
|
|
163
195
|
}
|
|
164
|
-
|
|
165
|
-
|
|
196
|
+
// Set query names and count
|
|
197
|
+
if (!queryNames) {
|
|
198
|
+
queryNames = Object.keys(averages);
|
|
199
|
+
for (const queryName of queryNames) {
|
|
200
|
+
outputCsvEntries[queryName] = [];
|
|
201
|
+
}
|
|
166
202
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
for (const [query, times] of Object.entries(totalsFirst)) {
|
|
172
|
-
const average = times.reduce((sum, current) => sum + current) / times.length;
|
|
173
|
-
averagesFirst[query] = average;
|
|
174
|
-
averageFirstMinus[query] = average - times.reduce((minV, value) => Math.min(value, minV));
|
|
175
|
-
const maxValue = times.reduce((maxV, value) => Math.max(value, maxV));
|
|
176
|
-
averageFirstPlus[query] = maxValue - average;
|
|
177
|
-
}
|
|
178
|
-
// Set query names and count
|
|
179
|
-
if (!queryNames) {
|
|
180
|
-
queryNames = Object.keys(averages);
|
|
203
|
+
else if (queryNames.join(',') !== Object.keys(averages).join(',')) {
|
|
204
|
+
throw new Error(`Tried to plot experiments with different query sets`);
|
|
205
|
+
}
|
|
206
|
+
// Append average, min, and max result
|
|
181
207
|
for (const queryName of queryNames) {
|
|
182
|
-
outputCsvEntries[queryName]
|
|
208
|
+
outputCsvEntries[queryName].push(averages[queryName], averageMinus[queryName], averagePlus[queryName]);
|
|
209
|
+
if (metric === 'time') {
|
|
210
|
+
outputCsvEntries[queryName].push(averagesFirst[queryName] || Number.NaN, averageFirstMinus[queryName] || Number.NaN, averageFirstPlus[queryName] || Number.NaN);
|
|
211
|
+
}
|
|
183
212
|
}
|
|
184
213
|
}
|
|
185
|
-
|
|
186
|
-
throw new Error(`
|
|
214
|
+
if (!queryNames) {
|
|
215
|
+
throw new Error(`No queries could be found`);
|
|
187
216
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
outputCsvEntries[queryName].push(averagesFirst[queryName] || Number.NaN, averageFirstMinus[queryName] || Number.NaN, averageFirstPlus[queryName] || Number.NaN);
|
|
217
|
+
if (argv.relative) {
|
|
218
|
+
// Make values relative per query
|
|
219
|
+
for (const queryName of Object.keys(outputCsvEntries)) {
|
|
220
|
+
outputCsvEntries[queryName] = outputCsvEntries[queryName].map(value => value / maxQueryValues[queryName]);
|
|
193
221
|
}
|
|
194
222
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const csvOutputStream = fs.createWriteStream(path_1.default.join(context.cwd, `${argv.name}.csv`));
|
|
210
|
-
csvOutputStream.write(`query;${experimentIds.map(id => {
|
|
211
|
-
let value = `${id}-mean;${id}-minus;${id}-plus`;
|
|
212
|
-
if (metric === 'time') {
|
|
213
|
-
value = `${value};${id}-first-mean;${id}-first-minus;${id}-first-plus`;
|
|
223
|
+
// Determine query labels
|
|
224
|
+
queryNames = (0, TexUtils_1.getQueryNames)(queryNames, argv);
|
|
225
|
+
outputCsvEntries = (0, TexUtils_1.relabelQueryNames)(outputCsvEntries, queryNames);
|
|
226
|
+
// Write output CSV file
|
|
227
|
+
const csvOutputStream = fs.createWriteStream(path_1.default.join(context.cwd, `${argv.name}.csv`));
|
|
228
|
+
csvOutputStream.write(`query;${experimentIds.map((id) => {
|
|
229
|
+
let value = `${id}-mean;${id}-minus;${id}-plus`;
|
|
230
|
+
if (metric === 'time') {
|
|
231
|
+
value = `${value};${id}-first-mean;${id}-first-minus;${id}-first-plus`;
|
|
232
|
+
}
|
|
233
|
+
return value;
|
|
234
|
+
}).join(';')}\n`);
|
|
235
|
+
for (const [key, columns] of Object.entries(outputCsvEntries)) {
|
|
236
|
+
csvOutputStream.write(`${key};${columns.join(';')}\n`);
|
|
214
237
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
csvOutputStream.close();
|
|
221
|
-
// Shift color list by a number of elements
|
|
222
|
-
const prependPlotLines = argv.shiftColorList > 0 ? `\\pgfplotsset{cycle list shift=${argv.shiftColorList}}\n` : '';
|
|
223
|
-
// Prepare bar lines
|
|
224
|
-
let barLines = prependPlotLines + experimentNames
|
|
225
|
-
.map((name, id) => {
|
|
226
|
-
const offset = (id - ((experimentNames.length - 1) / 2)) * 2.75;
|
|
227
|
-
const yModifier = metric === 'time' && !argv.relative ? ' / 1000' : '';
|
|
228
|
-
const outliers = argv.outliers ? `, y error plus expr=(\\thisrow{${id}-plus}${yModifier}), y error minus expr=(\\thisrow{${id}-minus}${yModifier})` : '';
|
|
229
|
-
return `\\addplot+[ybar, xshift=${offset}pt,legend image post style={xshift=${-offset}pt}] table [x=query, y expr=(\\thisrow{${id}-mean}${yModifier})${outliers}, col sep=semicolon]{"${argv.name}.csv"};`;
|
|
230
|
-
})
|
|
231
|
-
.join('\n');
|
|
232
|
-
if (metric === 'time' && argv.outliers) {
|
|
233
|
-
const extraBarLines = experimentNames
|
|
238
|
+
csvOutputStream.close();
|
|
239
|
+
// Shift color list by a number of elements
|
|
240
|
+
const prependPlotLines = argv.shiftColorList > 0 ? `\\pgfplotsset{cycle list shift=${argv.shiftColorList}}\n` : '';
|
|
241
|
+
// Prepare bar lines
|
|
242
|
+
let barLines = prependPlotLines + experimentNames
|
|
234
243
|
.map((name, id) => {
|
|
235
244
|
const offset = (id - ((experimentNames.length - 1) / 2)) * 2.75;
|
|
236
245
|
const yModifier = metric === 'time' && !argv.relative ? ' / 1000' : '';
|
|
237
|
-
|
|
246
|
+
const outliers = argv.outliers ? `, y error plus expr=(\\thisrow{${id}-plus}${yModifier}), y error minus expr=(\\thisrow{${id}-minus}${yModifier})` : '';
|
|
247
|
+
return `\\addplot+[ybar, xshift=${offset}pt,legend image post style={xshift=${-offset}pt}] table [x=query, y expr=(\\thisrow{${id}-mean}${yModifier})${outliers}, col sep=semicolon]{"${argv.name}.csv"};`;
|
|
238
248
|
})
|
|
239
249
|
.join('\n');
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
.replace(/ymin=0,/u, 'ymin=0.000001,ymode=log,log origin=infty,log basis y={10},')
|
|
250
|
-
.replace(/ \/ 1000\)/ug, ' / 1000)+1e-5');
|
|
251
|
-
}
|
|
252
|
-
if (argv.relative) {
|
|
253
|
-
contents = contents.replace('ylabel={Duration (s)},', 'ylabel={},');
|
|
250
|
+
if (metric === 'time' && argv.outliers) {
|
|
251
|
+
const extraBarLines = experimentNames
|
|
252
|
+
.map((name, id) => {
|
|
253
|
+
const offset = (id - ((experimentNames.length - 1) / 2)) * 2.75;
|
|
254
|
+
const yModifier = metric === 'time' && !argv.relative ? ' / 1000' : '';
|
|
255
|
+
return `\\addplot+[only marks,xshift=${offset}pt,mark=star,mark options={color=gray,scale=0.5}] table [x=query, y expr=(\\thisrow{${id}-first-mean}${yModifier}), col sep=semicolon]{"${argv.name}.csv"};`;
|
|
256
|
+
})
|
|
257
|
+
.join('\n');
|
|
258
|
+
barLines = `${barLines}\n${prependPlotLines}${extraBarLines}`;
|
|
254
259
|
}
|
|
255
|
-
|
|
256
|
-
|
|
260
|
+
// Instantiate template
|
|
261
|
+
await (0, TemplateUtils_1.instantiateTemplate)(path_1.default.join(context.templatesRoot, 'tex', 'plot_query_data.tex'), path_1.default.join(context.cwd, `${argv.name}.tex`), Object.assign({ X_LIMITS: experimentDirectories.length * 2, WIDTH: queryNames.length * (experimentNames.length + 1) * 4, QUERIES: queryNames.join(','), LEGEND: experimentNames.map(name => name.replace(/_/gu, '\\_')).join(','), BARS: barLines, COLOR_SCHEME: colorScheme, LEGEND_POS: argv.legendPos }, argv.maxY ? { Y_MAX: `ymax=${argv.maxY},` } : {}), (contents) => {
|
|
262
|
+
if (!argv.legend) {
|
|
263
|
+
contents = contents.replace(/\\legend\{.*\}/ug, '');
|
|
264
|
+
}
|
|
265
|
+
if (argv.logY) {
|
|
266
|
+
contents = contents
|
|
267
|
+
.replace(/ymin=0,/u, 'ymin=0.000001,ymode=log,log origin=infty,log basis y={10},')
|
|
268
|
+
.replace(/ \/ 1000\)/ug, ' / 1000)+1e-5');
|
|
269
|
+
}
|
|
270
|
+
if (argv.relative) {
|
|
271
|
+
contents = contents.replace('ylabel={Duration (s)},', 'ylabel={},');
|
|
272
|
+
}
|
|
273
|
+
if (metric === 'httpRequests') {
|
|
274
|
+
contents = contents.replace('ylabel={Duration (s)},', 'ylabel={HTTP Requests},');
|
|
275
|
+
}
|
|
276
|
+
return contents;
|
|
277
|
+
});
|
|
278
|
+
// Render CSV from TeX
|
|
279
|
+
if (argv.svg) {
|
|
280
|
+
await (0, TexUtils_1.toSvg)(argv, context);
|
|
257
281
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
// Render CSV from TeX
|
|
261
|
-
if (argv.svg) {
|
|
262
|
-
await TexUtils_1.toSvg(argv, context);
|
|
263
|
-
}
|
|
264
|
-
}));
|
|
265
|
-
exports.handler = handler;
|
|
282
|
+
}));
|
|
283
|
+
}
|
|
266
284
|
//# sourceMappingURL=CommandQuery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandQuery.js","sourceRoot":"","sources":["CommandQuery.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,gDAAwB;AAGxB,0DAA6D;AAC7D,iDAA0E;AAG1E,yCAQoB;AAEP,QAAA,OAAO,GAAG,2BAA2B,CAAC;AACtC,QAAA,IAAI,GAAG,2DAA2D,CAAC;AACzE,MAAM,OAAO,GAAG,CAAC,KAAgB,EAAa,EAAE,CACrD,KAAK;KACF,OAAO,CAAC;IACP,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,6FAA6F;KACxG;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,yBAAyB;QACnC,OAAO,EAAE,mBAAmB;KAC7B;IACD,KAAK,EAAE;QACL,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,yCAAyC;KACpD;IACD,cAAc,EAAE;QACd,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,gDAAgD;QAC1D,OAAO,EAAE,CAAC;KACX;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,4DAA4D;KACvE;IACD,MAAM,EAAE;QACN,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,gCAAgC;QAC1C,OAAO,EAAE,IAAI;KACd;IACD,SAAS,EAAE;QACT,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,6CAA6C;QACvD,OAAO,EAAE,SAAS;KACnB;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,QAAQ,E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../../TemplateUtils';\nimport { wrapCommandHandler, wrapVisualProgress } from '../../CliHelpers';\n\nimport type { ITaskContext } from '../../ITaskContext';\nimport {\n\n getColorScheme,\n getExperimentNames,\n getQueryNames,\n handleCsvFile,\n relabelQueryNames,\n toSvg,\n} from './TexUtils';\n\nexport const command = 'query <experiment-dir...>';\nexport const desc = 'Plot the query execution times from the given experiments';\nexport const builder = (yargs: Argv<any>): Argv<any> =>\n yargs\n .options({\n queryRegex: {\n type: 'string',\n alias: 'q',\n describe: 'Regex for queries to include (before any label overrides). Examples: \\'^C\\', \\'^[^C]\\', ...',\n },\n name: {\n type: 'string',\n alias: 'n',\n describe: 'Custom output file name',\n default: 'plot_queries_data',\n },\n color: {\n type: 'string',\n alias: 'c',\n describe: 'Color scheme name from colorbrewer2.org',\n },\n shiftColorList: {\n type: 'number',\n describe: 'How many color list elements should be skipped',\n default: 0,\n },\n maxY: {\n type: 'number',\n describe: 'The upper limit of the Y-axis. Defaults to maximum Y value',\n },\n legend: {\n type: 'boolean',\n describe: 'If a legend should be included',\n default: true,\n },\n legendPos: {\n type: 'string',\n describe: 'The legend position X,Y (anchor north-east)',\n default: '1.0,1.0',\n },\n logY: {\n type: 'boolean',\n describe: 'If the Y-Axis must have a log scale',\n default: false,\n },\n inputName: {\n type: 'string',\n describe: 'Custom input file name per experiment',\n default: 'query-times.csv',\n },\n inputDelimiter: {\n type: 'string',\n describe: 'Delimiter for the input CSV file',\n default: ';',\n },\n overrideCombinationLabels: {\n type: 'string',\n describe: 'Comma-separated list of combination labels to use',\n },\n overrideQueryLabels: {\n type: 'string',\n describe: 'Comma-separated list of query labels to use',\n },\n zeroReplacement: {\n type: 'number',\n describe: 'If zero values occur, what values they should be replaced with',\n default: 0,\n },\n svg: {\n type: 'boolean',\n describe: 'If the tex file should be converted to svg via the tex2svg command',\n default: false,\n },\n metric: {\n type: 'string',\n describe: 'The metric to plot',\n choices: [ 'time', 'httpRequests' ],\n default: 'time',\n },\n outliers: {\n type: 'boolean',\n describe: 'If outliers should be included',\n default: true,\n },\n relative: {\n type: 'boolean',\n describe: 'If the maximum value per query should be set to 1, and all other values made relative to that.',\n default: false,\n },\n });\nexport const handler = (argv: Record<string, any>): Promise<void> => wrapCommandHandler(argv,\n async(context: ITaskContext) => wrapVisualProgress('Plotting data', async() => {\n // Load CLI args\n const { experimentDirectories, experimentNames, experimentIds } = getExperimentNames(argv);\n const queryRegex = argv.queryRegex ? new RegExp(argv.queryRegex, 'u') : undefined;\n const colorScheme = getColorScheme(argv, experimentDirectories);\n const metric = argv.metric;\n\n // Prepare query CSV file with averages per query group\n let queryNames: string[] | undefined;\n let outputCsvEntries: Record<string, number[]> = {};\n const maxQueryValues: Record<string, number> = {};\n for (const experimentDirectory of experimentDirectories) {\n // Read CSV file\n const totals: Record<string, number[]> = {};\n const totalsFirst: Record<string, number[]> = {};\n await handleCsvFile(experimentDirectory, argv, data => {\n if (!queryRegex || queryRegex.test(data.name)) {\n if (!(data.name in totals)) {\n totals[data.name] = [];\n }\n\n let value = Number.parseInt(data[metric] || '0', 10);\n value = Math.max(argv.zeroReplacement, value);\n\n totals[data.name].push(value);\n\n if (data.timestamps) {\n if (!(data.name in totalsFirst)) {\n totalsFirst[data.name] = [];\n }\n totalsFirst[data.name].push(Number.parseInt(data.timestamps.split(' ')[0], 10));\n }\n }\n });\n\n // Calculate average\n const averages: Record<string, number> = {};\n const averageMinus: Record<string, number> = {};\n const averagePlus: Record<string, number> = {};\n for (const [ query, times ] of Object.entries(totals)) {\n const average = times.reduce((sum, current) => sum + current) / times.length;\n averages[query] = average;\n averageMinus[query] = average - times.reduce((minV, value) => Math.min(value, minV));\n const maxValue = times.reduce((maxV, value) => Math.max(value, maxV));\n averagePlus[query] = maxValue - average;\n\n if (!(query in maxQueryValues)) {\n maxQueryValues[query] = maxValue;\n } else {\n maxQueryValues[query] = Math.max(maxQueryValues[query], maxValue);\n }\n }\n const averagesFirst: Record<string, number> = {};\n const averageFirstMinus: Record<string, number> = {};\n const averageFirstPlus: Record<string, number> = {};\n for (const [ query, times ] of Object.entries(totalsFirst)) {\n const average = times.reduce((sum, current) => sum + current) / times.length;\n averagesFirst[query] = average;\n averageFirstMinus[query] = average - times.reduce((minV, value) => Math.min(value, minV));\n const maxValue = times.reduce((maxV, value) => Math.max(value, maxV));\n averageFirstPlus[query] = maxValue - average;\n }\n\n // Set query names and count\n if (!queryNames) {\n queryNames = Object.keys(averages);\n for (const queryName of queryNames) {\n outputCsvEntries[queryName] = [];\n }\n } else if (queryNames.join(',') !== Object.keys(averages).join(',')) {\n throw new Error(`Tried to plot experiments with different query sets`);\n }\n\n // Append average, min, and max result\n for (const queryName of queryNames) {\n outputCsvEntries[queryName].push(\n averages[queryName],\n averageMinus[queryName],\n averagePlus[queryName],\n );\n if (metric === 'time') {\n outputCsvEntries[queryName].push(\n averagesFirst[queryName] || Number.NaN,\n averageFirstMinus[queryName] || Number.NaN,\n averageFirstPlus[queryName] || Number.NaN,\n );\n }\n }\n }\n if (!queryNames) {\n throw new Error(`No queries could be found`);\n }\n if (argv.relative) {\n // Make values relative per query\n for (const queryName of Object.keys(outputCsvEntries)) {\n outputCsvEntries[queryName] = outputCsvEntries[queryName].map(value => value / maxQueryValues[queryName]);\n }\n }\n // Determine query labels\n queryNames = getQueryNames(queryNames, argv);\n outputCsvEntries = relabelQueryNames(outputCsvEntries, queryNames);\n\n // Write output CSV file\n const csvOutputStream = fs.createWriteStream(Path.join(context.cwd, `${argv.name}.csv`));\n csvOutputStream.write(`query;${experimentIds.map(id => {\n let value = `${id}-mean;${id}-minus;${id}-plus`;\n if (metric === 'time') {\n value = `${value};${id}-first-mean;${id}-first-minus;${id}-first-plus`;\n }\n return value;\n }).join(';')}\\n`);\n for (const [ key, columns ] of Object.entries(outputCsvEntries)) {\n csvOutputStream.write(`${key};${columns.join(';')}\\n`);\n }\n csvOutputStream.close();\n\n // Shift color list by a number of elements\n const prependPlotLines = argv.shiftColorList > 0 ? `\\\\pgfplotsset{cycle list shift=${argv.shiftColorList}}\\n` : '';\n\n // Prepare bar lines\n let barLines = prependPlotLines + experimentNames\n .map((name, id) => {\n const offset = (id - ((experimentNames.length - 1) / 2)) * 2.75;\n const yModifier = metric === 'time' && !argv.relative ? ' / 1000' : '';\n const outliers = argv.outliers ? `, y error plus expr=(\\\\thisrow{${id}-plus}${yModifier}), y error minus expr=(\\\\thisrow{${id}-minus}${yModifier})` : '';\n return `\\\\addplot+[ybar, xshift=${offset}pt,legend image post style={xshift=${-offset}pt}] table [x=query, y expr=(\\\\thisrow{${id}-mean}${yModifier})${outliers}, col sep=semicolon]{\"${argv.name}.csv\"};`;\n })\n .join('\\n');\n if (metric === 'time' && argv.outliers) {\n const extraBarLines = experimentNames\n .map((name, id) => {\n const offset = (id - ((experimentNames.length - 1) / 2)) * 2.75;\n const yModifier = metric === 'time' && !argv.relative ? ' / 1000' : '';\n return `\\\\addplot+[only marks,xshift=${offset}pt,mark=star,mark options={color=gray,scale=0.5}] table [x=query, y expr=(\\\\thisrow{${id}-first-mean}${yModifier}), col sep=semicolon]{\"${argv.name}.csv\"};`;\n })\n .join('\\n');\n barLines = `${barLines}\\n${prependPlotLines}${extraBarLines}`;\n }\n\n // Instantiate template\n await instantiateTemplate(\n Path.join(context.templatesRoot, 'tex', 'plot_query_data.tex'),\n Path.join(context.cwd, `${argv.name}.tex`),\n {\n X_LIMITS: experimentDirectories.length * 2,\n WIDTH: queryNames.length * (experimentNames.length + 1) * 4,\n QUERIES: queryNames.join(','),\n LEGEND: experimentNames.map(name => name.replace(/_/gu, '\\\\_')).join(','),\n BARS: barLines,\n COLOR_SCHEME: colorScheme,\n LEGEND_POS: argv.legendPos,\n ...argv.maxY ? { Y_MAX: `ymax=${argv.maxY},` } : {},\n },\n contents => {\n if (!argv.legend) {\n contents = contents.replace(/\\\\legend\\{.*\\}/ug, '');\n }\n if (argv.logY) {\n contents = contents\n .replace(/ymin=0,/u, 'ymin=0.000001,ymode=log,log origin=infty,log basis y={10},')\n .replace(/ \\/ 1000\\)/ug, ' / 1000)+1e-5');\n }\n if (argv.relative) {\n contents = contents.replace('ylabel={Duration (s)},', 'ylabel={},');\n }\n if (metric === 'httpRequests') {\n contents = contents.replace('ylabel={Duration (s)},', 'ylabel={HTTP Requests},');\n }\n return contents;\n },\n );\n\n // Render CSV from TeX\n if (argv.svg) {\n await toSvg(argv, context);\n }\n }));\n"]}
|
|
1
|
+
{"version":3,"file":"CommandQuery.js","sourceRoot":"","sources":["CommandQuery.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,0BAwFC;AACD,0BAkLC;AA/RD,uCAAyB;AACzB,gDAAwB;AAGxB,0DAA6D;AAC7D,iDAA0E;AAG1E,yCAQoB;AAEP,QAAA,OAAO,GAAG,2BAA2B,CAAC;AACtC,QAAA,IAAI,GAAG,2DAA2D,CAAC;AAChF,SAAgB,OAAO,CAAC,KAAgB;IACtC,OAAO,KAAK;SACT,OAAO,CAAC;QACP,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,GAAG;YACV,QAAQ,EAAE,6FAA6F;SACxG;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,GAAG;YACV,QAAQ,EAAE,yBAAyB;YACnC,OAAO,EAAE,mBAAmB;SAC7B;QACD,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,GAAG;YACV,QAAQ,EAAE,yCAAyC;SACpD;QACD,cAAc,EAAE;YACd,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,gDAAgD;YAC1D,OAAO,EAAE,CAAC;SACX;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,4DAA4D;SACvE;QACD,MAAM,EAAE;YACN,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,gCAAgC;YAC1C,OAAO,EAAE,IAAI;SACd;QACD,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;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AAC,CAAC;YACtE,CAAC;YACD,IAAI,MAAM,KAAK,cAAc,EAAE,CAAC;gBAC9B,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,wBAAwB,EAAE,yBAAyB,CAAC,CAAC;YACnF,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC,CACF,CAAC;QAEF,sBAAsB;QACtB,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACb,MAAM,IAAA,gBAAK,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CAAC,CAAC,CAAC;AACN,CAAC","sourcesContent":["import * as fs from 'fs';\nimport Path from 'path';\n\nimport type { Argv } from 'yargs';\nimport { instantiateTemplate } from '../../../TemplateUtils';\nimport { wrapCommandHandler, wrapVisualProgress } from '../../CliHelpers';\n\nimport type { ITaskContext } from '../../ITaskContext';\nimport {\n\n getColorScheme,\n getExperimentNames,\n getQueryNames,\n handleCsvFile,\n relabelQueryNames,\n toSvg,\n} from './TexUtils';\n\nexport const command = 'query <experiment-dir...>';\nexport const desc = 'Plot the query execution times from the given experiments';\nexport function builder(yargs: Argv<any>): Argv<any> {\n return yargs\n .options({\n queryRegex: {\n type: 'string',\n alias: 'q',\n describe: 'Regex for queries to include (before any label overrides). Examples: \\'^C\\', \\'^[^C]\\', ...',\n },\n name: {\n type: 'string',\n alias: 'n',\n describe: 'Custom output file name',\n default: 'plot_queries_data',\n },\n color: {\n type: 'string',\n alias: 'c',\n describe: 'Color scheme name from colorbrewer2.org',\n },\n shiftColorList: {\n type: 'number',\n describe: 'How many color list elements should be skipped',\n default: 0,\n },\n maxY: {\n type: 'number',\n describe: 'The upper limit of the Y-axis. Defaults to maximum Y value',\n },\n legend: {\n type: 'boolean',\n describe: 'If a legend should be included',\n default: true,\n },\n legendPos: {\n type: 'string',\n describe: 'The legend position X,Y (anchor north-east)',\n default: '1.0,1.0',\n },\n logY: {\n type: 'boolean',\n describe: 'If the Y-Axis must have a log scale',\n default: false,\n },\n inputName: {\n type: 'string',\n describe: 'Custom input file name per experiment',\n default: 'query-times.csv',\n },\n inputDelimiter: {\n type: 'string',\n describe: 'Delimiter for the input CSV file',\n default: ';',\n },\n overrideCombinationLabels: {\n type: 'string',\n describe: 'Comma-separated list of combination labels to use',\n },\n overrideQueryLabels: {\n type: 'string',\n describe: 'Comma-separated list of query labels to use',\n },\n zeroReplacement: {\n type: 'number',\n describe: 'If zero values occur, what values they should be replaced with',\n default: 0,\n },\n svg: {\n type: 'boolean',\n describe: 'If the tex file should be converted to svg via the tex2svg command',\n default: false,\n },\n metric: {\n type: 'string',\n describe: 'The metric to plot',\n choices: [ 'time', 'httpRequests' ],\n default: 'time',\n },\n outliers: {\n type: 'boolean',\n describe: 'If outliers should be included',\n default: true,\n },\n relative: {\n type: 'boolean',\n describe: 'If the maximum value per query should be set to 1, and all other values made relative to that.',\n default: false,\n },\n });\n}\nexport function handler(argv: Record<string, any>): Promise<void> {\n return wrapCommandHandler(argv, async(context: ITaskContext) => wrapVisualProgress('Plotting data', async() => {\n // Load CLI args\n const { experimentDirectories, experimentNames, experimentIds } = getExperimentNames(argv);\n const queryRegex = argv.queryRegex ? new RegExp(argv.queryRegex, 'u') : undefined;\n const colorScheme = getColorScheme(argv, experimentDirectories);\n const metric = argv.metric;\n\n // Prepare query CSV file with averages per query group\n let queryNames: string[] | undefined;\n let outputCsvEntries: Record<string, number[]> = {};\n const maxQueryValues: Record<string, number> = {};\n for (const experimentDirectory of experimentDirectories) {\n // Read CSV file\n const totals: Record<string, number[]> = {};\n const totalsFirst: Record<string, number[]> = {};\n await handleCsvFile(experimentDirectory, argv, (data) => {\n if (!queryRegex || queryRegex.test(data.name)) {\n if (!(data.name in totals)) {\n totals[data.name] = [];\n }\n\n let value = Number.parseFloat(data[metric] || '0');\n value = Math.max(argv.zeroReplacement, value);\n\n totals[data.name].push(value);\n\n if (data.timestamps) {\n if (!(data.name in totalsFirst)) {\n totalsFirst[data.name] = [];\n }\n totalsFirst[data.name].push(Number.parseFloat(data.timestamps.split(' ')[0]));\n }\n }\n });\n\n // Calculate average\n const averages: Record<string, number> = {};\n const averageMinus: Record<string, number> = {};\n const averagePlus: Record<string, number> = {};\n for (const [ query, times ] of Object.entries(totals)) {\n const average = times.reduce((sum, current) => sum + current) / times.length;\n averages[query] = average;\n averageMinus[query] = average - times.reduce((minV, value) => Math.min(value, minV));\n const maxValue = times.reduce((maxV, value) => Math.max(value, maxV));\n averagePlus[query] = maxValue - average;\n\n if (!(query in maxQueryValues)) {\n maxQueryValues[query] = maxValue;\n } else {\n maxQueryValues[query] = Math.max(maxQueryValues[query], maxValue);\n }\n }\n const averagesFirst: Record<string, number> = {};\n const averageFirstMinus: Record<string, number> = {};\n const averageFirstPlus: Record<string, number> = {};\n for (const [ query, times ] of Object.entries(totalsFirst)) {\n const average = times.reduce((sum, current) => sum + current) / times.length;\n averagesFirst[query] = average;\n averageFirstMinus[query] = average - times.reduce((minV, value) => Math.min(value, minV));\n const maxValue = times.reduce((maxV, value) => Math.max(value, maxV));\n averageFirstPlus[query] = maxValue - average;\n }\n\n // Set query names and count\n if (!queryNames) {\n queryNames = Object.keys(averages);\n for (const queryName of queryNames) {\n outputCsvEntries[queryName] = [];\n }\n } else if (queryNames.join(',') !== Object.keys(averages).join(',')) {\n throw new Error(`Tried to plot experiments with different query sets`);\n }\n\n // Append average, min, and max result\n for (const queryName of queryNames) {\n outputCsvEntries[queryName].push(\n averages[queryName],\n averageMinus[queryName],\n averagePlus[queryName],\n );\n if (metric === 'time') {\n outputCsvEntries[queryName].push(\n averagesFirst[queryName] || Number.NaN,\n averageFirstMinus[queryName] || Number.NaN,\n averageFirstPlus[queryName] || Number.NaN,\n );\n }\n }\n }\n if (!queryNames) {\n throw new Error(`No queries could be found`);\n }\n if (argv.relative) {\n // Make values relative per query\n for (const queryName of Object.keys(outputCsvEntries)) {\n outputCsvEntries[queryName] = outputCsvEntries[queryName].map(value => value / maxQueryValues[queryName]);\n }\n }\n // Determine query labels\n queryNames = getQueryNames(queryNames, argv);\n outputCsvEntries = relabelQueryNames(outputCsvEntries, queryNames);\n\n // Write output CSV file\n const csvOutputStream = fs.createWriteStream(Path.join(context.cwd, `${argv.name}.csv`));\n csvOutputStream.write(`query;${experimentIds.map((id) => {\n let value = `${id}-mean;${id}-minus;${id}-plus`;\n if (metric === 'time') {\n value = `${value};${id}-first-mean;${id}-first-minus;${id}-first-plus`;\n }\n return value;\n }).join(';')}\\n`);\n for (const [ key, columns ] of Object.entries(outputCsvEntries)) {\n csvOutputStream.write(`${key};${columns.join(';')}\\n`);\n }\n csvOutputStream.close();\n\n // Shift color list by a number of elements\n const prependPlotLines = argv.shiftColorList > 0 ? `\\\\pgfplotsset{cycle list shift=${argv.shiftColorList}}\\n` : '';\n\n // Prepare bar lines\n let barLines = prependPlotLines + experimentNames\n .map((name, id) => {\n const offset = (id - ((experimentNames.length - 1) / 2)) * 2.75;\n const yModifier = metric === 'time' && !argv.relative ? ' / 1000' : '';\n const outliers = argv.outliers ? `, y error plus expr=(\\\\thisrow{${id}-plus}${yModifier}), y error minus expr=(\\\\thisrow{${id}-minus}${yModifier})` : '';\n return `\\\\addplot+[ybar, xshift=${offset}pt,legend image post style={xshift=${-offset}pt}] table [x=query, y expr=(\\\\thisrow{${id}-mean}${yModifier})${outliers}, col sep=semicolon]{\"${argv.name}.csv\"};`;\n })\n .join('\\n');\n if (metric === 'time' && argv.outliers) {\n const extraBarLines = experimentNames\n .map((name, id) => {\n const offset = (id - ((experimentNames.length - 1) / 2)) * 2.75;\n const yModifier = metric === 'time' && !argv.relative ? ' / 1000' : '';\n return `\\\\addplot+[only marks,xshift=${offset}pt,mark=star,mark options={color=gray,scale=0.5}] table [x=query, y expr=(\\\\thisrow{${id}-first-mean}${yModifier}), col sep=semicolon]{\"${argv.name}.csv\"};`;\n })\n .join('\\n');\n barLines = `${barLines}\\n${prependPlotLines}${extraBarLines}`;\n }\n\n // Instantiate template\n await instantiateTemplate(\n Path.join(context.templatesRoot, 'tex', 'plot_query_data.tex'),\n Path.join(context.cwd, `${argv.name}.tex`),\n {\n X_LIMITS: experimentDirectories.length * 2,\n WIDTH: queryNames.length * (experimentNames.length + 1) * 4,\n QUERIES: queryNames.join(','),\n LEGEND: experimentNames.map(name => name.replace(/_/gu, '\\\\_')).join(','),\n BARS: barLines,\n COLOR_SCHEME: colorScheme,\n LEGEND_POS: argv.legendPos,\n ...argv.maxY ? { Y_MAX: `ymax=${argv.maxY},` } : {},\n },\n (contents) => {\n if (!argv.legend) {\n contents = contents.replace(/\\\\legend\\{.*\\}/ug, '');\n }\n if (argv.logY) {\n contents = contents\n .replace(/ymin=0,/u, 'ymin=0.000001,ymode=log,log origin=infty,log basis y={10},')\n .replace(/ \\/ 1000\\)/ug, ' / 1000)+1e-5');\n }\n if (argv.relative) {\n contents = contents.replace('ylabel={Duration (s)},', 'ylabel={},');\n }\n if (metric === 'httpRequests') {\n contents = contents.replace('ylabel={Duration (s)},', 'ylabel={HTTP Requests},');\n }\n return contents;\n },\n );\n\n // Render CSV from TeX\n if (argv.svg) {\n await toSvg(argv, context);\n }\n }));\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Argv } from 'yargs';
|
|
2
2
|
export declare const command = "queryTimes <query> <experiment-dir...>";
|
|
3
3
|
export declare const desc = "Plot the query result arrival times from the given experiments";
|
|
4
|
-
export declare
|
|
5
|
-
export declare
|
|
4
|
+
export declare function builder(yargs: Argv<any>): Argv<any>;
|
|
5
|
+
export declare function handler(argv: Record<string, any>): Promise<void>;
|