mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-19 19:10:17 +00:00
...
This commit is contained in:
parent
13f691bc37
commit
5f7006e2cb
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -83,7 +83,7 @@ jobs:
|
||||
uses: jirutka/setup-alpine@v1
|
||||
with:
|
||||
arch: x86
|
||||
packages: gcc make cmake libc-dev linux-headers python3
|
||||
packages: gcc g++ make cmake libc-dev linux-headers python3
|
||||
- name: Build and Test
|
||||
run: |
|
||||
uname -m
|
||||
|
@ -1,46 +0,0 @@
|
||||
try:
|
||||
import os
|
||||
except ImportError:
|
||||
exit(0)
|
||||
|
||||
import sys
|
||||
is_pkpy = not hasattr(sys, 'getrefcount')
|
||||
|
||||
os.chdir('benchmarks')
|
||||
|
||||
if is_pkpy:
|
||||
try:
|
||||
import cjson as json
|
||||
except ImportError:
|
||||
print('[cJSON not Enabled]')
|
||||
exit(0)
|
||||
else:
|
||||
import json
|
||||
|
||||
_2489KB = 'WorldMap_GridVania_layout.ldtk'
|
||||
_1093KB = 'WorldMap_Free_layout.ldtk'
|
||||
_339KB = 'Typical_2D_platformer_example.ldtk'
|
||||
|
||||
with open(f'res/{_2489KB}', 'r') as f:
|
||||
json_content = f.read()
|
||||
|
||||
data: dict = json.loads(json_content)
|
||||
assert isinstance(data, dict)
|
||||
|
||||
# serialize and deserialize
|
||||
dumped: str = json.dumps(data)
|
||||
for _ in range(10):
|
||||
loaded: dict = json.loads(dumped)
|
||||
assert len(data) == len(loaded)
|
||||
assert data == loaded
|
||||
|
||||
#### very very slow!!
|
||||
import pickle
|
||||
|
||||
with open(f'res/{_339KB}', 'r') as f:
|
||||
json_content = f.read()
|
||||
data: dict = json.loads(json_content)
|
||||
|
||||
data_pickled: bytes = pickle.dumps(data)
|
||||
assert isinstance(data_pickled, bytes)
|
||||
assert pickle.loads(data_pickled) == data
|
@ -1,7 +1,4 @@
|
||||
try:
|
||||
import os
|
||||
except ImportError:
|
||||
exit(0)
|
||||
exit(0)
|
||||
|
||||
os.chdir('benchmarks')
|
||||
|
||||
|
@ -1,20 +1,15 @@
|
||||
import sys
|
||||
|
||||
is_cpython = hasattr(sys, 'getrefcount')
|
||||
class vec2:
|
||||
def __init__(self, x, y):
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
if is_cpython:
|
||||
class vec2:
|
||||
def __init__(self, x, y):
|
||||
self.x = x
|
||||
self.y = y
|
||||
def __add__(self, other):
|
||||
return vec2(self.x + other.x, self.y + other.y)
|
||||
|
||||
def __add__(self, other):
|
||||
return vec2(self.x + other.x, self.y + other.y)
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.x == other.x and self.y == other.y
|
||||
else:
|
||||
from linalg import vec2
|
||||
def __eq__(self, other):
|
||||
return self.x == other.x and self.y == other.y
|
||||
|
||||
x = vec2(0, 0)
|
||||
for i in range(10000000):
|
||||
|
Loading…
x
Reference in New Issue
Block a user