2015-02-19 00:57:00 +08:00
|
|
|
from math import sqrt
|
|
|
|
|
|
|
|
from artiq import *
|
|
|
|
|
|
|
|
|
2015-03-08 22:43:04 +08:00
|
|
|
class RPCTiming(Experiment, AutoDB):
|
|
|
|
"""RPC timing"""
|
2015-02-21 05:01:34 +08:00
|
|
|
|
2015-02-19 00:57:00 +08:00
|
|
|
class DBKeys:
|
2015-03-08 18:37:53 +08:00
|
|
|
core = Device()
|
2015-02-19 00:57:00 +08:00
|
|
|
repeats = Argument(100)
|
|
|
|
rpc_time_mean = Result()
|
|
|
|
rpc_time_stddev = Result()
|
|
|
|
|
|
|
|
def nop(self, x):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@kernel
|
|
|
|
def bench(self):
|
|
|
|
self.ts = [0.0 for _ in range(self.repeats)]
|
|
|
|
for i in range(self.repeats):
|
|
|
|
t1 = self.core.get_rtio_time()
|
|
|
|
self.nop(10)
|
|
|
|
t2 = self.core.get_rtio_time()
|
2015-06-26 22:20:13 +08:00
|
|
|
self.ts[i] = t2 - t1
|
2015-02-19 00:57:00 +08:00
|
|
|
|
|
|
|
def run(self):
|
|
|
|
self.bench()
|
|
|
|
mean = sum(self.ts)/self.repeats
|
|
|
|
self.rpc_time_stddev = sqrt(
|
2015-04-28 00:43:14 +08:00
|
|
|
sum([(t - mean)**2 for t in self.ts])/self.repeats)*s
|
2015-02-19 00:57:00 +08:00
|
|
|
self.rpc_time_mean = mean*s
|