def benchmark_thread(tid, _benchmark): t_cfg = _benchmark["test_cfg"] b_cfg = _benchmark["bench_cfg"] session = _benchmark["session"] lock = _benchmark["lock"] pre = b_cfg["pre"] core = b_cfg["core"] post = b_cfg["post"] try: pre_ret = pre(tid, t_cfg, b_cfg, session) sys.stdout.write("-") sys.stdout.flush() _benchmark["events"][tid]["event_1"].set() # signal we are done _benchmark["events"][tid]["event_2"].wait() # wait 'til others are done iterations = int(b_cfg["iterations"]) / int(b_cfg["concurrency"]) # poor-mans ceil() if (iterations * int(b_cfg["concurrency"])) < int(b_cfg["iterations"]): iterations += 1 for i in range(0, iterations + 1): core_ret = core(tid, i, pre_ret) benchmark_tic(_benchmark, tid) _benchmark["events"][tid]["event_3"].set() # signal we are done _benchmark["events"][tid]["event_4"].wait() # wait 'til others are done post_ret = post(tid, core_ret) sys.stdout.write("=") sys.stdout.flush() _benchmark["events"][tid]["event_5"].set() # signal we are done except Exception as e: print " 1 --------------------------------------- " print str(e) print " 2 --------------------------------------- " print repr(e) print " 3 --------------------------------------- " print sumisc.get_trace() print " 4 --------------------------------------- " sys.stdout.write("exception in benchmark thread: %s\n\n" % e) sys.stdout.flush() # Oops, we are screwed. Tell main thread that we are done for, and # bye-bye... _benchmark["events"][tid]["event_1"].set() # signal we are done _benchmark["events"][tid]["event_3"].set() # signal we are done _benchmark["events"][tid]["event_5"].set() # signal we are done sys.exit(-1) sys.exit(0)
def run(self): try: self._state = RUNNING self._result = self._call(*self._args, **self._kwargs) self._state = DONE except Exception as e: print ' ========================================== ' print repr(e) print ' ========================================== ' print str(e) print ' ========================================== ' print sumisc.get_trace() print ' ========================================== ' self._exception = e self._state = FAILED
def run (self) : try : self._state = RUNNING self._result = self._call (*self._args, **self._kwargs) self._state = DONE except Exception as e : print ' ========================================== ' print repr(e) print ' ========================================== ' print str(e) print ' ========================================== ' print sumisc.get_trace () print ' ========================================== ' self._exception = e self._state = FAILED
def benchmark_thread(tid, _benchmark): t_cfg = _benchmark['test_cfg'] b_cfg = _benchmark['bench_cfg'] session = _benchmark['session'] lock = _benchmark['lock'] pre = b_cfg['pre'] core = b_cfg['core'] post = b_cfg['post'] try: pre_ret = pre(tid, t_cfg, b_cfg, session) sys.stdout.write('-') sys.stdout.flush() _benchmark['events'][tid]['event_1'].set() # signal we are done _benchmark['events'][tid]['event_2'].wait( ) # wait 'til others are done iterations = int(b_cfg['iterations']) / int(b_cfg['concurrency']) # poor-mans ceil() if (iterations * int(b_cfg['concurrency'])) < int(b_cfg['iterations']): iterations += 1 for i in range(0, iterations + 1): core_ret = core(tid, i, pre_ret) benchmark_tic(_benchmark, tid) _benchmark['events'][tid]['event_3'].set() # signal we are done _benchmark['events'][tid]['event_4'].wait( ) # wait 'til others are done post_ret = post(tid, core_ret) sys.stdout.write('=') sys.stdout.flush() _benchmark['events'][tid]['event_5'].set() # signal we are done except Exception as e: print " 1 --------------------------------------- " print str(e) print " 2 --------------------------------------- " print repr(e) print " 3 --------------------------------------- " print sumisc.get_trace() print " 4 --------------------------------------- " sys.stdout.write("exception in benchmark thread: %s\n\n" % e) sys.stdout.flush() # Oops, we are screwed. Tell main thread that we are done for, and # bye-bye... _benchmark['events'][tid]['event_1'].set() # signal we are done _benchmark['events'][tid]['event_3'].set() # signal we are done _benchmark['events'][tid]['event_5'].set() # signal we are done sys.exit(-1) sys.exit(0)
def benchmark_thread (tid, _benchmark) : t_cfg = _benchmark['test_cfg'] b_cfg = _benchmark['bench_cfg'] session = _benchmark['session'] lock = _benchmark['lock'] pre = b_cfg['pre'] core = b_cfg['core'] post = b_cfg['post'] try : pre_ret = pre (tid, t_cfg, b_cfg, session) sys.stdout.write ('-') sys.stdout.flush () _benchmark['events'][tid]['event_1'].set () # signal we are done _benchmark['events'][tid]['event_2'].wait () # wait 'til others are done iterations = int(b_cfg['iterations']) / int(b_cfg['concurrency']) # poor-mans ceil() if (iterations * int(b_cfg['concurrency'])) < int(b_cfg['iterations']) : iterations += 1 for i in range (0, iterations+1) : core_ret = core (tid, i, pre_ret) benchmark_tic (_benchmark, tid) _benchmark['events'][tid]['event_3'].set () # signal we are done _benchmark['events'][tid]['event_4'].wait () # wait 'til others are done post_ret = post (tid, core_ret) sys.stdout.write ('=') sys.stdout.flush () _benchmark['events'][tid]['event_5'].set () # signal we are done except Exception as e : print " 1 --------------------------------------- " print str(e) print " 2 --------------------------------------- " print repr(e) print " 3 --------------------------------------- " print sumisc.get_trace () print " 4 --------------------------------------- " sys.stdout.write ("exception in benchmark thread: %s\n\n" % e) sys.stdout.flush () # Oops, we are screwed. Tell main thread that we are done for, and # bye-bye... _benchmark['events'][tid]['event_1'].set () # signal we are done _benchmark['events'][tid]['event_3'].set () # signal we are done _benchmark['events'][tid]['event_5'].set () # signal we are done sys.exit (-1) sys.exit (0)