Tak is a simple benchmark function. This repo contains some scripts I wrote to test various language implementations.
It is defined as follows:
def tak(x, y, z):
if y < x:
return tak(
tak(x - 1, y, z),
tak(y - 1, z, x),
tak(z - 1, x, y),
)
else:
return z
Current results - x = 48, y = 20, z = 12 - M1 MacBook Pro:
rust | 0:00:00.973172
c | 0:00:01.007381
luajit | 0:00:03.208017
factor | 0:00:06.010207
gforth | 0:00:13.519273
uxntal | 0:00:16.565155
lua | 0:00:17.558004
python | 0:00:33.063282
Note that Factor does not currently support arm64 processors, so it is running through Rosetta 2 translation in this run.
I'd love to build up a collection of more languages, and while I plan to implement some more myself, I won't say no to help!
The general requirements for adding a new language:
- Create a new folder for the language.
- Add the implementation - usually named
tak.foo
, wherefoo
is the relevant extension. - Add
run.sh
, which passes three arguments$1
,$2
and$3
to the program. - For compiled languages, add
build.sh
to generate the compiled output. - The program must read the values of x, y, and z from
argv
. - The program must produce some sort of output, as this makes verification and debugging easier.
- The program must implement the Tak function as specified above - I'm interested in raw performance, not the number of clever optimisations you can make.