From dda5c167b893ad160e7f564b2c2587c6aef441b5 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 18 Feb 2015 09:57:00 -0700 Subject: [PATCH] benchmarks: add rpc_timing --- benchmarks/all.py | 4 ++-- benchmarks/rpc_timing.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 benchmarks/rpc_timing.py diff --git a/benchmarks/all.py b/benchmarks/all.py index a2bc069f7..f520853bc 100644 --- a/benchmarks/all.py +++ b/benchmarks/all.py @@ -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): diff --git a/benchmarks/rpc_timing.py b/benchmarks/rpc_timing.py new file mode 100644 index 000000000..15c881f27 --- /dev/null +++ b/benchmarks/rpc_timing.py @@ -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