Skip to content

Commit c02ec5b

Browse files
committed
feat: adds bench/
1 parent b86b35e commit c02ec5b

File tree

6 files changed

+53
-1
lines changed

6 files changed

+53
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*.egg
77
*.egg-info/
88
*.pyc
9+
__pycache__
910
.cache/
1011
.coverage
1112
.coverage.*

bench/bench.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "Using python: $(which python3)"
6+
python --version
7+
8+
echo ">>> Bench pyais"
9+
python bench_pyais.py
10+
11+
echo ">>> Bench libais"
12+
python bench_libais.py

bench/bench_libais.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from pyais.exceptions import UnknownMessageException
2+
from pyais import FileReaderStream
3+
from collections import defaultdict
4+
import time
5+
import pathlib
6+
import ais.stream
7+
import json
8+
import ais.compatibility.gpsd
9+
10+
file = pathlib.Path(__file__).parent.joinpath('../tests/nmea-sample')
11+
stats = defaultdict(lambda: 0)
12+
start = time.time()
13+
14+
with open(file) as inf:
15+
for i, msg in enumerate(ais.stream.decode(inf)):
16+
stats[msg['id']] += 1
17+
18+
19+
print(stats)
20+
print(f'Decoded {i} NMEA AIS messages in {time.time() - start: .2f}s')
File renamed without changes.

bench/install.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "Using python: $(which python3)"
6+
7+
mkdir -p build
8+
cd build
9+
10+
if [ ! -d "libais" ]; then
11+
git clone git@github.com:schwehr/libais.git
12+
fi
13+
14+
cd libais
15+
uv pip install setuptools six
16+
python setup.py build
17+
python setup.py install
18+
19+
echo "Installed libais."

tests/test_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ def test_run_every_file(self):
3333
if csv_file.exists():
3434
csv_file.unlink()
3535

36-
assert i == 24
36+
assert i == 23

0 commit comments

Comments
 (0)