-
Notifications
You must be signed in to change notification settings - Fork 1
/
benchmarking.py
33 lines (26 loc) · 1.01 KB
/
benchmarking.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
Perform some benchmarks on various parameters.
"""
from timeit import timeit
from functools import partial
from powergrasp import solving
def extract_config(graph_lp):
"""Yield time necessary for perform an extraction with different
clasp configurations"""
results = {}
try:
for aspconfig in solving.gen_extract_configs():
def func():
tuple(solving.all_models_from('', aspfiles=[graph_lp],
aspconfig=aspconfig))
result = timeit(func, number=3)
yield aspconfig.clasp_options + ': ' + str(result)
results[aspconfig.clasp_options] = result
except KeyboardInterrupt:
pass
minimal = min(results, key=lambda k: results[k])
yield '\nMinimal score:' + str(results[minimal]) + '\n\t' + minimal
if __name__ == "__main__":
GRAPH = './powergrasp/tests/structural_binding.lp'
GRAPH = './powergrasp/tests/big_biclique.lp'
[print(line) for line in extract_config(GRAPH)]