mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
up
This commit is contained in:
parent
b7ca9dfa33
commit
ce6dba5240
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
|||||||
mv src/pocketpy.h src/pocketpy.cpp
|
mv src/pocketpy.h src/pocketpy.cpp
|
||||||
CL -std:c++17 -GR- -EHsc -O2 -LD -Fe:pocketpy src/pocketpy.cpp
|
CL -std:c++17 -GR- -EHsc -O2 -LD -Fe:pocketpy src/pocketpy.cpp
|
||||||
python3 scripts/run_tests.py
|
python3 scripts/run_tests.py
|
||||||
python3 scripts/run_tests.py benchmarks/
|
python3 scripts/run_tests.py benchmark
|
||||||
mkdir -p output/windows/x86_64
|
mkdir -p output/windows/x86_64
|
||||||
mv pocketpy.exe output/windows/x86_64
|
mv pocketpy.exe output/windows/x86_64
|
||||||
mv pocketpy.dll output/windows/x86_64
|
mv pocketpy.dll output/windows/x86_64
|
||||||
@ -54,7 +54,7 @@ jobs:
|
|||||||
bash build_cpp.sh
|
bash build_cpp.sh
|
||||||
bash build_linux.sh
|
bash build_linux.sh
|
||||||
python3 scripts/run_tests.py
|
python3 scripts/run_tests.py
|
||||||
python3 scripts/run_tests.py benchmarks/
|
python3 scripts/run_tests.py benchmark
|
||||||
mkdir -p output/linux/x86_64
|
mkdir -p output/linux/x86_64
|
||||||
mv pocketpy output/linux/x86_64
|
mv pocketpy output/linux/x86_64
|
||||||
mv pocketpy.so output/linux/x86_64
|
mv pocketpy.so output/linux/x86_64
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
import time
|
|
||||||
_0 = time.time()
|
|
||||||
|
|
||||||
UPPER_BOUND = 5000000
|
UPPER_BOUND = 5000000
|
||||||
PREFIX = 32338
|
PREFIX = 32338
|
||||||
|
|
||||||
@ -112,5 +109,3 @@ def verify():
|
|||||||
verify()
|
verify()
|
||||||
results = find(UPPER_BOUND, PREFIX)
|
results = find(UPPER_BOUND, PREFIX)
|
||||||
assert results == [323381, 323383, 3233803, 3233809, 3233851, 3233863, 3233873, 3233887, 3233897]
|
assert results == [323381, 323383, 3233803, 3233809, 3233851, 3233863, 3233873, 3233887, 3233897]
|
||||||
|
|
||||||
print(round(time.time()-_0, 6), 's')
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
import time
|
|
||||||
_0 = time.time()
|
|
||||||
|
|
||||||
def is_prime(x):
|
def is_prime(x):
|
||||||
if x<2:
|
if x<2:
|
||||||
return False
|
return False
|
||||||
@ -21,4 +18,3 @@ def test(n):
|
|||||||
# dis(is_prime)
|
# dis(is_prime)
|
||||||
|
|
||||||
print(test(10000))
|
print(test(10000))
|
||||||
print(round(time.time()-_0, 6), 's')
|
|
@ -1,9 +1,4 @@
|
|||||||
import time
|
|
||||||
_0 = time.time()
|
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
a = [random.randint(-100000, 100000) for i in range(1500)]
|
a = [random.randint(-100000, 100000) for i in range(100000)]
|
||||||
a = sorted(a)
|
a = sorted(a)
|
||||||
|
|
||||||
print(round(time.time()-_0, 6), 's')
|
|
@ -1,31 +1,38 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
def test_file(filepath):
|
def test_file(filepath, cpython=False):
|
||||||
|
if cpython:
|
||||||
|
return os.system("python3 " + filepath) == 0
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
return os.system("pocketpy.exe " + filepath) == 0
|
return os.system("pocketpy.exe " + filepath) == 0
|
||||||
else:
|
else:
|
||||||
return os.system("./pocketpy " + filepath) == 0
|
return os.system("./pocketpy " + filepath) == 0
|
||||||
|
|
||||||
def test_dir(path):
|
def test_dir(path):
|
||||||
has_error = False
|
print("Testing directory:", path)
|
||||||
for filename in os.listdir(path):
|
for filename in os.listdir(path):
|
||||||
if not filename.endswith('.py'):
|
if not filename.endswith('.py'):
|
||||||
continue
|
continue
|
||||||
filepath = os.path.join(path, filename)
|
filepath = os.path.join(path, filename)
|
||||||
print("> " + filepath)
|
print("> " + filepath)
|
||||||
code = test_file(filepath)
|
|
||||||
if not code:
|
|
||||||
has_error = True
|
|
||||||
exit(1)
|
|
||||||
return not has_error
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if path == 'benchmarks/':
|
||||||
if len(sys.argv) > 1:
|
_0 = time.time()
|
||||||
d = sys.argv[1]
|
if not test_file(filepath, cpython=True): exit(1)
|
||||||
|
_1 = time.time()
|
||||||
|
if not test_file(filepath): exit(1)
|
||||||
|
_2 = time.time()
|
||||||
|
print(f' cpython: {_1 - _0:.6f}s (100%)')
|
||||||
|
print(f' pocketpy: {_2 - _1:.6f}s ({(_2 - _1) / (_1 - _0) * 100:.2f}%)')
|
||||||
|
else:
|
||||||
|
if not test_file(filepath): exit(1)
|
||||||
|
|
||||||
|
if len(sys.argv) == 2:
|
||||||
|
assert sys.argv[1] == 'benchmark'
|
||||||
|
d = 'benchmarks/'
|
||||||
else:
|
else:
|
||||||
d = 'tests/'
|
d = 'tests/'
|
||||||
print("Testing directory:", d)
|
test_dir(d)
|
||||||
ok = test_dir(d)
|
|
||||||
if ok:
|
|
||||||
print("ALL TESTS PASSED")
|
print("ALL TESTS PASSED")
|
Loading…
x
Reference in New Issue
Block a user