Skip to content

Commit 6782ae1

Browse files
committed
SMTLIB Benchmark: Revised Util
1 parent c5c4a84 commit 6782ae1

File tree

4 files changed

+29
-120
lines changed

4 files changed

+29
-120
lines changed

SMT-LIB/download.py

Lines changed: 0 additions & 53 deletions
This file was deleted.

SMT-LIB/parse_all.py

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@
33
import sys
44
import random
55
import multiprocessing
6+
import argparse
67

78
from itertools import islice
89

9-
from pysmt.shortcuts import reset_env, get_env
10-
from pysmt.smtlib.parser import SmtLibParser
11-
from pysmt.solvers.noop import NoopSolver
10+
from pysmt.shortcuts import reset_env, read_smtlib
1211

13-
SMTLIB_DIR = "./"
1412

1513
def get_all_smt_files(target_dir=None):
1614
if target_dir == None:
17-
target_dir = SMTLIB_DIR
15+
target_dir = "./"
1816

1917
assert os.path.exists(target_dir)
2018
for root, _, files in os.walk(target_dir):
@@ -28,46 +26,52 @@ def execute_script_fname(smtfile):
2826
print(smtfile)
2927
reset_env()
3028
assert os.path.exists(smtfile)
31-
parser = SmtLibParser()
32-
solver = NoopSolver(get_env())
33-
3429
start = time.clock()
35-
script = parser.get_script_fname(smtfile)
30+
read_smtlib(smtfile)
3631
end = time.clock()
37-
38-
script.evaluate(solver)
39-
res = solver.get_asserted_formula()
40-
assert res is not None
41-
42-
return (smtfile, (end - start))
32+
return ( (end - start), smtfile)
4333

4434

4535
def dump_stats(timings, fname):
36+
if fname is None:
37+
fname = "stats.out"
4638
with open(fname, "w") as f:
4739
f.write('filename, time\n')
4840
for k in timings:
49-
f.write('"%s", "%s"\n' % k)
41+
f.write('%f, "%s"\n' % k)
5042

5143

5244
def main():
53-
if len(sys.argv) != 3:
54-
print("usage: %s <number of files to benchmark> <statistics file>" %\
55-
sys.argv[0])
56-
exit(1)
45+
parser = argparse.ArgumentParser(description='SMT-LIB Parser Benchmarking')
46+
parser.add_argument('--base', type=str, nargs='?',
47+
help='top-directory of the benchmarks')
48+
49+
parser.add_argument('--count', type=int, nargs='?',
50+
default=-1,
51+
help='number of files to benchmark')
52+
53+
parser.add_argument('--out', type=str, default="stats.out", nargs='?',
54+
help='Where to save the statistics')
55+
56+
args = parser.parse_args()
5757

5858
random.seed(42)
5959
p = multiprocessing.Pool()
6060
chunks = multiprocessing.cpu_count()
61-
file_list = list(get_all_smt_files())
61+
file_list = list(get_all_smt_files(args.base))
6262
random.shuffle(file_list)
63-
files_cnt = int(sys.argv[1])
63+
if args.count == -1:
64+
files_cnt = len(file_list)
65+
else:
66+
files_cnt = args.count
6467
print("Submitting %d jobs, %d at the time" % (files_cnt, chunks))
6568
timings = p.map(execute_script_fname, islice(file_list, files_cnt), chunks)
6669

67-
mean = sum(x[1] for x in timings) / len(timings)
68-
print("The mean execution time is:", mean, "seconds")
70+
mean = sum(x[0] for x in timings) / len(timings)
71+
print("The mean execution time was %0.2f seconds" % mean)
72+
print("The max execution time was %0.2f seconds" % max(x[0] for x in timings))
6973

70-
outfile = sys.argv[2]
74+
outfile = args.out
7175
dump_stats(timings, outfile)
7276
print("The statistics file has been generated in '%s'" % outfile)
7377

SMT-LIB/parse_all.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

SMT-LIB/smtlib.urls

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)