Open
Description
Benchmark:
from ltypes import i32
def is_prime(n: i32) -> bool:
factors: i32
factors = 0
i: i32
for i in range(2, n):
if n % i == 0:
factors += 1
return factors == 0
def main():
limit: i32
limit = 20000
total: i32
total = 0
i: i32
for i in range(2, limit):
if is_prime(i):
total += 1
print(total)
CPython 3.10.2 speed on Apple M1 Max:
$ time PYTHONPATH=~/repos/lpython/src/runtime/ltypes python a.py
2262
PYTHONPATH=~/repos/lpython/src/runtime/ltypes python a.py 5.82s user 0.01s system 99% cpu 5.841 total
LPython speed:
$ lpython --fast a.py
$ time ./a.out
2262
./a.out 0.10s user 0.00s system 95% cpu 0.104 total
So about 55x speedup.
Metadata
Metadata
Assignees
Labels
No labels