Skip to content

Commit

Permalink
Add svg to performance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ihabunek committed Jul 3, 2024
1 parent b780add commit 77d515e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tests/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from datetime import datetime
from pdf417gen import encode, render_image
from pdf417gen import encode, render_image, render_svg

ZEN = """
Beautiful is better than ugly.
Expand All @@ -28,23 +28,33 @@
""".strip()


def test_encode(cycles=1000):
def test_encode(cycles=100):
start = datetime.now()
for _ in range(cycles):
encode(ZEN)
duration = datetime.now() - start
print("Encode x{}: {}".format(cycles, duration))


def test_render_image(cycles=1000):
def test_render_image(cycles=100):
codes = encode(ZEN)
start = datetime.now()
for _ in range(cycles):
render_image(codes)
duration = datetime.now() - start
print("Render x{}: {}".format(cycles, duration))
print("Render image x{}: {}".format(cycles, duration))


def test_render_svg(cycles=100):
codes = encode(ZEN)
start = datetime.now()
for _ in range(cycles):
render_svg(codes)
duration = datetime.now() - start
print("Render SVG x{}: {}".format(cycles, duration))


if __name__ == "__main__":
test_encode()
test_render_image()
test_render_svg()

0 comments on commit 77d515e

Please sign in to comment.