diff --git a/ci/complexity_measurements/check_for_changes.py b/ci/complexity_measurements/check_for_changes.py new file mode 100644 index 0000000000000000000000000000000000000000..f43396260f1aa9d59380ab88f9f092a824ced62b --- /dev/null +++ b/ci/complexity_measurements/check_for_changes.py @@ -0,0 +1,45 @@ +import argparse +import csv +import sys +import numpy as np + + +THRESH = 0.01 +COLS = [ + [3, 5, 7, 9], # wmops_all + [3,5,7,8,10,12,13,15,17], # ram_all + [3,5,7,9,11,13,15,17,19], # rom_all +] + + +def main(args): + linewise_logfiles = [args.wmops_logfile, args.ram_logfile, args.rom_logfile] + changes_found_linewise = any([check_linewise_logfile(f, c) for f, c in zip(linewise_logfiles, COLS)]) + + if changes_found_linewise: + print("Global max of WMOPS, RAM or ROM changed") + + return int(changes_found_linewise) + + +def check_linewise_logfile(filepath, cols): + with open(filepath) as f: + contents = [line for line in csv.reader(f, delimiter=" ")] + + curr = contents[-1] + prev = contents[-2] + + change_ratios = [abs(float(curr[i]) / float(prev[i]) - 1) > THRESH for i in cols] + changes_found = any(change_ratios) + + return changes_found + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("wmops_logfile") + parser.add_argument("ram_logfile") + parser.add_argument("rom_logfile") + args = parser.parse_args() + + sys.exit(main(args)) diff --git a/ci/complexity_measurements/getWmops.sh b/ci/complexity_measurements/getWmops.sh index 22ca8335fb91db0a057d953d7136732d62f796e9..c069e2d57b16ada134eba8f1fa9a9eaab5f9c2a5 100755 --- a/ci/complexity_measurements/getWmops.sh +++ b/ci/complexity_measurements/getWmops.sh @@ -86,4 +86,9 @@ ${scriptDir}/parseNewsletterRom.py ${wmopsFilenameFlc}_PROM.csv ${wmopsFilenameF # generate java script from database tcsh ${scriptDir}/genWebpageData_Rom.csh ${destDir}/wmops/log_rom_all.txt ${destDir}/wmops/graphs_rom_flc.js Graphs_ROM -exit $ret_val \ No newline at end of file +python3 ${scriptDir}/check_for_changes.py ${destDir}/wmops/log_wmops_all.txt ${destDir}/wmops/log_ram_all.txt ${destDir}/wmops/log_rom_all.txt +if [ "$?" != "0" ]; then + ret_val=1 +fi + +exit $ret_val