embedded-unit-converter/batch_test.py

22 lines
561 B
Python
Raw Normal View History

2019-11-05 22:35:04 -05:00
import random
import pytest
2019-11-06 09:24:35 -05:00
import unit_converter as rust
import py_unit_converter as py
2019-11-05 22:35:04 -05:00
@pytest.fixture(scope="module")
def batch_numbers():
return [random.random() * 100 for x in range(1000)]
# The larger the range of numbers, the closer the Rust version is to Python.
# e.g. return [random.random() * 100 for x in range(1000000)]
2019-11-05 22:35:04 -05:00
def test_using_python_batch(benchmark, batch_numbers):
2019-11-06 09:24:35 -05:00
benchmark(py.batch_converter, batch_numbers)
2019-11-05 22:35:04 -05:00
def test_using_rust_batch(benchmark, batch_numbers):
2019-11-06 09:24:35 -05:00
benchmark(rust.batch_converter, batch_numbers)