Created
November 4, 2018 02:29
-
-
Save josh-richardson/c6187ed1221982bf73aad960cdcd29e0 to your computer and use it in GitHub Desktop.
it hurts to live
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 json | |
# def process_parallel(item): | |
class BenchmarkResult: | |
def __init__(self, language, cores, speed, category, computer): | |
self.language = language | |
self.cores = cores | |
self.speed = speed | |
self.category = category | |
self.computer = computer | |
def __str__(self): | |
return ('%s with %d cores took %s for %s on %d' % (self.language, self.cores, self.speed, self.category, self.computer)) | |
final_results = [] | |
result_types = ["results_c.txt", "results_go.txt", "results_c_parallel.txt", "results_go_parallel.txt"] | |
result_categories = ["1 and 15000", "1 and 30000", "1 and 60000"] | |
stoof = {} | |
for i in range(1, 4): | |
for j in range(1, 4): | |
for file in result_types: | |
filename = 'gpgnode-0%d/0%d/%s' % (i, j, file) | |
results = open(filename, 'r').read() | |
if file in stoof: | |
stoof[file] += "\n" + results | |
else: | |
stoof[file] = results | |
for file in result_types: | |
individuals = list(filter(lambda x: len(x.strip()) != 0, stoof[file].split("Time for"))) | |
fileseg = (len(individuals)) / 3 | |
counter = 0 | |
computer = 0 | |
for benchmark in individuals: | |
if (counter % fileseg == 0): | |
computer += 1 | |
counter += 1 | |
for category in result_categories: | |
if (category in benchmark): | |
benchmark_lines = benchmark.split('\n') | |
language = benchmark_lines[0].split(" ")[2] if ("parallel" in benchmark) else benchmark_lines[0].split(" ")[3] | |
cores = int(benchmark_lines[0].split(" ")[4]) if ("parallel" in benchmark) else 0 | |
speed = benchmark_lines[4] if language == "go" else benchmark_lines[3] | |
speed = speed.split(" ")[1].replace("s", "").split("m") | |
speed = int(1000 * ((60 * int(speed[0])) + float(speed[1]))) | |
result = BenchmarkResult(language, cores, speed, category, computer) | |
final_results.append(result) | |
# print('%s with %d cores took %s for %s on %s' % (language, cores, speed, category, file)) | |
for itm in list(filter(lambda x: True, final_results)): | |
print(itm) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment