Skip to content

Commit

Permalink
test: add benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKevinWeiss committed May 3, 2023
1 parent cd30ee8 commit 4da9343
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install pytest
pip install pytest-benchmark
pip install .
- name: Run pytest
Expand Down
2 changes: 2 additions & 0 deletions pytest/test_simple_dep/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FOO = y
BAR = y
1 change: 1 addition & 0 deletions pytest/test_simple_dep/config.import100.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[kconfig_import("config.py") for _ in range(100)]
2 changes: 2 additions & 0 deletions pytest/test_simple_dep/config1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
for _ in range(1):
FOO.val = not FOO.val
2 changes: 2 additions & 0 deletions pytest/test_simple_dep/config100.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
for _ in range(100):
FOO.val = not FOO.val
54 changes: 54 additions & 0 deletions pytest/test_simple_dep/test_simple_dep_bench.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import os
import glob
import kconfiglib
import pytest

CUR_DIR = os.path.dirname(os.path.realpath(__file__))


def test_bench_config(benchmark):
"""Evaluate the performance standard config file."""
kconfig_path = CUR_DIR + '/Kconfig'

kconf = kconfiglib.Kconfig(kconfig_path)
benchmark(kconf.load_config, filename=CUR_DIR + '/app.config')


def test_bench_configpy(benchmark):
"""Evaluate the performance python config."""
kconfig_path = CUR_DIR + '/Kconfig'

kconf = kconfiglib.Kconfig(kconfig_path)
benchmark(kconf.load_config, filename=CUR_DIR + '/config.py')


def test_bench_import_configpy(benchmark):
"""Evaluate the performance of importing."""
kconfig_path = CUR_DIR + '/Kconfig'

kconf = kconfiglib.Kconfig(kconfig_path)
benchmark(kconf.load_config, filename=CUR_DIR + '/config.import.py')


def test_bench_import100_configpy(benchmark):
"""Evaluate the performance of importing foo 100 times."""
kconfig_path = CUR_DIR + '/Kconfig'

kconf = kconfiglib.Kconfig(kconfig_path)
benchmark(kconf.load_config, filename=CUR_DIR + '/config.import100.py')


def test_bench_config1_configpy(benchmark):
"""Evaluate the performance of setting foo 1 time."""
kconfig_path = CUR_DIR + '/Kconfig'

kconf = kconfiglib.Kconfig(kconfig_path)
benchmark(kconf.load_config, filename=CUR_DIR + '/config1.py')


def test_bench_config100_configpy(benchmark):
"""Evaluate the performance of setting foo 100 times."""
kconfig_path = CUR_DIR + '/Kconfig'

kconf = kconfiglib.Kconfig(kconfig_path)
benchmark(kconf.load_config, filename=CUR_DIR + '/config100.py')

0 comments on commit 4da9343

Please sign in to comment.