Skip to content

Commit d90d6a3

Browse files
committed
Updated scripts
1 parent ac9f3b6 commit d90d6a3

File tree

4 files changed

+109
-54
lines changed

4 files changed

+109
-54
lines changed

output/toCsv.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env python3
2+
3+
import csv
4+
import os
5+
import re
6+
7+
8+
def parseFileInfo(f):
9+
words = f.replace('.txt', '').split('-')
10+
return {
11+
'datatype': words[0],
12+
'command': words[1],
13+
'number': words[2],
14+
'size': words[3]
15+
}
16+
17+
18+
def extractScores(f):
19+
result = {}
20+
with open(f) as fh:
21+
lines = fh.readlines()
22+
summary = False
23+
for l in lines:
24+
if l.startswith("# Run complete. Total time:"):
25+
summary = True
26+
elif summary and not l.startswith('Benchmark'):
27+
values = re.split('\s+', l)
28+
if (len(values) > 3):
29+
name = values[0].split('.')[-1]
30+
score = values[3]
31+
result[name] = score
32+
return result
33+
34+
35+
cwd = os.getcwd()
36+
sheets = {}
37+
for f in os.listdir(cwd):
38+
if os.path.isfile(f) and f.endswith('.txt'):
39+
fileInfo = parseFileInfo(f)
40+
scores = extractScores(f)
41+
42+
sheetName = "{}-{}-{}".format(fileInfo['datatype'],
43+
fileInfo['command'], fileInfo['number'])
44+
if sheetName not in sheets:
45+
sheets[sheetName] = {}
46+
47+
size = fileInfo['size']
48+
for k, v in scores.items():
49+
if k not in sheets[sheetName]:
50+
sheets[sheetName][k] = {}
51+
sheets[sheetName][k][size] = v
52+
53+
54+
for filename, v in sheets.items():
55+
fieldnames = ['Test']
56+
rows = []
57+
for libname, scores in v.items():
58+
row = {}
59+
row['Test'] = libname
60+
for size, score in scores.items():
61+
fieldname = "{}kb (x{})".format(size, size)
62+
if fieldname not in fieldnames:
63+
fieldnames.append(fieldname)
64+
row[fieldname] = float(score) * int(size)
65+
rows.append(row)
66+
67+
if not os.path.exists('csv/'):
68+
os.mkdir('csv')
69+
csvfilename = "csv/{}.csv".format(filename)
70+
with open(csvfilename, 'w', newline='') as csvfile:
71+
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
72+
writer.writeheader()
73+
writer.writerows(rows)

output/toCsv.sh

Lines changed: 0 additions & 26 deletions
This file was deleted.

output/toMd.sh

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,43 @@
1-
#!/bin/bash
2-
set -e
1+
#!/usr/bin/env sh -e
2+
3+
datatypes=$(ls *.txt | cut -d- -f1 | sort | uniq)
34

45
echo $(date +%Y-%m-%d)
56
echo
67

7-
for f in $(ls *.txt); do
8-
fnoxt=${f/.txt/}
9-
name=$(echo $fnoxt | cut -d- -f1)
10-
n=$(echo $fnoxt | cut -d- -f2)
11-
s=$(echo $fnoxt | cut -d- -f3)
128

13-
title=""
14-
case $name in
15-
"deser") title="Deserialization" ;;
16-
"ser") title="Serialization" ;;
17-
*) echo "Unknow name: '$name"; exit 1 ;;
18-
esac
9+
for datatype in $datatypes; do
1910

20-
title="$title - $s KB"
21-
22-
echo "# JMH: $title"
23-
echo
24-
tail -n30 $f | grep -A30 "Benchmark" | sed -E -e 's/± +/±/' | \
25-
awk 'BEGIN { OFS=" | " } { print "",$1,$2,$3,$4,$5,$6,""; if ($1 == "Benchmark") { print "|-----------|------|-----|-------|-------|-------|"; } }' | \
26-
sed -E \
27-
-e 's/^.*databind\.Deserialization\.([a-zA-Z_]+)/| \1\/databind/g' \
28-
-e 's/^.*stream\.Deserialization\.([a-zA-Z_]+)/| \1\/stream/g' \
29-
-e 's/^.*databind\.Serialization\.([a-zA-Z_]+)/| \1\/databind/g' \
30-
-e 's/^.*stream\.Serialization\.([a-zA-Z_]+)/| \1\/stream/g' \
31-
-e 's/\| ± \|/±/g' \
32-
-e 's/^ //g'
11+
echo "# *$datatype* data type"
3312
echo
34-
done
3513

14+
for f in $(ls $datatype-*.txt); do
15+
fnoxt=${f/.txt/}
16+
cmd=$(echo $fnoxt | cut -d- -f2)
17+
n=$(echo $fnoxt | cut -d- -f3)
18+
s=$(echo $fnoxt | cut -d- -f4)
19+
20+
title=""
21+
case $cmd in
22+
"deser") title="Deserialization" ;;
23+
"ser") title="Serialization" ;;
24+
*) echo "Unknow name: '$name"; exit 1 ;;
25+
esac
26+
27+
title="$title - $s KB"
28+
29+
echo "## JMH: $title"
30+
echo
31+
tail -n30 $f | grep -A30 "Benchmark" | sed -E -e 's/± +/±/' | \
32+
awk 'BEGIN { OFS=" | " } { print "",$1,$2,$3,$4,$5,$6,""; if ($1 == "Benchmark") { print "|-----------|------|-----|-------|-------|-------|"; } }' | \
33+
sed -E \
34+
-e 's/^.*databind\.Deserialization\.([a-zA-Z_]+)/| \1\/databind/g' \
35+
-e 's/^.*stream\.Deserialization\.([a-zA-Z_]+)/| \1\/stream/g' \
36+
-e 's/^.*databind\.Serialization\.([a-zA-Z_]+)/| \1\/databind/g' \
37+
-e 's/^.*stream\.Serialization\.([a-zA-Z_]+)/| \1\/stream/g' \
38+
-e 's/\| ± \|/±/g' \
39+
-e 's/^ //g'
40+
echo
41+
done
42+
43+
done

run-everything

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ for datatype in ${DATA_TYPES}; do
1515
for n in ${NUMBERS}; do
1616
for size in ${SIZES}; do
1717
for command in ${COMMANDS}; do
18-
outputFile="output/${command}-${n}-${size}-${datatype}.txt"
18+
outputFile="output/${datatype}-${command}-${n}-${size}.txt"
1919
echo ./run ${command} --number ${n} --size ${size} --datatype ${datatype}
2020
./run ${command} \
2121
--number ${n} \

0 commit comments

Comments
 (0)