summaryrefslogtreecommitdiff
path: root/bin/generate-dfa-benchmark.py
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-02-21 16:42:49 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-02-21 16:42:49 +0100
commit53c0421d66ebe6644cdd4d36c0fb849f352c4641 (patch)
tree9637fa0e46521924d701226bf4ec97e44e4d5867 /bin/generate-dfa-benchmark.py
parent6e72c1b2b53e2290dc5cb7aa218c620a0ee979d4 (diff)
generate-dfa-benchmark: Add sleep statements, handle interrupts
Diffstat (limited to 'bin/generate-dfa-benchmark.py')
-rwxr-xr-xbin/generate-dfa-benchmark.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/bin/generate-dfa-benchmark.py b/bin/generate-dfa-benchmark.py
index 083d0fe..e96100c 100755
--- a/bin/generate-dfa-benchmark.py
+++ b/bin/generate-dfa-benchmark.py
@@ -14,6 +14,7 @@ if __name__ == '__main__':
optspec = (
'depth= '
'instance= '
+ 'sleep= '
)
raw_opts, args = getopt.getopt(sys.argv[1:], "", optspec.split(' '))
@@ -26,6 +27,9 @@ if __name__ == '__main__':
else:
opt['depth'] = 3
+ if 'sleep' in opt:
+ opt['sleep'] = int(opt['sleep'])
+
except getopt.GetoptError as err:
print(err)
sys.exit(2)
@@ -36,11 +40,18 @@ if __name__ == '__main__':
pta = PTA.from_json(json.load(f))
for run in pta.dfs(opt['depth'], with_arguments = True):
- for function_name, arguments in run:
- if 'instance' in opt:
- print('{}.{}({});'.format(opt['instance'], function_name, ', '.join(arguments)))
+ for transition, arguments in run:
+ if transition.is_interrupt:
+ print('// wait for {} interrupt'.format(transition.name))
else:
- print('{}({});'.format(function_name, ', '.join(arguments)))
+ if 'instance' in opt:
+ print('{}.{}({});'.format(opt['instance'], transition.name, ', '.join(arguments)))
+ else:
+ print('{}({});'.format(transition.name, ', '.join(arguments)))
+
+ if 'sleep' in opt:
+ print('arch.delay_ms({:d});'.format(opt['sleep']))
+
print()
sys.exit(0)