Skip to content

Commit

Permalink
do_regtest: Add timings report
Browse files Browse the repository at this point in the history
  • Loading branch information
oschuett committed Apr 4, 2019
1 parent 7ea2c6e commit 55cf030
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/regtesting/do_regtest
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ error_description_file=${dir_out}/error_summary
memory_description_file=${dir_out}/memory_summary
>${memory_description_file}
summary=${dir_out}/summary.txt
timings=${dir_out}/timings.txt
printf "Summary of the regression tester run from ${date_stamp} using ${dir_triplet} ${cp2k_version} \n" >${summary}


Expand Down Expand Up @@ -528,6 +529,7 @@ function run_regtest_dir() {
fi

printf " %-50s %25s %20s %s\n" "${input_file}" "${test_value}" "${this_test}" "${leak_marker}" >> ${dir_out}/status/REGTEST_TASK_TESTS-$task
printf "%7.2f %s\n" "${timing}" "${dir}/${input_file}" >> "${timings}"
done

t2=`date +%s`
Expand Down Expand Up @@ -626,6 +628,7 @@ function run_unittest() {
echo "${n_runtime_error} 0 ${n_correct} 0 1" > ${dir_out}/status/REGTEST_TASK_RESULT-$task
cat ${dir_out}/status/REGTEST_TASK_TESTS-$task
rm -f ${dir_out}/status/REGTEST_TASK_TESTS-$task ${dir_out}/status/REGTEST_RUNNING-$task
printf "%7.2f %s\n" "${timing}" "UNIT/${dir##*/}" >> "${timings}"
}

###################################################################################
Expand Down Expand Up @@ -1158,6 +1161,8 @@ EOF
cat "${error_description_file}"
echo "--------------------------------------------------------------------------"
file_info
echo "--------------------------------- Timings --------------------------------"
${dir_base}/${cp2k_dir}/tools/regtesting/timings.py "${timings}"
echo "--------------------------------- Summary --------------------------------"
if [[ ${quick} != "quick" ]]; then
printf "Number of COMPILE warns %d\n" ${compile_warnings} | tee -a ${summary}
Expand Down
43 changes: 43 additions & 0 deletions tools/regtesting/timings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# author: Ole Schuett

from __future__ import print_function
import sys
import math

#===============================================================================
def main():
if(len(sys.argv) != 2):
print("Usage: timings.py <timings.txt>")
sys.exit(1)

filename = sys.argv[1]
with open(filename) as fhandle:
timings = sorted(float(line.split()[0]) for line in fhandle.readlines())

print('Plot: name="timings", title="Timings Distribution", ylabel="time [s]"')
tmpl = 'PlotPoint: name="{}th_percentile", plot="timings", label="{}th %ile", y={}, yerr=0.0'
for p in (100, 99, 98, 95, 90, 80):
v = percentile(timings, p / 100.0)
print(tmpl.format(p, p, v))

#===============================================================================
def percentile(values, percent):
k = (len(values)-1) * percent
f = math.floor(k)
c = math.ceil(k)
if f == c:
return values[int(k)]
d0 = values[int(f)] * (c-k)
d1 = values[int(c)] * (k-f)
return d0 + d1

#===============================================================================
if(len(sys.argv)==2 and sys.argv[-1]=="--selftest"):
pass #TODO implement selftest
else:
main()

#EOF

0 comments on commit 55cf030

Please sign in to comment.