def execute(self, clkrate): ignore, plan, ignore = build_plan(self.network, clkrate) thrds = [] #stuff = [] for cli in self.clients: cltrd, ignore, ignore = build_plan(cli, clkrate) #stuff[0:0] = cltrd.tups thrds.append(cltrd) #stuff[0:0] = plan #for t in sorted(stuff, key=lambda t: t[0]): # print t act = ActThread(plan) # sync offset for start, in msec start = int(time() * 1000) + SYNC_WINDOW act.abstime = start for t in thrds: t.abstime = start for t in thrds: t.start() t.start_event.wait() act.start() act.join() for cli, t in zip(self.clients, thrds): t.join() cli.ctrace = t.ctrace
for i in xrange(20): kv['foo'] = 'bar' + str(i) kv2['foo'] kv2['foo'] = 'bar_' + str(i) sys.fail(serv) kv['foo'] sys.recover(serv) kv['foo'] cli, plan, dead_time = build_plan(sys, CLOCK_RATE) cli2, plan2, dead_time2 = build_plan(sys2, CLOCK_RATE) strt = (time() * 1000) + 1000 cli.abstime = strt cli2.abstime = strt cli.start() cli2.start() cli.join() cli2.join() print 'Total Errors:', count_errors(cli.ctrace)
serv1 = Server(xcript, "127.0.0.1", "8080") serv2 = Server(xcript, "127.0.0.1", "8888") serv3 = Server(xcript, "127.0.0.1", "9988") network = Network([serv, serv1, serv2, serv3], xcript) sys = Client(clk, [serv]) kv = sys.store for i in xrange(50): kv["foo"] = "bar" + str(i) kv["foo"] cli, plan, dead_time = build_plan(sys, CLOCK_RATE) network[(serv, serv1)] = False ignore, plan, dead_time = build_plan(network, CLOCK_RATE) print plan cli.start() cli.join() print "Total Errors:", count_errors(cli.ctrace) print "Thread 1 ran for: run time={0}, dead_time={1} slack={2}".format(cli.runtime, dead_time, cli.ctrace.slack)
network = Network([serv, serv1, serv2, serv3], xcript) sys = Client(clk, [serv]) kv = sys.store for i in xrange(500): kv['foo'] = 'bar' kv['foo'] for clk in xrange(10): cli, plan, dead_time = build_plan(sys, clk) cli.abstime = int(time() * 1000) + 100 cli.start() cli.join() if count_errors(cli.ctrace) != 0: print 'errors: '+ str(count_errors(cli.ctrace)) rate = (cli.ctrace.slack * 1000.0 / cli.ctrace.reqcount) print '@{0}ms clock, msec / req : {1}'.format(clk, rate) raise SystemExit print 'Total Errors:', count_errors(cli.ctrace) print 'Thread 1 ran for: run time={0}, dead_time={1} slack={2}'.format( cli.runtime, dead_time, cli.ctrace.slack) effective_time = cli.runtime - cli.ctrace.slack
serv3= Server(xcript, '192.168.56.104', '8808') network = Network([serv, serv1, serv2, serv3], xcript) sys = Client(clk, [serv]) kv = sys.store for i in xrange(5): kv['foo'] = 'bar' kv['foo'] cli, plan, dead_time = build_plan(sys, CLOCK_RATE) cli.abstime = int(time() * 1000) + 1000 cli.start() cli.join() print 'Total Errors:', count_errors(cli.ctrace) print 'Thread 1 ran for: run time={0}, dead_time={1} slack={2}'.format( cli.runtime, dead_time, cli.ctrace.slack) effective_time = cli.runtime - cli.ctrace.slack print 'C-Runtime (msec):', cli.ctrace.runtime