Add results for Julia files
This commit is contained in:
parent
71a1ccd2ca
commit
846a9343ae
@ -1,4 +1,3 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
@ -32,19 +31,30 @@ def execute():
|
||||
def _file_stem(f):
|
||||
return f[-5:]
|
||||
|
||||
os.chdir(Path("Python/"))
|
||||
scripts = sorted([script.as_posix() for script in Path(".").rglob("*[0-9].py")], key=_file_stem)
|
||||
# os.chdir(Path("Python/"))
|
||||
os.chdir(Path("Julia/"))
|
||||
# scripts = sorted([script.as_posix() for script in Path(".").rglob("*[0-9].py")], key=_file_stem)
|
||||
scripts = sorted([script.as_posix() for script in Path(".").rglob("*[0-9].jl")], key=_file_stem)
|
||||
# print(scripts)
|
||||
|
||||
timings, results = [], []
|
||||
for script in scripts:
|
||||
_res = run(["python3", f"{script}"], capture_output=True, text=True).stdout.split("\n")
|
||||
timings.append(_res[0])
|
||||
results.append(_res[2])
|
||||
python_timings, python_results = [], []
|
||||
julia_problem_numbers, julia_timings, julia_results = [], [], []
|
||||
for script in scripts[:5]:
|
||||
# _res = run(["python3", f"{script}"], capture_output=True, text=True).stdout.split("\n")
|
||||
_res = run(["julia", f"{script}"], capture_output=True, text=True).stdout.split("\n")
|
||||
# print(_res)
|
||||
# python_timings.append(_res[0])
|
||||
# python_results.append(_res[2])
|
||||
julia_problem_numbers.append(_res[0])
|
||||
julia_timings.append(_res[1].split("(")[0])
|
||||
julia_results.append(_res[3])
|
||||
|
||||
writer = MarkdownTableWriter(
|
||||
table_name="Project Euler Solutions",
|
||||
headers=["Problem #", "Result", "Execution time (Python)"],
|
||||
value_matrix=[[f"{int(t[26:28]):003d}", int(r[23:]), t[29:]] for t,r in zip(timings, results)],
|
||||
# headers=["Problem #", "Result", "Execution time (Python)"],
|
||||
headers=["Problem #", "Result", "Execution time (Julia)"],
|
||||
# value_matrix=[[f"{int(t[26:28]):003d}", int(r[23:]), t[29:]] for t,r in zip(python_timings, python_results)],
|
||||
value_matrix=[[f"{int(p[-2:-1]):03d}", int(r[23:]), t] for p,t,r in zip(julia_problem_numbers, julia_timings, julia_results)],
|
||||
column_styles=[
|
||||
Style(align="center"),
|
||||
Style(align="right", thousand_separator="_"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user