Skip to content

Instantly share code, notes, and snippets.

@srijan-paul
Last active July 18, 2021 10:03
Show Gist options
  • Save srijan-paul/84317b593af69db62ae319d645ef81f7 to your computer and use it in GitHub Desktop.
Save srijan-paul/84317b593af69db62ae319d645ef81f7 to your computer and use it in GitHub Desktop.
import os
N = 1
def decls():
global N
s = ""
for i in range(1, N + 1):
s = s + f"\tlocal a{i}: integer = {i}" + '\n'
return s
def capture():
global N
s = ""
for i in range(1, N + 1):
s = s + f"\t\ta{i} = a{i} * 2" + '\n'
return s
def genfile():
f = open("temp/out.pln", "w")
template = f"""
local m: module = {{}}
function m.bench(N: integer): boolean
{decls()}
local f: () -> () = function ()
{capture()}
end
for i = 1, N do
f()
end
return true
end
return m"""
f.write(template)
f.close()
os.system("./pallenec --emit-c temp/out.pln")
os.system("./pallenec temp/out.pln -o temp/out_no_merge.so")
os.system(f"python3 edit.py {N}")
os.system("./pallenec --compile-c temp/out.c")
N = int(input("#upvalues (1 - 200): "))
genfile()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment