-
-
Save tanzaku/d786d7a929ea3340fbf4d827327d05dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import os | |
import time | |
import sys | |
# test = ["java", "-jar", "SquareRemoverVis.jar", "-exec", "\"a.exe\"", "-novis", "-seed "] | |
def build(): | |
sys.stderr.write("compiling...\n") | |
sys.stderr.flush() | |
compile_command = ["g++", "-std=c++11", "main.cpp", "-O2", "-D", "LOCAL"] | |
p = subprocess.Popen(compile_command, shell=True) | |
p.communicate() | |
sys.stderr.write("finish compile\n") | |
sys.stderr.flush() | |
def run_test(seed): | |
start_time = time.clock() | |
# sys.stderr.write("start tester: seed=" + str(seed) + '\n') | |
# sys.stderr.flush() | |
command = ["java", "-jar", "SquareRemoverVis.jar", "-exec", "\"a.exe\"", "-novis", "-seed", str(seed)] | |
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
pipe_out, pipe_err = p.communicate() | |
end_time = time.clock() | |
score = repr(pipe_out) | |
score = score.replace('\\\\', '\\') | |
score = score.replace('\\r', '\r') | |
score = score.replace('\\n', '\n') | |
score = score.replace(' ', '') | |
score = score.strip(' \r\n\t\'\"') | |
score = score.split('=') | |
# seed,score,time[s] | |
print(str(seed) + ',' + score[-1] + ',' + str(end_time - start_time)) | |
sys.stdout.flush() | |
sys.stderr.write(str(seed) + ',' + score[-1] + ',' + str(end_time - start_time) + '\n') | |
sys.stderr.flush() | |
# print(score[-1]) | |
# print(str(end_time - start_time) + ' [s]') | |
if __name__ == "__main__": | |
# print("Score = 4587".split(" ")) | |
build() | |
for seed in range(1, 101): | |
run_test(seed) | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment