Permalink
Browse files

Added Python benchmarking code

  • Loading branch information...
1 parent 698d159 commit 3526b735e98d426db302a494d179dacf59c83c82 @ktnyt ktnyt committed Jan 6, 2016
Showing with 75 additions and 0 deletions.
  1. +75 −0 python/tests/scheduler_benchmark.py
@@ -0,0 +1,75 @@
+from benchmarker import Benchmarker
+
+import brica1
+
+with Benchmarker(width=20, loop=10000, cycle=20) as bench:
+ @bench(None)
+ def _(bm):
+ for _ in bm:
+ pass
+
+ @bench('constant_null_small')
+ def _(bm):
+ s = brica1.VirtualTimeSyncScheduler(1.0)
+ agent = brica1.Agent(s)
+
+ compA = brica1.ConstantComponent()
+ compB = brica1.NullComponent()
+ mod = brica1.Module();
+
+ mod.add_component('compA', compA)
+ mod.add_component('compB', compB)
+
+ compA.make_out_port('out', 1)
+ compB.make_in_port('in', 1)
+
+ brica1.connect((compA, 'out'), (compB, 'in'))
+
+ agent.add_submodule('mod', mod)
+
+ for _ in bm:
+ agent.step()
+
+ @bench('constant_null_medium')
+ def _(bm):
+ s = brica1.VirtualTimeSyncScheduler(1.0)
+ agent = brica1.Agent(s)
+
+ compA = brica1.ConstantComponent()
+ compB = brica1.NullComponent()
+ mod = brica1.Module();
+
+ mod.add_component('compA', compA)
+ mod.add_component('compB', compB)
+
+ compA.make_out_port('out', 28)
+ compB.make_in_port('in', 28)
+
+ brica1.connect((compA, 'out'), (compB, 'in'))
+
+ agent.add_submodule('mod', mod)
+
+ for _ in bm:
+ agent.step()
+
+ @bench('constant_null_large')
+ def _(bm):
+ s = brica1.VirtualTimeSyncScheduler(1.0)
+ agent = brica1.Agent(s)
+
+ compA = brica1.ConstantComponent()
+ compB = brica1.NullComponent()
+ mod = brica1.Module();
+
+ mod.add_component('compA', compA)
+ mod.add_component('compB', compB)
+
+ compA.make_out_port('out', 256*256*3)
+ compB.make_in_port('in', 256*256*3)
+
+ brica1.connect((compA, 'out'), (compB, 'in'))
+
+ agent.add_submodule('mod', mod)
+
+ for _ in bm:
+ agent.step()

0 comments on commit 3526b73

Please sign in to comment.