def main(): workers = 200 timeout = 2.5 wcon = gtarantool.connect("127.0.0.1", 3301) spawn_workers(workers, timeout, wcon) spawn_printer() return 0
def spawn_printer(): proc = find_pid_benchmark() if proc == None: raise Exception("Can't find benchmark process") tnt = gtarantool.connect("127.0.0.1", 3301) while True: try: stat = tnt.call("box.stat")[0][0] except: print "Printer connection is closed" return print "%6.2f CPU | %6s MEM [ DELETE %6d rps | INSERT %6d rps | SELECT %6d rps ]" % ( proc.cpu_percent(), size( proc.memory_info().rss, system=alternative), stat['DELETE']['rps'], stat['INSERT']['rps'], stat['SELECT']['rps']) gevent.sleep(1)
def spawn_printer(): proc = find_pid_benchmark() if proc == None: raise Exception("Can't find benchmark process") tnt = gtarantool.connect("127.0.0.1", 3301) while True: try: stat = tnt.call("box.stat")[0][0] except: print "Printer connection is closed" return print "%6.2f CPU | %6s MEM [ DELETE %6d rps | INSERT %6d rps | SELECT %6d rps ]" % ( proc.cpu_percent(), size(proc.memory_info().rss, system=alternative), stat['DELETE']['rps'], stat['INSERT']['rps'], stat['SELECT']['rps'] ) gevent.sleep(1)
def target_bench(): print("run process:", os.getpid()) tnt = gtarantool.connect("127.0.0.1", 3301) bench = Bench(tnt) tasks = [] tasks += [gevent.spawn(bench.insert_job) for _ in range(20)] tasks += [gevent.spawn(bench.select_job) for _ in range(20)] tasks += [gevent.spawn(bench.update_job) for _ in range(20)] tasks += [gevent.spawn(bench.delete_job) for _ in range(20)] t1 = time.time() gevent.joinall(tasks) t2 = time.time() print("select=%d; insert=%d; update=%d; delete=%d; total=%d" % ( bench.cnt_s, bench.cnt_i, bench.cnt_u, bench.cnt_d, t2 - t1))
global cnt for i in range(2500): cnt += 1 r = tnt.update("tester", cnt, [("=", 2, cnt)]) def delete_job(tnt): global cnt for i in range(2500): cnt += 1 r = tnt.delete("tester", cnt) tnt = gtarantool.connect("127.0.0.1", 3301) # insert test print "gtarantool insert test" t1 = time.time() cnt = 0 jobs = [gevent.spawn(insert_job, tnt) for _ in range(40)] gevent.joinall(jobs) t2 = time.time() benchmark["gtarantool"]["insert"] = t2 - t1 # select test print "gtarantool select test" t1 = time.time()