Skip to content

Commit

Permalink
chore: adds bench.py
Browse files Browse the repository at this point in the history
  • Loading branch information
M0r13n committed Sep 28, 2024
1 parent 7ac7cc5 commit d7312d8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions examples/bench.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pathlib
import time
from collections import defaultdict
from pyais import FileReaderStream
from pyais.exceptions import UnknownMessageException

file = pathlib.Path(__file__).parent.joinpath('../tests/nmea-sample')
stats = defaultdict(lambda: 0)
start = time.time()

for i, msg in enumerate(FileReaderStream(file), 1):
try:
decoded = msg.decode()
stats[decoded.msg_type] += 1
except UnknownMessageException:
stats['errors'] += 1


print(stats)
print(f'Decoded {i} NMEA AIS messages in {time.time() - start: .2f}s')

0 comments on commit d7312d8

Please sign in to comment.