Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.

Commit a6abdd2

Browse files
authored
Merge pull request #346 from ndawe/master
update ROOT/root_numpy comparison with latest ROOT
2 parents c1575dd + 786afe4 commit a6abdd2

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

benchmarks/bench_tree2array.pdf

-808 Bytes
Binary file not shown.

benchmarks/bench_tree2array.png

2.27 KB
Loading

benchmarks/bench_tree2array.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from rootpy.io import TemporaryFile
44
import rootpy
5-
from root_numpy import array2tree
5+
from root_numpy import array2tree, tree2array
66
import numpy as np
77
import uuid
88
import random
@@ -27,11 +27,20 @@
2727
def randomword(length):
2828
return ''.join(random.choice(string.lowercase) for i in range(length))
2929

30-
def make_tree(entries, branches=10, dtype=np.double):
30+
def make_tree(entries, branches=1, dtype=np.double):
3131
dtype = np.dtype([(randomword(20), dtype) for idx in range(branches)])
3232
array = np.zeros(entries, dtype=dtype)
3333
return array2tree(array, name=uuid.uuid4().hex)
3434

35+
# warm up
36+
print("warming up... ", end="")
37+
for i in range(30):
38+
tree = make_tree(100, branches=1)
39+
branchname = tree.GetListOfBranches()[0].GetName()
40+
tree2array(tree)
41+
tree.Draw(branchname, "", "goff")
42+
print("done\n")
43+
3544
# time vs entries
3645
num_entries = np.logspace(1, 7, 20, dtype=np.int)
3746
root_numpy_times = []
@@ -73,18 +82,19 @@ def make_tree(entries, branches=10, dtype=np.double):
7382
num_branches = np.linspace(1, 10, 10, dtype=np.int)
7483
root_numpy_times = []
7584
root_times = []
85+
iterations = 10
7686
print("\n{0:>10} {1:<10} {2:<10}".format("branches", "root_numpy", "ROOT"))
7787
for branches in num_branches:
7888
print("{0:>10}".format(branches), end="")
7989
tree = make_tree(1000000, branches=branches)
8090
branchnames = [branch.GetName() for branch in tree.GetListOfBranches()]
8191
branchname = ':'.join(branchnames)
82-
iterations = 5
8392
root_numpy_times.append(
8493
min(timeit.Timer('tree2array(tree)',
8594
setup='from root_numpy import tree2array; from __main__ import tree').repeat(3, iterations)) / iterations)
95+
opt = 'candle' if branches > 1 else ''
8696
root_times.append(
87-
min(timeit.Timer('draw("{0}", "", "goff candle")'.format(branchname),
97+
min(timeit.Timer('draw("{0}", "", "goff {1}")'.format(branchname, opt),
8898
setup='from __main__ import tree; draw = tree.Draw').repeat(3, iterations)) / iterations)
8999
print(" {0:10.5f}".format(root_numpy_times[-1]), end="")
90100
print(" {0:10.5f}".format(root_times[-1]))

benchmarks/sysinfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Get system hardware information
33
http://stackoverflow.com/a/4194146/1002176
44
"""
5-
import cpuinfo
5+
import cpuinfo # pip install --user py-cpuinfo
66
import sys, os, fcntl, struct
77
import pickle
88

0 commit comments

Comments
 (0)