diff options
| author | Charlie Blake | 2018-01-10 18:16:34 +0000 |
|---|---|---|
| committer | GitHub | 2018-01-10 18:16:34 +0000 |
| commit | 2a62143fb9edb929f410b1b9b3aed16a16ceba39 (patch) | |
| tree | d5d7839783cebb097af9f071751d693f47e3af6d /benchmark.py | |
| parent | Merge pull request #28 from thecharlesblake/all-canonical-games (diff) | |
| parent | Add asserts to program and fix bugs they raise (diff) | |
| download | metasol-2a62143fb9edb929f410b1b9b3aed16a16ceba39.tar.gz metasol-2a62143fb9edb929f410b1b9b3aed16a16ceba39.zip | |
Merge pull request #29 from thecharlesblake/refactor-improve-debug
Refactor improve debug
Diffstat (limited to 'benchmark.py')
| -rw-r--r-- | benchmark.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/benchmark.py b/benchmark.py index c00ccce..1eaf9f4 100644 --- a/benchmark.py +++ b/benchmark.py @@ -5,11 +5,18 @@ import sys import atexit from subprocess import run, TimeoutExpired, CalledProcessError, DEVNULL from abc import ABCMeta, abstractmethod +from prettytable import PrettyTable tempRulesFilename = "temp_rules.json" timeoutsLimit = 4 timeoutSeconds = 1 +runtype = "release" +if (len(sys.argv) == 2 + and (sys.argv[1] == "--debug" or sys.argv[1] == "-d")): + runtype = "debug" + print("Running in debug mode...") + class SolitaireRulesGen(metaclass=ABCMeta): def __init__(self, name): @@ -134,6 +141,8 @@ def cleanup(): atexit.register(cleanup) +summaryResults = {} + # Loops through each canonical solitaire for rulesGen in [SpanishPatienceRulesGen(), FreeCellRulesGen(), @@ -157,7 +166,7 @@ for rulesGen in [SpanishPatienceRulesGen(), timeouts = 0 for attempt in range(20): try: - run("./cmake-build-release/bin/solvitaire --rules " + run("./cmake-build-" + runtype + "/bin/solvitaire --rules " + tempRulesFilename + " --random " + str(attempt + 1), shell=True, check=True, @@ -169,6 +178,7 @@ for rulesGen in [SpanishPatienceRulesGen(), except CalledProcessError: print("Error running " + rulesGen.name + " at level " + str(level) + " with seed " + str(attempt + 1) + "!") + print(str(rulesGen) + "\n") sys.exit() except: print("Unknown error in script") @@ -184,7 +194,14 @@ for rulesGen in [SpanishPatienceRulesGen(), + " within time constraint\n") print("Game description at level " + str(level) + ":") print(str(rulesGen) + "\n") + summaryResults[rulesGen.name] = level break else: print("Solved " + rulesGen.name + " at level " + str(level) + " ...") + +# Prints results summary table +t = PrettyTable(['Solitaire', 'Level']) +for name, level in summaryResults.items(): + t.add_row([name, level]) +print(t) |
