summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-03-05 16:10:49 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-03-05 16:10:49 +0100
commitcc31a043f21c16986d7b33eabb05cfc34d6e0390 (patch)
tree024529d92341a8b3096095e3043dc204082f17db /bin
parentcf7e68c388bd1ef0e9e2ee64b5193e09be16b6da (diff)
working benchmark generation
Diffstat (limited to 'bin')
-rwxr-xr-xbin/generate-dfa-benchmark.py38
1 files changed, 32 insertions, 6 deletions
diff --git a/bin/generate-dfa-benchmark.py b/bin/generate-dfa-benchmark.py
index ce67313..76b9de4 100755
--- a/bin/generate-dfa-benchmark.py
+++ b/bin/generate-dfa-benchmark.py
@@ -1,4 +1,26 @@
#!/usr/bin/env python3
+"""
+Generate a driver/library benchmark based on DFA/PTA traces.
+
+Usage:
+PYTHONPATH=lib bin/generate-dfa-benchmark.py [options] <pta/dfa definition>
+
+generate-dfa-benchmarks reads in a DFA definition and generates runs
+(i.e., all words accepted by the DFA up to a configurable length). Each symbol
+corresponds to a function call. If arguments are specified in the DFA
+definition, each symbol corresponds to a function call with a specific set of
+arguments (so all argument combinations are present in the generated runs).
+
+Options:
+--depth=<depth> (default: 3)
+ Maximum number of function calls per run
+
+--instance=<name>
+ Override the name of the class instance used for benchmarking
+
+--sleep=<ms> (default: 0)
+ How long to sleep between function calls.
+"""
import getopt
import json
@@ -6,7 +28,7 @@ import re
import sys
import yaml
from automata import PTA
-from harness import TransitionHarness
+from harness import OnboardTimerHarness
opt = {}
@@ -44,11 +66,12 @@ if __name__ == '__main__':
else:
pta = PTA.from_yaml(yaml.safe_load(f))
- harness = TransitionHarness('GPIO::p1_0')
+ harness = OnboardTimerHarness('GPIO::p1_0')
print('#include "arch.h"')
- if pta.header:
- print('#include "{}"'.format(pta.header))
+ if 'includes' in pta.codegen:
+ for include in pta.codegen['includes']:
+ print('#include "{}"'.format(include))
print(harness.global_code())
print('void loop(void)')
@@ -59,8 +82,8 @@ if __name__ == '__main__':
class_prefix = ''
if 'instance' in opt:
class_prefix = '{}.'.format(opt['instance'])
- elif pta.instance:
- class_prefix = '{}.'.format(pta.instance)
+ elif 'intance' in pta.codegen:
+ class_prefix = '{}.'.format(pta.codegen['instance'])
for run in pta.dfs(opt['depth'], with_arguments = True):
print(harness.start_run())
@@ -85,6 +108,9 @@ if __name__ == '__main__':
print('{')
for driver in ('arch', 'gpio', 'kout'):
print('{}.setup();'.format(driver))
+ if 'setup' in pta.codegen:
+ for call in pta.codegen['setup']:
+ print(call)
print('arch.idle_loop();')
print('return 0;')
print('}')