2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-20 08:56:28 +08:00
artiq/benchmarks/rpc_timing.py

33 lines
772 B
Python
Raw Normal View History

2015-02-19 00:57:00 +08:00
from math import sqrt
from artiq import *
class RPCTiming(Experiment, AutoDB):
"""RPC timing"""
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()
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(
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