Skip to content

Commit fd602fa

Browse files
authored
Merge pull request #1 from trifectatechfoundation/compression-benchmarks
Add graphs for compression benchmarks
2 parents 65e89ae + 31e0aae commit fd602fa

4 files changed

Lines changed: 71 additions & 63 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

script.js

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ function results_over_time(title, lines, group, keys, get_key, key_to_name, coun
9898
let unzipped = {};
9999
for (let i in lines) {
100100
let line = lines[i];
101+
if (!line.bench_groups[group]) {
102+
continue;
103+
}
101104
for (let run of line.bench_groups[group]) {
102105
const key = get_key(run.cmd);
103106
if (!unzipped[key]) {
@@ -277,32 +280,24 @@ function render(data_url, entries, counter) {
277280
const final = entries[entries.length - 1];
278281
const final_c = final.bench_groups["decompress-c"];
279282
const final_rs = final.bench_groups["decompress-rs"];
280-
{
281-
const final = entries[entries.length - 1];
282-
const final_c = final.bench_groups["decompress-c"];
283-
const final_rs = final.bench_groups["decompress-rs"];
284-
const plot = compare_impls_barchart(`c versus rs (decompression, ${counter}, on <a href="https://github.com/trifectatechfoundation/libzstd-rs-sys/commit/${final.commit_hash}">main</a>)`, "zstd-rs", final_c, "libzstd-rs-sys", final_rs, "File", (cmd) => cmd[2].split("/").reverse()[0], counter);
285-
render_plot(plot);
286-
}
287-
// {
288-
// const plot = compare_impls(
289-
// `c versus rs (decompression, ${counter}, on <a href="https://github.com/trifectatechfoundation/libzstd-rs-sys/commit/${final.commit_hash}">main</a>)`,
290-
// "zstd-sys",
291-
// final_c,
292-
// "libzstd-rs-sys",
293-
// final_rs,
294-
// "Input Chunk Size (power of 2 bytes)",
295-
// (cmd) => parseFloat(cmd[2]),
296-
// counter,
297-
// [5, 16],
298-
// );
299-
// render_plot(plot);
300-
// }
283+
const plot = compare_impls_barchart(`c versus rs (decompression, ${counter}, on <a href="https://github.com/trifectatechfoundation/libzstd-rs-sys/commit/${final.commit_hash}">main</a>)`, "zstd-rs", final_c, "libzstd-rs-sys", final_rs, "File", (cmd) => cmd[2].split("/").reverse()[0], counter);
284+
render_plot(plot);
301285
}
302286
{
303-
console.log(entries);
304287
const plot = results_over_time("libzstd-rs-sys decompression", entries, "decompress-rs", ["silesia-small.tar.zst", "re2-exhaustive.txt.zst", "zip64support.tar.zst"], (cmd) => cmd[2], (level) => `${level}`, counter);
305288
render_plot(plot);
306289
}
290+
{
291+
const final = entries[entries.length - 1];
292+
const final_c = final.bench_groups["compress-c"];
293+
const final_rs = final.bench_groups["compress-rs"];
294+
const plot = compare_impls_barchart(`c versus rs (compression, ${counter}, on <a href="https://github.com/trifectatechfoundation/libzstd-rs-sys/commit/${final.commit_hash}">main</a>)`, "zstd-rs", final_c, "libzstd-rs-sys", final_rs, "File", (cmd) => `${cmd[3].split("/").reverse()[0]} (level ${cmd[2]})`, counter);
295+
render_plot(plot);
296+
}
297+
{
298+
const plot = results_over_time("libzstd-rs-sys compression", entries, "compress-rs", ["silesia-small.tar.zst", "re2-exhaustive.txt.zst", "zip64support.tar.zst"]
299+
.flatMap((f) => [1, 3, 19].map((level) => `${f} (level ${level})`)), (cmd) => `${cmd[3]} (level ${cmd[2]})`, (level) => `${level}`, counter);
300+
render_plot(plot);
301+
}
307302
}
308303
main();

script.ts

Lines changed: 52 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@ type MemoryMetric = [number, 'MB'];
33
type TimeMetric = [number, 'ms'];
44

55
type Root = {
6-
commit_hash: string
7-
commit_timestamp: number
8-
timestamp: Timestamp
9-
arch: string
10-
os: string
11-
runner: string
12-
cpu_model: string
13-
bench_groups: {[key: string]: SingleBench[]},
6+
commit_hash: string
7+
commit_timestamp: number
8+
timestamp: Timestamp
9+
arch: string
10+
os: string
11+
runner: string
12+
cpu_model: string
13+
bench_groups: { [key: string]: SingleBench[] },
1414
};
1515

1616
type Timestamp = {
17-
secs_since_epoch: number
18-
nanos_since_epoch: number
17+
secs_since_epoch: number
18+
nanos_since_epoch: number
1919
};
2020

2121
type SingleBench = {
22-
cmd: string[]
23-
counters: Counters
22+
cmd: string[]
23+
counters: Counters
2424
};
2525

2626
type CounterName = "cycles" | "instructions" | "user-time" | "task-clock";
@@ -44,14 +44,14 @@ function counter_to_verb(counter: CounterName) {
4444
}
4545

4646
type Counters = {
47-
[name in CounterName]: Counter
47+
[name in CounterName]: Counter
4848
};
4949

5050
type Counter = {
51-
value: number
52-
variance: number | undefined
53-
repetitions: number | undefined
54-
unit: string
51+
value: number
52+
variance: number | undefined
53+
repetitions: number | undefined
54+
unit: string
5555
};
5656

5757
type Plots = {
@@ -133,10 +133,13 @@ function results_over_time(
133133
},
134134
};
135135

136-
let unzipped: {[level: string]: {x: [], y: number[], error: number[], sha: string[]}} = {};
136+
let unzipped: { [level: string]: { x: [], y: number[], error: number[], sha: string[] } } = {};
137137

138138
for (let i in lines) {
139139
let line = lines[i];
140+
if (!line.bench_groups[group]) {
141+
continue;
142+
}
140143
for (let run of line.bench_groups[group]) {
141144
const key = get_key(run.cmd);
142145

@@ -361,12 +364,6 @@ function render(data_url: string, entries: Root[], counter: CounterName) {
361364
bodyElement.removeChild(bodyElement.firstChild);
362365
}
363366

364-
{
365-
const final = entries[entries.length - 1];
366-
const final_c = final.bench_groups["decompress-c"];
367-
const final_rs = final.bench_groups["decompress-rs"];
368-
369-
370367
{
371368
const final = entries[entries.length - 1];
372369
const final_c = final.bench_groups["decompress-c"];
@@ -384,24 +381,7 @@ function render(data_url: string, entries: Root[], counter: CounterName) {
384381
render_plot(plot);
385382
}
386383

387-
// {
388-
// const plot = compare_impls(
389-
// `c versus rs (decompression, ${counter}, on <a href="https://github.com/trifectatechfoundation/libzstd-rs-sys/commit/${final.commit_hash}">main</a>)`,
390-
// "zstd-sys",
391-
// final_c,
392-
// "libzstd-rs-sys",
393-
// final_rs,
394-
// "Input Chunk Size (power of 2 bytes)",
395-
// (cmd) => parseFloat(cmd[2]),
396-
// counter,
397-
// [5, 16],
398-
// );
399-
// render_plot(plot);
400-
// }
401-
}
402-
403384
{
404-
console.log(entries);
405385
const plot = results_over_time(
406386
"libzstd-rs-sys decompression",
407387
entries,
@@ -413,6 +393,37 @@ function render(data_url: string, entries: Root[], counter: CounterName) {
413393
);
414394
render_plot(plot);
415395
}
396+
397+
{
398+
const final = entries[entries.length - 1];
399+
const final_c = final.bench_groups["compress-c"];
400+
const final_rs = final.bench_groups["compress-rs"];
401+
const plot = compare_impls_barchart(
402+
`c versus rs (compression, ${counter}, on <a href="https://github.com/trifectatechfoundation/libzstd-rs-sys/commit/${final.commit_hash}">main</a>)`,
403+
"zstd-rs",
404+
final_c,
405+
"libzstd-rs-sys",
406+
final_rs,
407+
"File",
408+
(cmd) => `${cmd[3].split("/").reverse()[0]} (level ${cmd[2]})`,
409+
counter,
410+
);
411+
render_plot(plot);
412+
}
413+
414+
{
415+
const plot = results_over_time(
416+
"libzstd-rs-sys compression",
417+
entries,
418+
"compress-rs",
419+
["silesia-small.tar.zst", "re2-exhaustive.txt.zst", "zip64support.tar.zst"]
420+
.flatMap((f) => [1, 3, 19].map((level) => `${f} (level ${level})`)),
421+
(cmd) => `${cmd[3]} (level ${cmd[2]})`,
422+
(level) => `${level}`,
423+
counter,
424+
);
425+
render_plot(plot);
426+
}
416427
}
417428

418429
main();

style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
body {
22
margin: 0 15px;
3+
font-family: sans-serif;
34
}
45

56
#inner {

0 commit comments

Comments
 (0)