mirror of
https://github.com/Noratrieb/benchmarks.git
synced 2026-01-14 10:45:04 +01:00
lmao python
This commit is contained in:
parent
a8eacce3c8
commit
4b0ec1a437
2 changed files with 33 additions and 3 deletions
|
|
@ -3,10 +3,13 @@
|
|||
Find all primes from 0 to 10 000 000.
|
||||
Printing time is not included.
|
||||
|
||||
There are probably some issues in the code since this result seems a bit *questionable*
|
||||
There are probably some issues in the code since this result seems a bit *questionable*
|
||||
Although I can understand that JS is extremly fast, this is the perfect benchmark for JS,
|
||||
and we should never forget that V8 is... **fast**.
|
||||
|
||||
| Language | Time |
|
||||
| ---------| -------|
|
||||
| Java | 1836ms |
|
||||
| Javascript | 1778.2ms |
|
||||
| Rust | 1818ms |
|
||||
| Javascript | 1778ms |
|
||||
| Rust | 1818ms |
|
||||
| python3 | 34361ms |
|
||||
27
primes/python/primes.py
Normal file
27
primes/python/primes.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import time
|
||||
from math import sqrt
|
||||
|
||||
|
||||
def primes(max):
|
||||
primes_list = [2]
|
||||
|
||||
for i in range(3, max):
|
||||
is_prime = True
|
||||
for prime in primes_list:
|
||||
if prime > sqrt(i):
|
||||
break
|
||||
if i % prime == 0:
|
||||
is_prime = False
|
||||
break
|
||||
|
||||
if is_prime:
|
||||
primes_list.append(i)
|
||||
|
||||
return primes_list
|
||||
|
||||
|
||||
start_millis = round(time.time() * 1000)
|
||||
primes(10_000_000)
|
||||
total_millis = round(time.time() * 1000) - start_millis
|
||||
|
||||
print(total_millis)
|
||||
Loading…
Add table
Add a link
Reference in a new issue