summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-02-21 15:21:42 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-02-21 15:21:42 +0100
commit115274b46b61180ca1fea79511482fc704b552ca (patch)
tree48c8e81ae92d88a9d367141574d8614bd6b65994 /bin
parent31c25383a4f169ee7652c76f0bf323447cdbb334 (diff)
add generate-dfa-benchmark: trace-based benchmark generation
Diffstat (limited to 'bin')
-rwxr-xr-xbin/generate-dfa-benchmark.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/bin/generate-dfa-benchmark.py b/bin/generate-dfa-benchmark.py
new file mode 100755
index 0000000..083d0fe
--- /dev/null
+++ b/bin/generate-dfa-benchmark.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python3
+
+import getopt
+import json
+import re
+import sys
+from automata import PTA
+
+opt = {}
+
+if __name__ == '__main__':
+
+ try:
+ optspec = (
+ 'depth= '
+ 'instance= '
+ )
+ raw_opts, args = getopt.getopt(sys.argv[1:], "", optspec.split(' '))
+
+ for option, parameter in raw_opts:
+ optname = re.sub(r'^--', '', option)
+ opt[optname] = parameter
+
+ if 'depth' in opt:
+ opt['depth'] = int(opt['depth'])
+ else:
+ opt['depth'] = 3
+
+ except getopt.GetoptError as err:
+ print(err)
+ sys.exit(2)
+
+ modelfile = args[0]
+
+ with open(modelfile, 'r') as f:
+ 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)))
+ else:
+ print('{}({});'.format(function_name, ', '.join(arguments)))
+ print()
+
+ sys.exit(0)