mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-25 11:18:27 +08:00
benchmarks: add rpc_timing
This commit is contained in:
parent
e10390d142
commit
dda5c167b8
@ -1,9 +1,9 @@
|
||||
from artiq import *
|
||||
|
||||
import pulse_rate, rtio_skew
|
||||
import pulse_rate, rtio_skew, rpc_timing
|
||||
|
||||
|
||||
_units = [pulse_rate.PulseRate, rtio_skew.RTIOSkew]
|
||||
_units = [pulse_rate.PulseRate, rtio_skew.RTIOSkew, rpc_timing.RPCTiming]
|
||||
|
||||
class AllBenchmarks(AutoDB):
|
||||
def build(self):
|
||||
|
29
benchmarks/rpc_timing.py
Normal file
29
benchmarks/rpc_timing.py
Normal file
@ -0,0 +1,29 @@
|
||||
from math import sqrt
|
||||
|
||||
from artiq import *
|
||||
|
||||
|
||||
class RPCTiming(AutoDB):
|
||||
class DBKeys:
|
||||
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] = float(t2.amount - t1.amount)
|
||||
|
||||
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
|
||||
self.rpc_time_mean = mean*s
|
Loading…
Reference in New Issue
Block a user