- #print("\nregression: {0} * x + {1}".format(a,b))
- #print("corr_bw = bw_regr/bandwidth= {0}/{1}={2} lat_regr/(lat_xml*links)={3}/({4}*{5}))".format(bw_regr,bandwidth,bw_regr/bandwidth,lat_regr,latency,links))
- # return correction factors c_bw,c_lat
- return bw_regr/bandwidth, lat_regr/(latency*links)
+ print("\nregression: {0} * x + {1}".format(a,b))
+ print("corr_bw = bw_regr/bandwidth= {0}/{1}={2} lat_regr/(lat_xml*links)={3}/({4}*{5}))".format(bw_regr,bandwidth,bw_regr/bandwidth,lat_regr,latency,links))
+ # return linear regression result and corresponding correction factors c_bw,c_lat
+ return a,b, bw_regr/bandwidth, lat_regr/(latency*links)
+
+
+##---------------------------------------------------------------------
+## outputs a C formatted conditional return value for factor
+##
+## param lb lower bound
+## param ub upper bound
+## param lb_included boolean to tell if bound is included (<=) or exclude (<)
+## param ub_included boolean to tell if bound is included (<=) or exclude (<)
+##---------------------------------------------------------------------
+def c_code_print (lb,ub, retval, lb_included, ub_included):
+ lb_cmp = ub_cmp = "<"
+ if lb_included:
+ lb_cmp ="<="
+ if ub_included:
+ ub_cmp ="<="
+
+ ub_kib=ub/1024.
+ lb_kib=lb/1024.
+ print("\t /* case {0:.1f} KiB {1} size {2} {3:.1f} KiB */".format(lb_kib,lb_cmp,ub_cmp,ub_kib))
+ print("\t if ({0:d} {1} size && size {2} {3:d}) ".format(lb,lb_cmp,ub_cmp,ub))
+ print("\t return({0});" . format(retval))
+