7 tmp
= "/tmp/memcpy.tmp."
9 for i
in range(1, len(sys
.argv
)):
11 cached
= True if fn
.startswith('c:') else False
12 if cached
: fn
= fn
[2:]
14 if cached
and os
.path
.exists("%s.%s"%(tmp
, fn
)): pass
15 elif os
.system("./build.sh %s && ./test > %s.%s"%(fn
, tmp
, fn
)):
18 with
open("%s.%s"%(tmp
, fn
), "r") as f
:
19 a
= f
.read().split('\n')
21 if not '\t' in x
: continue
24 if i
== 1: order
.append(n
)
25 candidates
.append(results
)
28 return a
if a
> b
else b
30 col_lengths
= [len(x
) for x
in sys
.argv
]
32 for n
in order
: col_lengths
[0] = max(len(n
), col_lengths
[0])
33 last_n
= order
[len(order
)-1]
34 for i
in range(len(candidates
)):
35 col_lengths
[i
+1] = max(len(candidates
[i
][last_n
]), col_lengths
[i
+1])
37 def fmt(s
, col
, dir=-1):
39 while len(s
) < col_lengths
[col
]: s
= ' ' + s
41 while len(s
) < col_lengths
[col
]: s
= s
+ ' '
44 print ("memcpy speed comparison")
45 print ("CC=%s, OPTS=%s, UNIT=ticks"%( \
46 os
.environ
['CC'] if 'CC' in os
.environ
else 'cc', \
47 os
.environ
['OPTS'] if 'OPTS' in os
.environ
else ''))
49 for i
in range(1, len(fna
)):
50 s
+= " " + fmt(fna
[i
], i
, 1)
56 for i
in range(len(candidates
)): s
+= fmt(candidates
[i
][n
], i
+1) + ' '