From 6c7a66dd874b4a345c9e78bc36097a88d2dc8ec9 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Wed, 10 Jan 2018 12:12:15 +0000 Subject: Add results table to benchmark script --- benchmark.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'benchmark.py') diff --git a/benchmark.py b/benchmark.py index c00ccce..fa13c7b 100644 --- a/benchmark.py +++ b/benchmark.py @@ -5,6 +5,7 @@ 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 @@ -134,6 +135,8 @@ def cleanup(): atexit.register(cleanup) +summaryResults = {} + # Loops through each canonical solitaire for rulesGen in [SpanishPatienceRulesGen(), FreeCellRulesGen(), @@ -184,7 +187,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) -- cgit v1.2.1 From c0ca8cc4b13c0a4953519658d8fe7e27980a5651 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Wed, 10 Jan 2018 18:14:28 +0000 Subject: Add debug mode to benchmark script --- benchmark.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'benchmark.py') diff --git a/benchmark.py b/benchmark.py index fa13c7b..1eaf9f4 100644 --- a/benchmark.py +++ b/benchmark.py @@ -11,6 +11,12 @@ 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): @@ -160,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, @@ -172,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") -- cgit v1.2.1