def Wolfinch_init(): # seed random random.seed() # 1. Retrieve states back from Db # db.init_order_db(Order) # setup ui if required if ui.integrated_ui: ui.ui_conn_pipe = ui.ui_mp_init(ui.port) if ui.ui_conn_pipe is None: log.critical("unable to setup ui!! ") print("unable to setup UI!!") sys.exit(1) # 2. Init Exchanges exchanges.init_exchanges(get_config()) # 3. Init markets market_init(exchanges.exchange_list, get_product_config) # 4. Setup markets market_setup(restart=gRestart) # 5. start stats thread stats.start()
def run_test(setup, stats, output, speed, test, eta, sleep, coding=True, toggle_tq=False): verb = "with" if coding else "without" tq = "random tq" if toggle_tq else "network coding" iso_time = time.strftime("%H:%M:%S", time.gmtime(eta)) print("# {} kbps test {} {} {} (ETA: {})".format(speed, test, verb, tq, iso_time)) if not setup.set_coding_nodes(coding, toggle_tq): print("Setting coding failed. Sleeping") time.sleep(sleep) return False # Record stats from each node stats.start(test) # Start iperf on all slaves setup.signal_slaves(test) # Wait for iperf to finish ret = setup.wait_slaves() # Stop recording stats if not stats.stop(): print("Direct path detected. Sleeping") time.sleep(sleep) return False # Restart iperf server to avoid time skew setup.restart_iperf_slaves() if not ret: time.sleep(sleep) return False if not setup.check_slave_times(): print("Slave time differs; restarting") time.sleep(sleep) return False res = stats.results() for r in res: node = r[0] stat = r[1] append_output(output, coding, node, speed, stat) res = setup.result_slaves() for r in res: slave = r.pop('slave') append_output(output, coding, slave, speed, r) print("{:10s} {throughput:5.1f} kb/s | {jitter:4.1f} ms | {lost:4d}/{total:4d} ({pl:4.1f}%)".format(slave.name.title(), **r)) print time.sleep(sleep) return True
def jayhorn(build_dir, args): cmd = ["java", "-jar", JAYHORN, "-t", "60", "-stats", "-j", build_dir, '-mem-prec', "{}".format(args.mem)] if args.inline: cmd.extend(['-inline_size', '30', '-inline_count', '3']) cmd_spacer = cmd + ['-solver', 'spacer'] bench_stats.start('JayHorn-Eldarica-Time') eldarica_result = run_with_timeout("jayhorn-eldarica_{}_{}".format(args.mem, args.inline), cmd, args.timeout) bench_stats.stop('JayHorn-Eldarica-Time') bench_stats.start('JayHorn-Spacer-Time') spacer_result = run_with_timeout("jayhorn-spacer_{}_{}".format(args.mem, args.inline), cmd_spacer, args.timeout) bench_stats.stop('JayHorn-Spacer-Time') eldarica_time = bench_stats.get("JayHorn-Eldarica-Time") spacer_time = bench_stats.get("JayHorn-Spacer-Time") return eldarica_result, spacer_result, str(eldarica_time), str(spacer_time)
def jayhorn(build_dir, args): cmd = [ "java", "-jar", JAYHORN, "-t", "60", "-stats", "-j", build_dir, '-mem-prec', "{}".format(args.mem) ] if args.inline: cmd.extend(['-inline_size', '30', '-inline_count', '3']) cmd_spacer = cmd + ['-solver', 'spacer'] bench_stats.start('JayHorn-Eldarica-Time') eldarica_result = run_with_timeout( "jayhorn-eldarica_{}_{}".format(args.mem, args.inline), cmd, args.timeout) bench_stats.stop('JayHorn-Eldarica-Time') bench_stats.start('JayHorn-Spacer-Time') spacer_result = run_with_timeout( "jayhorn-spacer_{}_{}".format(args.mem, args.inline), cmd_spacer, args.timeout) bench_stats.stop('JayHorn-Spacer-Time') eldarica_time = bench_stats.get("JayHorn-Eldarica-Time") spacer_time = bench_stats.get("JayHorn-Spacer-Time") return eldarica_result, spacer_result, str(eldarica_time), str(spacer_time)
def run_test(setup, stats, output, speed, test, eta, sleep, coding=True, toggle_tq=False): verb = "with" if coding else "without" tq = "random tq" if toggle_tq else "network coding" iso_time = time.strftime("%H:%M:%S", time.gmtime(eta)) print("# {} kbps test {} {} {} (ETA: {})".format(speed, test, verb, tq, iso_time)) if not setup.set_coding_nodes(coding, toggle_tq): print("Setting coding failed. Sleeping") time.sleep(sleep) return False # Record stats from each node stats.start(test) # Start iperf on all slaves setup.signal_slaves(test) # Wait for iperf to finish ret = setup.wait_slaves() # Stop recording stats if not stats.stop(): print("Direct path detected. Sleeping") time.sleep(sleep) return False # Restart iperf server to avoid time skew setup.restart_iperf_slaves() if not ret: time.sleep(sleep) return False if not setup.check_slave_times(): print("Slave time differs; restarting") time.sleep(sleep) return False res = stats.results() for r in res: node = r[0] stat = r[1] append_output(output, coding, node, speed, stat) res = setup.result_slaves() for r in res: slave = r.pop('slave') append_output(output, coding, slave, speed, r) print( "{:10s} {throughput:5.1f} kb/s | {jitter:4.1f} ms | {lost:4d}/{total:4d} ({pl:4.1f}%)" .format(slave.name.title(), **r)) print time.sleep(sleep) return True
def stats_general_summary(targetlist): return stats.start(found, targetlist)
def runCpa(args, dr): print "--- Running CpaChecker --- " all_dir = [os.path.join(dr, name)for name in os.listdir(dr) if os.path.isdir(os.path.join(dr, name)) ] all_build_dir = list() raw_results = dict() cpa_out = "cpachecker_out" if not os.path.exists(cpa_out): os.mkdir(cpa_out) if args.mp: for d in sorted(all_dir): if debug: print "Benchmark:\t " + str(d) tmp = d.split("/") bench = tmp[len(tmp)-1] outputpath = cpa_out+os.sep+bench cmd = [CPA, "-valueAnalysis-java-with-RTT", "-cp", d, "-outputpath", outputpath, "Main"] result = "" try: bench_stats.start('Cpa-Time') result = run_with_timeout('cpa', cmd, args.timeout) bench_stats.stop('Cpa-Time') bench_stats.brunch_print() res = "" if result: for line in result.split("\n"): if "Verification result" in line: res = "UNSAFE" if "FALSE" in line else "SAFE" else: res = "UNKNOWN" raw_results.update({d:{"result":res, "total-time": str(bench_stats.get('Cpa-Time')), "logs": (outputpath + os.sep + "Report.html")}}) except Exception as e: raw_results.update({prog: {"result":"UNKNOWN", "total-time":"", "logs": result}}) else: for d in sorted(all_dir): if debug: print "Benchmark:\t " + str(d) tmp = d.split("/") bench = tmp[len(tmp)-1] java_prog = glob.glob(os.path.abspath(d) + os.sep + "*.java") for prog in sorted(java_prog): print "Java file: " + str(prog) build_dir = os.path.splitext(prog)[0] build_dir = os.path.dirname(build_dir) bench_name = os.path.basename(prog).split(".java")[0] outputpath = cpa_out+os.sep+bench_name cmd = [CPA, "-valueAnalysis-java-with-RTT", "-cp", build_dir, "-outputpath",outputpath, bench_name] result = "" try: bench_stats.start('Cpa-Time') result = run_with_timeout('cpa', cmd, args.timeout) bench_stats.stop('Cpa-Time') res = "" if result: for line in result.split("\n"): if "Verification result" in line: res = "UNSAFE" if "FALSE" in line else "SAFE" else: res = "UNKNOWN" raw_results.update({bench_name:{ "result":res, "total-time": str(bench_stats.get('Cpa-Time')), "logs":(outputpath + os.sep + "Report.html")}}) except Exception as e: raw_results.update({prog: {"result":"UNKNOWN", "total-time":str(bench_stats.get('Cpa-Time')), "logs": result}}) stats = cpaAnalysis(raw_results) return stats
def runCpa(args, dr): print "--- Running CpaChecker --- " all_dir = [ os.path.join(dr, name) for name in os.listdir(dr) if os.path.isdir(os.path.join(dr, name)) ] all_build_dir = list() raw_results = dict() cpa_out = "cpachecker_out" if not os.path.exists(cpa_out): os.mkdir(cpa_out) if args.mp: for d in sorted(all_dir): if debug: print "Benchmark:\t " + str(d) tmp = d.split("/") bench = tmp[len(tmp) - 1] outputpath = cpa_out + os.sep + bench cmd = [ CPA, "-valueAnalysis-java-with-RTT", "-cp", d, "-outputpath", outputpath, "Main" ] result = "" try: bench_stats.start('Cpa-Time') result = run_with_timeout('cpa', cmd, args.timeout) bench_stats.stop('Cpa-Time') bench_stats.brunch_print() res = "" if result: for line in result.split("\n"): if "Verification result" in line: res = "UNSAFE" if "FALSE" in line else "SAFE" else: res = "UNKNOWN" raw_results.update({ d: { "result": res, "total-time": str(bench_stats.get('Cpa-Time')), "logs": (outputpath + os.sep + "Report.html") } }) except Exception as e: raw_results.update({ prog: { "result": "UNKNOWN", "total-time": "", "logs": result } }) else: for d in sorted(all_dir): if debug: print "Benchmark:\t " + str(d) tmp = d.split("/") bench = tmp[len(tmp) - 1] java_prog = glob.glob(os.path.abspath(d) + os.sep + "*.java") for prog in sorted(java_prog): print "Java file: " + str(prog) build_dir = os.path.splitext(prog)[0] build_dir = os.path.dirname(build_dir) bench_name = os.path.basename(prog).split(".java")[0] outputpath = cpa_out + os.sep + bench_name cmd = [ CPA, "-valueAnalysis-java-with-RTT", "-cp", build_dir, "-outputpath", outputpath, bench_name ] result = "" try: bench_stats.start('Cpa-Time') result = run_with_timeout('cpa', cmd, args.timeout) bench_stats.stop('Cpa-Time') res = "" if result: for line in result.split("\n"): if "Verification result" in line: res = "UNSAFE" if "FALSE" in line else "SAFE" else: res = "UNKNOWN" raw_results.update({ bench_name: { "result": res, "total-time": str(bench_stats.get('Cpa-Time')), "logs": (outputpath + os.sep + "Report.html") } }) except Exception as e: raw_results.update({ prog: { "result": "UNKNOWN", "total-time": str(bench_stats.get('Cpa-Time')), "logs": result } }) stats = cpaAnalysis(raw_results) return stats