@rubensworks/process-sparql-benchmark-results 1.0.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/LICENSE.txt +21 -0
- package/README.md +285 -0
- package/bin/psbr +2 -0
- package/bin/psbr.d.ts +2 -0
- package/bin/psbr.js +6 -0
- package/bin/psbr.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.js +16 -0
- package/index.js.map +1 -0
- package/index.ts +3 -0
- package/lib/TemplateUtils.d.ts +1 -0
- package/lib/TemplateUtils.js +35 -0
- package/lib/TemplateUtils.js.map +1 -0
- package/lib/cli/CliHelpers.d.ts +5 -0
- package/lib/cli/CliHelpers.js +87 -0
- package/lib/cli/CliHelpers.js.map +1 -0
- package/lib/cli/CliRunner.d.ts +1 -0
- package/lib/cli/CliRunner.js +24 -0
- package/lib/cli/CliRunner.js.map +1 -0
- package/lib/cli/ErrorHandled.d.ts +8 -0
- package/lib/cli/ErrorHandled.js +15 -0
- package/lib/cli/ErrorHandled.js.map +1 -0
- package/lib/cli/ITaskContext.d.ts +10 -0
- package/lib/cli/ITaskContext.js +3 -0
- package/lib/cli/ITaskContext.js.map +1 -0
- package/lib/cli/commands/CommandCsv.d.ts +4 -0
- package/lib/cli/commands/CommandCsv.js +10 -0
- package/lib/cli/commands/CommandCsv.js.map +1 -0
- package/lib/cli/commands/CommandStats.d.ts +4 -0
- package/lib/cli/commands/CommandStats.js +10 -0
- package/lib/cli/commands/CommandStats.js.map +1 -0
- package/lib/cli/commands/CommandTex.d.ts +4 -0
- package/lib/cli/commands/CommandTex.js +10 -0
- package/lib/cli/commands/CommandTex.js.map +1 -0
- package/lib/cli/commands/csv/CommandQuery.d.ts +5 -0
- package/lib/cli/commands/csv/CommandQuery.js +120 -0
- package/lib/cli/commands/csv/CommandQuery.js.map +1 -0
- package/lib/cli/commands/csv/CommandSummary.d.ts +5 -0
- package/lib/cli/commands/csv/CommandSummary.js +246 -0
- package/lib/cli/commands/csv/CommandSummary.js.map +1 -0
- package/lib/cli/commands/csv/CommandWins.d.ts +5 -0
- package/lib/cli/commands/csv/CommandWins.js +151 -0
- package/lib/cli/commands/csv/CommandWins.js.map +1 -0
- package/lib/cli/commands/csv/ITableSerializer.d.ts +9 -0
- package/lib/cli/commands/csv/ITableSerializer.js +3 -0
- package/lib/cli/commands/csv/ITableSerializer.js.map +1 -0
- package/lib/cli/commands/csv/TableSerializerCsv.d.ts +10 -0
- package/lib/cli/commands/csv/TableSerializerCsv.js +19 -0
- package/lib/cli/commands/csv/TableSerializerCsv.js.map +1 -0
- package/lib/cli/commands/csv/TableSerializerMarkdown.d.ts +18 -0
- package/lib/cli/commands/csv/TableSerializerMarkdown.js +34 -0
- package/lib/cli/commands/csv/TableSerializerMarkdown.js.map +1 -0
- package/lib/cli/commands/stats/CommandDocker.d.ts +7 -0
- package/lib/cli/commands/stats/CommandDocker.js +79 -0
- package/lib/cli/commands/stats/CommandDocker.js.map +1 -0
- package/lib/cli/commands/tex/CommandQuery.d.ts +5 -0
- package/lib/cli/commands/tex/CommandQuery.js +253 -0
- package/lib/cli/commands/tex/CommandQuery.js.map +1 -0
- package/lib/cli/commands/tex/CommandQueryTimes.d.ts +5 -0
- package/lib/cli/commands/tex/CommandQueryTimes.js +153 -0
- package/lib/cli/commands/tex/CommandQueryTimes.js.map +1 -0
- package/lib/cli/commands/tex/TexUtils.d.ts +34 -0
- package/lib/cli/commands/tex/TexUtils.js +149 -0
- package/lib/cli/commands/tex/TexUtils.js.map +1 -0
- package/lib/correctness/CorrectnessCheckerQueries.d.ts +6 -0
- package/lib/correctness/CorrectnessCheckerQueries.js +13 -0
- package/lib/correctness/CorrectnessCheckerQueries.js.map +1 -0
- package/lib/correctness/CorrectnessCheckerUtils.d.ts +2 -0
- package/lib/correctness/CorrectnessCheckerUtils.js +14 -0
- package/lib/correctness/CorrectnessCheckerUtils.js.map +1 -0
- package/lib/correctness/ICorrectnessChecker.d.ts +3 -0
- package/lib/correctness/ICorrectnessChecker.js +3 -0
- package/lib/correctness/ICorrectnessChecker.js.map +1 -0
- package/lib/templates/tex/plot_query_data.tex +94 -0
- package/lib/templates/tex/plot_query_times.tex +75 -0
- package/package.json +100 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
26
|
+
const fs = __importStar(require("fs"));
|
|
27
|
+
const path_1 = __importDefault(require("path"));
|
|
28
|
+
const TemplateUtils_1 = require("../../../TemplateUtils");
|
|
29
|
+
const CliHelpers_1 = require("../../CliHelpers");
|
|
30
|
+
const TexUtils_1 = require("./TexUtils");
|
|
31
|
+
exports.command = 'queryTimes <query> <experiment-dir...>';
|
|
32
|
+
exports.desc = 'Plot the query result arrival times from the given experiments';
|
|
33
|
+
const builder = (yargs) => yargs
|
|
34
|
+
.options({
|
|
35
|
+
name: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
alias: 'n',
|
|
38
|
+
describe: 'Custom output file name',
|
|
39
|
+
default: 'query_times',
|
|
40
|
+
},
|
|
41
|
+
color: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
alias: 'c',
|
|
44
|
+
describe: 'Color scheme name from colorbrewer2.org',
|
|
45
|
+
},
|
|
46
|
+
maxY: {
|
|
47
|
+
type: 'number',
|
|
48
|
+
describe: 'The upper limit of the Y-axis. Defaults to maximum Y value',
|
|
49
|
+
},
|
|
50
|
+
legend: {
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
describe: 'If a legend should be included',
|
|
53
|
+
default: true,
|
|
54
|
+
},
|
|
55
|
+
legendPos: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
describe: 'The legend position X,Y (anchor north-east)',
|
|
58
|
+
default: '1.0,1.0',
|
|
59
|
+
},
|
|
60
|
+
logY: {
|
|
61
|
+
type: 'boolean',
|
|
62
|
+
describe: 'If the Y-Axis must have a log scale',
|
|
63
|
+
default: false,
|
|
64
|
+
},
|
|
65
|
+
inputName: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
describe: 'Custom input file name per experiment',
|
|
68
|
+
default: 'query-times.csv',
|
|
69
|
+
},
|
|
70
|
+
inputDelimiter: {
|
|
71
|
+
type: 'string',
|
|
72
|
+
describe: 'Delimiter for the input CSV file',
|
|
73
|
+
default: ';',
|
|
74
|
+
},
|
|
75
|
+
overrideCombinationLabels: {
|
|
76
|
+
type: 'string',
|
|
77
|
+
describe: 'Comma-separated list of combination labels to use',
|
|
78
|
+
},
|
|
79
|
+
svg: {
|
|
80
|
+
type: 'boolean',
|
|
81
|
+
describe: 'If the tex file should be converted to svg via the tex2svg command',
|
|
82
|
+
default: false,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
exports.builder = builder;
|
|
86
|
+
const handler = (argv) => CliHelpers_1.wrapCommandHandler(argv, async (context) => CliHelpers_1.wrapVisualProgress('Plotting data', async () => {
|
|
87
|
+
// Load CLI args
|
|
88
|
+
let query = argv.query;
|
|
89
|
+
let id = '0';
|
|
90
|
+
const { experimentDirectories, experimentNames, experimentIds } = TexUtils_1.getExperimentNames(argv);
|
|
91
|
+
const colorScheme = TexUtils_1.getColorScheme(argv, experimentDirectories);
|
|
92
|
+
// Determine optional query id
|
|
93
|
+
const dotPos = query.indexOf('.');
|
|
94
|
+
if (dotPos >= 0) {
|
|
95
|
+
id = query.slice(dotPos + 1, query.length);
|
|
96
|
+
query = query.slice(0, Math.max(0, dotPos));
|
|
97
|
+
}
|
|
98
|
+
// Load query times from CSV files
|
|
99
|
+
const resultsArrivalTimes = [];
|
|
100
|
+
for (const [experimentId, experimentDirectory] of experimentDirectories.entries()) {
|
|
101
|
+
// Read CSV file
|
|
102
|
+
let foundQuery = false;
|
|
103
|
+
await TexUtils_1.handleCsvFile(experimentDirectory, argv, data => {
|
|
104
|
+
if (!foundQuery && data.name === query && (!id || data.id === id)) {
|
|
105
|
+
foundQuery = true;
|
|
106
|
+
const times = data.timestamps.split(/[ ,]/u);
|
|
107
|
+
for (const [i, time] of times.entries()) {
|
|
108
|
+
if (i >= resultsArrivalTimes.length) {
|
|
109
|
+
resultsArrivalTimes.push({});
|
|
110
|
+
}
|
|
111
|
+
resultsArrivalTimes[i][experimentId] = time;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
// Write output CSV file
|
|
117
|
+
const csvOutputStream = fs.createWriteStream(path_1.default.join(context.cwd, `${argv.name}.csv`));
|
|
118
|
+
csvOutputStream.write(`${experimentNames.join(';')}\n`);
|
|
119
|
+
for (const resultArrivalTimes of resultsArrivalTimes) {
|
|
120
|
+
let first = true;
|
|
121
|
+
for (const experimentId of experimentIds) {
|
|
122
|
+
if (first) {
|
|
123
|
+
first = false;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
csvOutputStream.write(`;`);
|
|
127
|
+
}
|
|
128
|
+
csvOutputStream.write(`${resultArrivalTimes[experimentId] || ''}`);
|
|
129
|
+
}
|
|
130
|
+
csvOutputStream.write(`\n`);
|
|
131
|
+
}
|
|
132
|
+
csvOutputStream.close();
|
|
133
|
+
// Prepare bar lines
|
|
134
|
+
const lines = experimentNames
|
|
135
|
+
.map(name => `\\addplot+[mark=none] table [y expr=\\coordindex+1, x=${name}, col sep=semicolon]{"${argv.name}.csv"};`)
|
|
136
|
+
.join('\n');
|
|
137
|
+
// Instantiate template
|
|
138
|
+
await TemplateUtils_1.instantiateTemplate(path_1.default.join(context.templatesRoot, 'tex', 'plot_query_times.tex'), path_1.default.join(context.cwd, `${argv.name}.tex`), Object.assign({ LEGEND: experimentNames.map(name => name.replace(/_/gu, '\\_')).join(','), LINES: lines, COLOR_SCHEME: colorScheme, LEGEND_POS: argv.legendPos }, argv.maxY ? { Y_MAX: `ymax=${argv.maxY},` } : {}), contents => {
|
|
139
|
+
if (!argv.legend) {
|
|
140
|
+
contents = contents.replace(/^\\legend.*$/u, '');
|
|
141
|
+
}
|
|
142
|
+
if (argv.logY) {
|
|
143
|
+
contents = contents.replace(/ymin=0,/u, 'ymode=log,log origin=infty,');
|
|
144
|
+
}
|
|
145
|
+
return contents;
|
|
146
|
+
});
|
|
147
|
+
// Render CSV from TeX
|
|
148
|
+
if (argv.svg) {
|
|
149
|
+
await TexUtils_1.toSvg(argv, context);
|
|
150
|
+
}
|
|
151
|
+
}));
|
|
152
|
+
exports.handler = handler;
|
|
153
|
+
//# sourceMappingURL=CommandQueryTimes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandQueryTimes.js","sourceRoot":"","sources":["CommandQueryTimes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB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AAI,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,KAAK,EAAE,sBAAsB,CAAC,EAC/D,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,MAAM,CAAC,kBAExC,MAAM,EAAE,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EACzE,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,WAAW,EACzB,UAAU,EAAE,IAAI,CAAC,SAAS,IACvB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,GAErD,QAAQ,CAAC,EAAE;QACT,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;SAClD;QACD,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,6BAA6B,CAAC,CAAC;SACxE;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,CACF,CAAC;IAEF,sBAAsB;IACtB,IAAI,IAAI,CAAC,GAAG,EAAE;QACZ,MAAM,gBAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KAC5B;AACH,CAAC,CAAC,CAAC,CAAC;AAlFO,QAAA,OAAO,WAkFd","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 { getColorScheme, getExperimentNames, handleCsvFile, toSvg } from './TexUtils';\n\nexport const command = 'queryTimes <query> <experiment-dir...>';\nexport const desc = 'Plot the query result arrival times from the given experiments';\nexport const builder = (yargs: Argv<any>): Argv<any> =>\n yargs\n .options({\n name: {\n type: 'string',\n alias: 'n',\n describe: 'Custom output file name',\n default: 'query_times',\n },\n color: {\n type: 'string',\n alias: 'c',\n describe: 'Color scheme name from colorbrewer2.org',\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 svg: {\n type: 'boolean',\n describe: 'If the tex file should be converted to svg via the tex2svg command',\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 let query: string = argv.query;\n let id = '0';\n const { experimentDirectories, experimentNames, experimentIds } = getExperimentNames(argv);\n const colorScheme = getColorScheme(argv, experimentDirectories);\n\n // Determine optional query id\n const dotPos = query.indexOf('.');\n if (dotPos >= 0) {\n id = query.slice(dotPos + 1, query.length);\n query = query.slice(0, Math.max(0, dotPos));\n }\n\n // Load query times from CSV files\n const resultsArrivalTimes: Record<string, string>[] = [];\n for (const [ experimentId, experimentDirectory ] of experimentDirectories.entries()) {\n // Read CSV file\n let foundQuery = false;\n await handleCsvFile(experimentDirectory, argv, data => {\n if (!foundQuery && data.name === query && (!id || data.id === id)) {\n foundQuery = true;\n const times: string[] = data.timestamps.split(/[ ,]/u);\n for (const [ i, time ] of times.entries()) {\n if (i >= resultsArrivalTimes.length) {\n resultsArrivalTimes.push({});\n }\n resultsArrivalTimes[i][experimentId] = time;\n }\n }\n });\n }\n\n // Write output CSV file\n const csvOutputStream = fs.createWriteStream(Path.join(context.cwd, `${argv.name}.csv`));\n csvOutputStream.write(`${experimentNames.join(';')}\\n`);\n for (const resultArrivalTimes of resultsArrivalTimes) {\n let first = true;\n for (const experimentId of experimentIds) {\n if (first) {\n first = false;\n } else {\n csvOutputStream.write(`;`);\n }\n csvOutputStream.write(`${resultArrivalTimes[experimentId] || ''}`);\n }\n csvOutputStream.write(`\\n`);\n }\n csvOutputStream.close();\n\n // Prepare bar lines\n const lines = experimentNames\n .map(name => `\\\\addplot+[mark=none] table [y expr=\\\\coordindex+1, x=${name}, col sep=semicolon]{\"${argv.name}.csv\"};`)\n .join('\\n');\n\n // Instantiate template\n await instantiateTemplate(\n Path.join(context.templatesRoot, 'tex', 'plot_query_times.tex'),\n Path.join(context.cwd, `${argv.name}.tex`),\n {\n LEGEND: experimentNames.map(name => name.replace(/_/gu, '\\\\_')).join(','),\n LINES: lines,\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.*$/u, '');\n }\n if (argv.logY) {\n contents = contents.replace(/ymin=0,/u, 'ymode=log,log origin=infty,');\n }\n return contents;\n },\n );\n\n // Render CSV from TeX\n if (argv.svg) {\n await toSvg(argv, context);\n }\n }));\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ITaskContext } from '../../ITaskContext';
|
|
2
|
+
/**
|
|
3
|
+
* Determine experiment labels
|
|
4
|
+
* @param argv CLI args
|
|
5
|
+
*/
|
|
6
|
+
export declare function getExperimentNames(argv: Record<string, any>): {
|
|
7
|
+
experimentDirectories: string[];
|
|
8
|
+
experimentNames: string[];
|
|
9
|
+
experimentIds: number[];
|
|
10
|
+
};
|
|
11
|
+
export declare function getQueryNames(queryNames: string[], argv: Record<string, any>): string[];
|
|
12
|
+
export declare function relabelQueryNames<T>(record: Record<string, T>, queryNames: string[]): Record<string, T>;
|
|
13
|
+
export declare function calcAverage(data: number[]): number;
|
|
14
|
+
export declare function calcMedian(data: number[]): number;
|
|
15
|
+
export declare function calcSum(data: number[]): number;
|
|
16
|
+
/**
|
|
17
|
+
* Read a CSV file and handle each row.
|
|
18
|
+
* @param experimentDirectory An experiment directory.
|
|
19
|
+
* @param argv CLI args
|
|
20
|
+
* @param handler A callback for each row.
|
|
21
|
+
*/
|
|
22
|
+
export declare function handleCsvFile(experimentDirectory: string, argv: Record<string, any>, handler: (data: any) => void): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Determine the color scheme.
|
|
25
|
+
* @param argv CLI args
|
|
26
|
+
* @param experimentDirectories The array of experiment directories.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getColorScheme(argv: Record<string, any>, experimentDirectories: string[]): string;
|
|
29
|
+
/**
|
|
30
|
+
* Create an SVG file from a TeX file by invoking 'tex2svg'.
|
|
31
|
+
* @param argv CLI args
|
|
32
|
+
* @param context The task context.
|
|
33
|
+
*/
|
|
34
|
+
export declare function toSvg(argv: Record<string, any>, context: ITaskContext): Promise<void>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.toSvg = exports.getColorScheme = exports.handleCsvFile = exports.calcSum = exports.calcMedian = exports.calcAverage = exports.relabelQueryNames = exports.getQueryNames = exports.getExperimentNames = void 0;
|
|
26
|
+
const fs_1 = __importDefault(require("fs"));
|
|
27
|
+
const path_1 = __importDefault(require("path"));
|
|
28
|
+
const spawn = __importStar(require("cross-spawn"));
|
|
29
|
+
const csv_parse_1 = __importDefault(require("csv-parse"));
|
|
30
|
+
const ErrorHandled_1 = require("../../ErrorHandled");
|
|
31
|
+
/**
|
|
32
|
+
* Determine experiment labels
|
|
33
|
+
* @param argv CLI args
|
|
34
|
+
*/
|
|
35
|
+
function getExperimentNames(argv) {
|
|
36
|
+
const experimentDirectories = argv.experimentDir;
|
|
37
|
+
let experimentNames = experimentDirectories.map((dir, index) => {
|
|
38
|
+
const lastSlash = dir.lastIndexOf(path_1.default.sep);
|
|
39
|
+
if (lastSlash >= 0) {
|
|
40
|
+
dir = dir.slice(lastSlash + 1);
|
|
41
|
+
}
|
|
42
|
+
if (!dir) {
|
|
43
|
+
return `experiment_${index}`;
|
|
44
|
+
}
|
|
45
|
+
return dir;
|
|
46
|
+
});
|
|
47
|
+
if (argv.overrideCombinationLabels) {
|
|
48
|
+
const overrideCombinationLabels = argv.overrideCombinationLabels.split(',');
|
|
49
|
+
if (overrideCombinationLabels.length !== experimentNames.length) {
|
|
50
|
+
throw new Error(`Invalid combination labels override, expected ${experimentNames.length} labels while ${overrideCombinationLabels.length} where given`);
|
|
51
|
+
}
|
|
52
|
+
experimentNames = overrideCombinationLabels;
|
|
53
|
+
}
|
|
54
|
+
const experimentIds = experimentNames.map((name, id) => id);
|
|
55
|
+
return {
|
|
56
|
+
experimentDirectories,
|
|
57
|
+
experimentNames,
|
|
58
|
+
experimentIds,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
exports.getExperimentNames = getExperimentNames;
|
|
62
|
+
function getQueryNames(queryNames, argv) {
|
|
63
|
+
if (argv.overrideQueryLabels) {
|
|
64
|
+
const overrideQueryLabels = argv.overrideQueryLabels.split(',');
|
|
65
|
+
if (overrideQueryLabels.length !== queryNames.length) {
|
|
66
|
+
throw new Error(`Invalid query labels override, expected ${queryNames.length} labels while ${overrideQueryLabels.length} where given`);
|
|
67
|
+
}
|
|
68
|
+
queryNames = overrideQueryLabels;
|
|
69
|
+
}
|
|
70
|
+
return queryNames;
|
|
71
|
+
}
|
|
72
|
+
exports.getQueryNames = getQueryNames;
|
|
73
|
+
function relabelQueryNames(record, queryNames) {
|
|
74
|
+
for (const [i, queryNameOld] of Object.keys(record).entries()) {
|
|
75
|
+
const averages = record[queryNameOld];
|
|
76
|
+
delete record[queryNameOld];
|
|
77
|
+
record[queryNames[i]] = averages;
|
|
78
|
+
}
|
|
79
|
+
return record;
|
|
80
|
+
}
|
|
81
|
+
exports.relabelQueryNames = relabelQueryNames;
|
|
82
|
+
function calcAverage(data) {
|
|
83
|
+
return data.reduce((sum, current) => sum + current) / data.length;
|
|
84
|
+
}
|
|
85
|
+
exports.calcAverage = calcAverage;
|
|
86
|
+
function calcMedian(data) {
|
|
87
|
+
data = [...data].sort((left, right) => left - right);
|
|
88
|
+
return data[Math.floor(data.length / 2)];
|
|
89
|
+
}
|
|
90
|
+
exports.calcMedian = calcMedian;
|
|
91
|
+
function calcSum(data) {
|
|
92
|
+
return data.reduce((sum, current) => sum + current);
|
|
93
|
+
}
|
|
94
|
+
exports.calcSum = calcSum;
|
|
95
|
+
/**
|
|
96
|
+
* Read a CSV file and handle each row.
|
|
97
|
+
* @param experimentDirectory An experiment directory.
|
|
98
|
+
* @param argv CLI args
|
|
99
|
+
* @param handler A callback for each row.
|
|
100
|
+
*/
|
|
101
|
+
async function handleCsvFile(experimentDirectory, argv, handler) {
|
|
102
|
+
const csvFile = path_1.default.join(experimentDirectory, argv.inputName);
|
|
103
|
+
await new Promise((resolve, reject) => {
|
|
104
|
+
const parser = csv_parse_1.default({ delimiter: argv.inputDelimiter, columns: true });
|
|
105
|
+
parser.on('data', handler);
|
|
106
|
+
parser.on('error', reject);
|
|
107
|
+
parser.on('end', resolve);
|
|
108
|
+
fs_1.default.createReadStream(csvFile).pipe(parser);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
exports.handleCsvFile = handleCsvFile;
|
|
112
|
+
/**
|
|
113
|
+
* Determine the color scheme.
|
|
114
|
+
* @param argv CLI args
|
|
115
|
+
* @param experimentDirectories The array of experiment directories.
|
|
116
|
+
*/
|
|
117
|
+
function getColorScheme(argv, experimentDirectories) {
|
|
118
|
+
let colorScheme;
|
|
119
|
+
if (argv.color) {
|
|
120
|
+
colorScheme = argv.color;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
// We only allow even indexes, as uneven spectral schemes have a yellow tint that is hard to read on screens
|
|
124
|
+
const colorSchemeIndex = Math.max(3, (Math.round(experimentDirectories.length + 2 - 1) / 2) * 2);
|
|
125
|
+
colorScheme = `Spectral-${colorSchemeIndex}`;
|
|
126
|
+
}
|
|
127
|
+
return colorScheme;
|
|
128
|
+
}
|
|
129
|
+
exports.getColorScheme = getColorScheme;
|
|
130
|
+
/**
|
|
131
|
+
* Create an SVG file from a TeX file by invoking 'tex2svg'.
|
|
132
|
+
* @param argv CLI args
|
|
133
|
+
* @param context The task context.
|
|
134
|
+
*/
|
|
135
|
+
async function toSvg(argv, context) {
|
|
136
|
+
const { error, status, stdout, stderr } = spawn.sync('tex2svg', [`${argv.name}.tex`], {
|
|
137
|
+
stdio: 'pipe',
|
|
138
|
+
encoding: 'utf8',
|
|
139
|
+
cwd: context.cwd,
|
|
140
|
+
});
|
|
141
|
+
if (error) {
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
if (status !== 0) {
|
|
145
|
+
throw new ErrorHandled_1.ErrorHandled(`tex2svg failed}:\n${stdout + stderr}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.toSvg = toSvg;
|
|
149
|
+
//# sourceMappingURL=TexUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TexUtils.js","sourceRoot":"","sources":["TexUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,mDAAqC;AACrC,0DAA8B;AAC9B,qDAAkD;AAGlD;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,IAAyB;IAK1D,MAAM,qBAAqB,GAAa,IAAI,CAAC,aAAa,CAAC;IAC3D,IAAI,eAAe,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAC7D,MAAM,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC,cAAI,CAAC,GAAG,CAAC,CAAC;QAC5C,IAAI,SAAS,IAAI,CAAC,EAAE;YAClB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;SAChC;QACD,IAAI,CAAC,GAAG,EAAE;YACR,OAAO,cAAc,KAAK,EAAE,CAAC;SAC9B;QACD,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;IAEH,IAAI,IAAI,CAAC,yBAAyB,EAAE;QAClC,MAAM,yBAAyB,GAAG,IAAI,CAAC,yBAAyB,CAAC,KAAK,C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AC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC;AAdD,sCAcC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAyB,EAAE,qBAA+B;IACvF,IAAI,WAAmB,CAAC;IACxB,IAAI,IAAI,CAAC,KAAK,EAAE;QACd,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC;KAC1B;SAAM;QACL,4GAA4G;QAC5G,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACjG,WAAW,GAAG,YAAY,gBAAgB,EAAE,CAAC;KAC9C;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAVD,wCAUC;AAED;;;;GAIG;AACI,KAAK,UAAU,KAAK,CAAC,IAAyB,EAAE,OAAqB;IAC1E,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,CAAE,GAAG,IAAI,CAAC,IAAI,MAAM,CAAE,EAAE;QACtF,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,MAAM;QAChB,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC,CAAC;IACH,IAAI,KAAK,EAAE;QACT,MAAM,KAAK,CAAC;KACb;IACD,IAAI,MAAM,KAAK,CAAC,EAAE;QAChB,MAAM,IAAI,2BAAY,CAAC,qBAAqB,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;KAChE;AACH,CAAC;AAZD,sBAYC","sourcesContent":["import fs from 'fs';\nimport Path from 'path';\nimport * as spawn from 'cross-spawn';\nimport parse from 'csv-parse';\nimport { ErrorHandled } from '../../ErrorHandled';\nimport type { ITaskContext } from '../../ITaskContext';\n\n/**\n * Determine experiment labels\n * @param argv CLI args\n */\nexport function getExperimentNames(argv: Record<string, any>): {\n experimentDirectories: string[];\n experimentNames: string[];\n experimentIds: number[];\n} {\n const experimentDirectories: string[] = argv.experimentDir;\n let experimentNames = experimentDirectories.map((dir, index) => {\n const lastSlash = dir.lastIndexOf(Path.sep);\n if (lastSlash >= 0) {\n dir = dir.slice(lastSlash + 1);\n }\n if (!dir) {\n return `experiment_${index}`;\n }\n return dir;\n });\n\n if (argv.overrideCombinationLabels) {\n const overrideCombinationLabels = argv.overrideCombinationLabels.split(',');\n if (overrideCombinationLabels.length !== experimentNames.length) {\n throw new Error(`Invalid combination labels override, expected ${experimentNames.length} labels while ${overrideCombinationLabels.length} where given`);\n }\n experimentNames = overrideCombinationLabels;\n }\n\n const experimentIds = experimentNames.map((name, id) => id);\n\n return {\n experimentDirectories,\n experimentNames,\n experimentIds,\n };\n}\n\nexport function getQueryNames(queryNames: string[], argv: Record<string, any>): string[] {\n if (argv.overrideQueryLabels) {\n const overrideQueryLabels: string[] = argv.overrideQueryLabels.split(',');\n if (overrideQueryLabels.length !== queryNames.length) {\n throw new Error(`Invalid query labels override, expected ${queryNames.length} labels while ${overrideQueryLabels.length} where given`);\n }\n queryNames = overrideQueryLabels;\n }\n return queryNames;\n}\n\nexport function relabelQueryNames<T>(record: Record<string, T>, queryNames: string[]): Record<string, T> {\n for (const [ i, queryNameOld ] of Object.keys(record).entries()) {\n const averages = record[queryNameOld];\n delete record[queryNameOld];\n record[queryNames[i]] = averages;\n }\n return record;\n}\n\nexport function calcAverage(data: number[]): number {\n return data.reduce((sum, current) => sum + current) / data.length;\n}\n\nexport function calcMedian(data: number[]): number {\n data = [ ...data ].sort((left, right) => left - right);\n return data[Math.floor(data.length / 2)];\n}\n\nexport function calcSum(data: number[]): number {\n return data.reduce((sum, current) => sum + current);\n}\n\n/**\n * Read a CSV file and handle each row.\n * @param experimentDirectory An experiment directory.\n * @param argv CLI args\n * @param handler A callback for each row.\n */\nexport async function handleCsvFile(\n experimentDirectory: string,\n argv: Record<string, any>,\n handler: (data: any) => void,\n): Promise<void> {\n const csvFile = Path.join(experimentDirectory, argv.inputName);\n await new Promise((resolve, reject) => {\n const parser = parse({ delimiter: argv.inputDelimiter, columns: true });\n parser.on('data', handler);\n parser.on('error', reject);\n parser.on('end', resolve);\n\n fs.createReadStream(csvFile).pipe(parser);\n });\n}\n\n/**\n * Determine the color scheme.\n * @param argv CLI args\n * @param experimentDirectories The array of experiment directories.\n */\nexport function getColorScheme(argv: Record<string, any>, experimentDirectories: string[]): string {\n let colorScheme: string;\n if (argv.color) {\n colorScheme = argv.color;\n } else {\n // We only allow even indexes, as uneven spectral schemes have a yellow tint that is hard to read on screens\n const colorSchemeIndex = Math.max(3, (Math.round(experimentDirectories.length + 2 - 1) / 2) * 2);\n colorScheme = `Spectral-${colorSchemeIndex}`;\n }\n return colorScheme;\n}\n\n/**\n * Create an SVG file from a TeX file by invoking 'tex2svg'.\n * @param argv CLI args\n * @param context The task context.\n */\nexport async function toSvg(argv: Record<string, any>, context: ITaskContext): Promise<void> {\n const { error, status, stdout, stderr } = spawn.sync('tex2svg', [ `${argv.name}.tex` ], {\n stdio: 'pipe',\n encoding: 'utf8',\n cwd: context.cwd,\n });\n if (error) {\n throw error;\n }\n if (status !== 0) {\n throw new ErrorHandled(`tex2svg failed}:\\n${stdout + stderr}`);\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ICorrectnessChecker } from './ICorrectnessChecker';
|
|
2
|
+
export declare class CorrectnessCheckerQueries implements ICorrectnessChecker {
|
|
3
|
+
private readonly expectedCardinality;
|
|
4
|
+
constructor(expectedCardinality: Record<string, number>);
|
|
5
|
+
getCorrectness(experimentId: number, query: string, actualCardinality: number): number;
|
|
6
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CorrectnessCheckerQueries = void 0;
|
|
4
|
+
class CorrectnessCheckerQueries {
|
|
5
|
+
constructor(expectedCardinality) {
|
|
6
|
+
this.expectedCardinality = expectedCardinality;
|
|
7
|
+
}
|
|
8
|
+
getCorrectness(experimentId, query, actualCardinality) {
|
|
9
|
+
return actualCardinality / this.expectedCardinality[query];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.CorrectnessCheckerQueries = CorrectnessCheckerQueries;
|
|
13
|
+
//# sourceMappingURL=CorrectnessCheckerQueries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CorrectnessCheckerQueries.js","sourceRoot":"","sources":["CorrectnessCheckerQueries.ts"],"names":[],"mappings":";;;AAEA,MAAa,yBAAyB;IACpC,YACmB,mBAA2C;QAA3C,wBAAmB,GAAnB,mBAAmB,CAAwB;IAC3D,CAAC;IAEG,cAAc,CAAC,YAAoB,EAAE,KAAa,EAAE,iBAAyB;QAClF,OAAO,iBAAiB,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;CACF;AARD,8DAQC","sourcesContent":["import type { ICorrectnessChecker } from './ICorrectnessChecker';\n\nexport class CorrectnessCheckerQueries implements ICorrectnessChecker {\n public constructor(\n private readonly expectedCardinality: Record<string, number>,\n ) {}\n\n public getCorrectness(experimentId: number, query: string, actualCardinality: number): number {\n return actualCardinality / this.expectedCardinality[query];\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.constructCorrectnessChecker = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const CorrectnessCheckerQueries_1 = require("./CorrectnessCheckerQueries");
|
|
6
|
+
function constructCorrectnessChecker(correctnessReference) {
|
|
7
|
+
const data = JSON.parse(fs_1.readFileSync(correctnessReference, 'utf8'));
|
|
8
|
+
if (data.type === 'queries') {
|
|
9
|
+
return new CorrectnessCheckerQueries_1.CorrectnessCheckerQueries(data.queries);
|
|
10
|
+
}
|
|
11
|
+
throw new Error(`Unsupported correctness reference with type '${data.type}'`);
|
|
12
|
+
}
|
|
13
|
+
exports.constructCorrectnessChecker = constructCorrectnessChecker;
|
|
14
|
+
//# sourceMappingURL=CorrectnessCheckerUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CorrectnessCheckerUtils.js","sourceRoot":"","sources":["CorrectnessCheckerUtils.ts"],"names":[],"mappings":";;;AAAA,2BAAkC;AAClC,2EAAwE;AAGxE,SAAgB,2BAA2B,CAAC,oBAA4B;IACtE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAY,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC,CAAC;IACpE,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;QAC3B,OAAO,IAAI,qDAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KACpD;IACD,MAAM,IAAI,KAAK,CAAC,gDAAgD,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;AAChF,CAAC;AAND,kEAMC","sourcesContent":["import { readFileSync } from 'fs';\nimport { CorrectnessCheckerQueries } from './CorrectnessCheckerQueries';\nimport type { ICorrectnessChecker } from './ICorrectnessChecker';\n\nexport function constructCorrectnessChecker(correctnessReference: string): ICorrectnessChecker {\n const data = JSON.parse(readFileSync(correctnessReference, 'utf8'));\n if (data.type === 'queries') {\n return new CorrectnessCheckerQueries(data.queries);\n }\n throw new Error(`Unsupported correctness reference with type '${data.type}'`);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ICorrectnessChecker.js","sourceRoot":"","sources":["ICorrectnessChecker.ts"],"names":[],"mappings":"","sourcesContent":["export interface ICorrectnessChecker {\n getCorrectness: (experimentId: number, query: string, actualCardinality: number) => number;\n}\n"]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
\documentclass[preview]{standalone}
|
|
2
|
+
\usepackage[utf8]{inputenc}
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
% Page setup
|
|
6
|
+
\usepackage{amsmath}
|
|
7
|
+
|
|
8
|
+
% Typography
|
|
9
|
+
\usepackage[scaled]{helvet}
|
|
10
|
+
\let\familydefault\sfdefault
|
|
11
|
+
\usepackage{sansmath}
|
|
12
|
+
\sansmath
|
|
13
|
+
|
|
14
|
+
\usepackage[usenames,svgnames]{xcolor}
|
|
15
|
+
\usepackage{tikz,pgfplots}
|
|
16
|
+
\usetikzlibrary{arrows,positioning,shapes,calc,intersections,patterns}
|
|
17
|
+
\usepgfplotslibrary{colorbrewer}
|
|
18
|
+
|
|
19
|
+
\newcommand\plotfontsize{\fontsize{9}{9}\selectfont}
|
|
20
|
+
\pgfplotsset{compat=1.9,
|
|
21
|
+
axis lines=left,
|
|
22
|
+
every axis/.append style={
|
|
23
|
+
font=\plotfontsize,
|
|
24
|
+
},
|
|
25
|
+
label style={
|
|
26
|
+
font=\plotfontsize\bfseries,
|
|
27
|
+
},
|
|
28
|
+
tick label style={
|
|
29
|
+
font=\plotfontsize\bfseries,
|
|
30
|
+
},
|
|
31
|
+
xtick style={
|
|
32
|
+
draw=none,
|
|
33
|
+
},
|
|
34
|
+
legend cell align=left,
|
|
35
|
+
legend style={
|
|
36
|
+
/tikz/every even column/.append style={column sep=.3em},
|
|
37
|
+
draw=none, fill=none,
|
|
38
|
+
inner sep=0pt, outer sep=0pt,
|
|
39
|
+
anchor=north east,
|
|
40
|
+
at={(%LEGEND_POS%)},
|
|
41
|
+
text height=3pt,
|
|
42
|
+
},
|
|
43
|
+
log base 10 number format code/.code={%
|
|
44
|
+
$\pgfmathparse{10^(#1)}\pgfmathprintnumber{\pgfmathresult}$%
|
|
45
|
+
},
|
|
46
|
+
cycle list/%COLOR_SCHEME%,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
\begin{document}
|
|
50
|
+
\pagestyle{empty}
|
|
51
|
+
|
|
52
|
+
\newenvironment{resultAxis}{
|
|
53
|
+
\begin{axis}[
|
|
54
|
+
xtick=data,
|
|
55
|
+
width=%WIDTH%pt,
|
|
56
|
+
height=96pt,
|
|
57
|
+
ymin=0,
|
|
58
|
+
%Y_MAX%
|
|
59
|
+
bar width=2.75pt,
|
|
60
|
+
enlarge x limits={abs=%X_LIMITS%pt},
|
|
61
|
+
symbolic x coords={%QUERIES%},
|
|
62
|
+
% Don't show axis exponent
|
|
63
|
+
ytick scale label code/.code={},
|
|
64
|
+
scaled y ticks=false,
|
|
65
|
+
x axis line style={draw=none},
|
|
66
|
+
% reverse legend,
|
|
67
|
+
scale only axis,
|
|
68
|
+
clip=false,
|
|
69
|
+
axis on top,
|
|
70
|
+
area legend,
|
|
71
|
+
ylabel={Duration (s)},
|
|
72
|
+
cycle list name=%COLOR_SCHEME%,
|
|
73
|
+
every axis plot/.append style={
|
|
74
|
+
draw=none,
|
|
75
|
+
fill,
|
|
76
|
+
},
|
|
77
|
+
error bars/error bar style={
|
|
78
|
+
black,
|
|
79
|
+
dashed,
|
|
80
|
+
},
|
|
81
|
+
error bars/error mark options={
|
|
82
|
+
line width=1pt,mark size=0.5pt,rotate=90
|
|
83
|
+
},
|
|
84
|
+
error bars/y dir=both,
|
|
85
|
+
error bars/y explicit,
|
|
86
|
+
]
|
|
87
|
+
}{\end{axis}}
|
|
88
|
+
\begin{tikzpicture}
|
|
89
|
+
\begin{resultAxis}
|
|
90
|
+
%BARS%
|
|
91
|
+
\legend{%LEGEND%}
|
|
92
|
+
\end{resultAxis}
|
|
93
|
+
\end{tikzpicture}
|
|
94
|
+
\end{document}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
\documentclass[preview]{standalone}
|
|
2
|
+
\usepackage[utf8]{inputenc}
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
% Page setup
|
|
6
|
+
\usepackage{amsmath}
|
|
7
|
+
|
|
8
|
+
% Typography
|
|
9
|
+
\usepackage[scaled]{helvet}
|
|
10
|
+
\let\familydefault\sfdefault
|
|
11
|
+
\usepackage{sansmath}
|
|
12
|
+
\sansmath
|
|
13
|
+
|
|
14
|
+
\usepackage[usenames,svgnames]{xcolor}
|
|
15
|
+
\usepackage{tikz,pgfplots}
|
|
16
|
+
\usetikzlibrary{arrows,positioning,shapes,calc,intersections}
|
|
17
|
+
\usepgfplotslibrary{colorbrewer}
|
|
18
|
+
|
|
19
|
+
\newcommand\plotfontsize{\fontsize{9}{9}\selectfont}
|
|
20
|
+
\pgfplotsset{compat=1.9,
|
|
21
|
+
axis lines=left,
|
|
22
|
+
every axis/.append style={
|
|
23
|
+
font=\plotfontsize,
|
|
24
|
+
},
|
|
25
|
+
label style={
|
|
26
|
+
font=\plotfontsize\bfseries,
|
|
27
|
+
},
|
|
28
|
+
tick label style={
|
|
29
|
+
font=\plotfontsize\bfseries,
|
|
30
|
+
},
|
|
31
|
+
legend cell align=left,
|
|
32
|
+
legend style={
|
|
33
|
+
/tikz/every even column/.append style={column sep=.3em},
|
|
34
|
+
draw=none, fill=none,
|
|
35
|
+
inner sep=0pt, outer sep=0pt,
|
|
36
|
+
anchor=north east,
|
|
37
|
+
text height=3pt,
|
|
38
|
+
},
|
|
39
|
+
log base 10 number format code/.code={%
|
|
40
|
+
$\pgfmathparse{10^(#1)}\pgfmathprintnumber{\pgfmathresult}$%
|
|
41
|
+
},
|
|
42
|
+
cycle list/%COLOR_SCHEME%,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
\begin{document}
|
|
46
|
+
\pagestyle{empty}
|
|
47
|
+
|
|
48
|
+
\newenvironment{resultAxis}{
|
|
49
|
+
\begin{axis}[
|
|
50
|
+
width=350pt,
|
|
51
|
+
height=96pt,
|
|
52
|
+
xmin=0,
|
|
53
|
+
ymin=0,
|
|
54
|
+
%Y_MAX%
|
|
55
|
+
% Don't show axis exponent
|
|
56
|
+
ytick scale label code/.code={},
|
|
57
|
+
scaled y ticks=false,
|
|
58
|
+
x axis line style=-,
|
|
59
|
+
scale only axis,
|
|
60
|
+
clip=false,
|
|
61
|
+
axis on top,
|
|
62
|
+
xlabel={Time (ms)},
|
|
63
|
+
ylabel={Query results},
|
|
64
|
+
cycle list name=%COLOR_SCHEME%,
|
|
65
|
+
every axis plot/.append style={line width=1pt},
|
|
66
|
+
legend style={at={(1,0)},anchor=south east}
|
|
67
|
+
]
|
|
68
|
+
}{\end{axis}}
|
|
69
|
+
\begin{tikzpicture}
|
|
70
|
+
\begin{resultAxis}
|
|
71
|
+
%LINES%
|
|
72
|
+
\legend{%LEGEND%}
|
|
73
|
+
\end{resultAxis}
|
|
74
|
+
\end{tikzpicture}
|
|
75
|
+
\end{document}
|