Skip to content

Commit

Permalink
Add small cpu time measurement script.
Browse files Browse the repository at this point in the history
  • Loading branch information
scamille committed Apr 12, 2014
1 parent 56f4934 commit ae932ff
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions util_scripts/measure_cpu_time.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import sys,subprocess, math
import numpy as np
import xml.etree.ElementTree as ET

def main():
simc_bin = "../engine/simc.exe"
profile_dir="../profiles/Tier16H/"
name = "Priest_Shadow_T16H"
profile= name + ".simc"
extra_options = ""
threads=1
output_dir = "d:/dev/simc/"

iterations=10000
num_repetitions=10
list_cpu_seconds = np.empty([])

for repetition in range(num_repetitions):
command = "{bin} {profile} {eo} iterations={iterations} threads={threads} output={output} xml={xml}" \
.format( bin=simc_bin, profile=profile_dir+profile, eo=extra_options, iterations=iterations, threads=threads, output=output_dir+profile+".txt", xml=output_dir+profile+".xml" )

subprocess.call( command )

tree = ET.parse(output_dir+profile+".xml")
root = tree.getroot()
cpu_seconds = float(root.find("performance").find("cpu_seconds").text)
print( "Done simulation #{n} of {rep} with iterations={it}: cpu_seconds={t}".format(n=(repetition+1), rep=num_repetitions, it=iterations, t=cpu_seconds ) )
list_cpu_seconds = np.append( list_cpu_seconds, cpu_seconds )

print "mean: %s"%(np.mean(list_cpu_seconds))
print "stddev: %s"%(np.std(list_cpu_seconds))
print "stddev/sqrt(N): %s"%(np.std(list_cpu_seconds)/math.sqrt(num_repetitions))

if __name__ == "__main__":
main()

0 comments on commit ae932ff

Please sign in to comment.