Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# How to generate the benchmarks

$ cd benchmatks
$ ./compile_clang.sh array
$ ./benchmark.sh array # Outputs ./build/benchmarks/array.txt
$ python makereport.py ./build/benchmarks/array.txt > report.txt
$ python render.py report.txt ./images/array
$ python render.py report.txt ../images/array
$ python markdown.py jc::Array array report.txt > benchmarks_array.md

# Benchmarks

* [HashTable](./benchmarks_ht.md)
* [Array](./benchmarks_array.md)
* [Array](./benchmarks_array.md)
2 changes: 1 addition & 1 deletion benchmarks/array/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ typedef struct SValue
typedef valuelarge_t* container_valuelarge_t;

#elif defined(IMPL_JC)
#include <jc/array.h>
#include <jc/cpp/array.h>
#define CONTAINERNAME "jc::Array"
#define SET_CAPACITY(_CONTAINER, _SIZE) (_CONTAINER).SetCapacity(_SIZE)
#define SET_SIZE(_CONTAINER, _SIZE) (_CONTAINER).SetSize(_SIZE)
Expand Down
5 changes: 3 additions & 2 deletions benchmarks/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ function benchmark {
done
}


function benchmark_array {
local SERIES=()
count=100000
Expand All @@ -46,7 +45,9 @@ function benchmark_array {
SERIES+="$count "
((count+=100000))
done
benchmark "stl eastl boost jc carray" "$SERIES"
benchmark "carray stl boost jc" "$SERIES"
}

}

case $TESTCATEGORY in
Expand Down
138 changes: 89 additions & 49 deletions benchmarks/benchmarks_array.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion benchmarks/compile_clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mkdir -p $BUILDDIR
EXTERNALDIR=../../external

EASTL_INCLUDE="${EXTERNALDIR}/EASTL/include"
BOOST_INCLUDE="${EXTERNALDIR}/boost"
BOOST_INCLUDE="${EXTERNALDIR}/boost/libs"

SUFFIX=
DEFINES=
Expand Down
40 changes: 20 additions & 20 deletions benchmarks/makereport.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def convert_time(t, unit):

def parse_log(report, reportpath):
counts = []
with open(reportpath, 'rb') as f:
with open(reportpath, 'rt') as f:
n = -1
iterations = -1
for line in f:
Expand Down Expand Up @@ -70,8 +70,8 @@ def parse_log(report, reportpath):

def collect_table_data(counts, report, tabledata):

for category, tests in report.iteritems():
for testname, results in tests.iteritems():
for category, tests in report.items():
for testname, results in tests.items():
if testname in ['title', 'scale', 'unit']:
continue

Expand All @@ -84,7 +84,7 @@ def collect_table_data(counts, report, tabledata):
tabledata[category][testname]['counts'] = list()
tabledata[category][testname]['counts'].extend(counts)

for name, values in results.iteritems():
for name, values in results.items():
if not name in tabledata[category][testname]:
tabledata[category][testname][name] = list()
if name in ['title', 'scale', 'unit']:
Expand All @@ -96,16 +96,16 @@ def collect_table_data(counts, report, tabledata):
def make_table_report(data):
usediff = False

for category, tests in data.iteritems():
for category, tests in data.items():

totaldiff = 0.0

for testname, results in tests.iteritems():
for testname, results in tests.items():
if testname in ['title', 'scale', 'formatter', 'unit']:
continue

columns = list()
for name, values in results.iteritems():
for name, values in results.items():
if len(values) < len(results['counts']):
values.extend( (len(results['counts']) - len(values)) * [0.0])
columns.append( [name]+values )
Expand All @@ -114,11 +114,11 @@ def make_table_report(data):
scale = tests['scale']
title = tests['title']

matrix = zip(*columns)
matrix = list(zip(*columns))

rows = [list(matrix[0])]
for row in matrix[1:]:
rows.append( [str(row[0])] + map(formatter, map(lambda x: scale * x, row[1:]) ) )
rows.append( [str(row[0])] + list(map(formatter, map(lambda x: scale * x, row[1:]) )) )

lengths = [0] * len(rows[0])
for row in rows:
Expand All @@ -136,10 +136,10 @@ def make_table_report(data):
else:
headersunderline.append( '-' * (length + 2) )

print "## " + title + " " + testname
print ""
print '|' + '|'.join(headers) + '|'
print '|' + '|'.join(headersunderline) + '|'
print("## " + title + " " + testname)
print("")
print('|' + '|'.join(headers) + '|')
print('|' + '|'.join(headersunderline) + '|')

for row in rows[1:]:
values = []
Expand All @@ -148,23 +148,23 @@ def make_table_report(data):
value = v.ljust(length)
values.append( ' ' + value + ' ')

print '|' + '|'.join(values) + '|',
print('|' + '|'.join(values) + '|',)
if not usediff:
print ""
print("")

diff = 0.0
if usediff:
tokens = values[-1].split()
diff = float(tokens[0]) - float(values[-2].split()[0])
print diff, tokens[1]
print(diff, tokens[1])

totaldiff += diff

print ""
print ""
print("")
print("")

if usediff:
print "Total diff:", totaldiff
print("Total diff:", totaldiff)


if __name__ == '__main__':
Expand Down Expand Up @@ -213,4 +213,4 @@ def make_table_report(data):
make_table_report(tabledata)

timeend = time.time()
print "# Report made in %f seconds" % (timeend - timestart)
print("# Report made in %f seconds" % (timeend - timestart))
28 changes: 14 additions & 14 deletions benchmarks/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get_path_from_test_name(category, name):

def get_log(path):
lines = []
with open(path, 'rb') as f:
with open(path, 'rt') as f:
for line in f.readlines():
if line.startswith('# '):
continue
Expand All @@ -46,35 +46,35 @@ def sub(x):
category= sys.argv[2]
log = sys.argv[3]

print "# %s benchmarks" % title
print ""
print "Benchmarks run on a:", get_machine(), " ", get_cpu()
print ""
print("# %s benchmarks" % title)
print("")
print("Benchmarks run on a:", get_machine(), " ", get_cpu() )
print("")

lines = get_log(log)

print "# Images"
print("# Images")

tests = get_tests(lines)
i = 0
for test in tests:
if ('dmHashTable' in test):
continue
if (i % 2) == 0:
print '_\n<br/>'
print('_\n<br/>')
i = i + 1
print '<img src="%s" alt="%s" width="350">' % (get_path_from_test_name(category, test), test)
print('<img src="%s" alt="%s" width="350">' % (get_path_from_test_name(category, test), test))


print ""
print "# Tables"
print ""
print("")
print("# Tables")
print("")

print "### %s" % log
print ""
print("### %s" % log)
print("")
for line in lines:
if 'dmHashTable' in line:
continue
tokens = line.split()
tokens = map(sub, tokens)
print " ".join(tokens)
print(" ".join(tokens))
8 changes: 4 additions & 4 deletions benchmarks/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def convert_time(t, unit):

def parse_log(path):
tests = []
with open(path, 'rb') as f:
with open(path, 'rt') as f:
lines = f.readlines()

headers = None
Expand Down Expand Up @@ -95,7 +95,7 @@ def render_matplotlib(test, outputdir):
bars = []
offset = 0
markers='ov*sxd'
for i, (name, values) in enumerate(test['headers'].iteritems()):
for i, (name, values) in enumerate(test['headers'].items()):
values = [x * scale for x in values]
plt.plot(test['counts'], values, label=name, color=random_color(), marker=markers[i % len(markers)])
offset += bar_width
Expand All @@ -111,7 +111,7 @@ def render_matplotlib(test, outputdir):
plt.savefig(outpath)
plt.close()

print "Wrote", outpath
print("Wrote", outpath)

if __name__ == '__main__':
tests = parse_log(sys.argv[1])
Expand All @@ -123,4 +123,4 @@ def render_matplotlib(test, outputdir):

for test in tests:
render_matplotlib(test, outputdir)


Binary file modified images/array/timings_get_random_large.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/array/timings_get_random_small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/array/timings_push_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/array/timings_sum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading