diff options
Diffstat (limited to 'testing/web-platform/tests/tools/pytest/bench')
5 files changed, 56 insertions, 0 deletions
diff --git a/testing/web-platform/tests/tools/pytest/bench/bench.py b/testing/web-platform/tests/tools/pytest/bench/bench.py new file mode 100644 index 000000000..ce9496417 --- /dev/null +++ b/testing/web-platform/tests/tools/pytest/bench/bench.py @@ -0,0 +1,12 @@ +import sys + +if __name__ == '__main__': + import cProfile + import pytest + import pstats + script = sys.argv[1:] if len(sys.argv) > 1 else "empty.py" + stats = cProfile.run('pytest.cmdline.main(%r)' % script, 'prof') + p = pstats.Stats("prof") + p.strip_dirs() + p.sort_stats('cumulative') + print(p.print_stats(500)) diff --git a/testing/web-platform/tests/tools/pytest/bench/bench_argcomplete.py b/testing/web-platform/tests/tools/pytest/bench/bench_argcomplete.py new file mode 100644 index 000000000..d66c664f3 --- /dev/null +++ b/testing/web-platform/tests/tools/pytest/bench/bench_argcomplete.py @@ -0,0 +1,19 @@ + + +# 10000 iterations, just for relative comparison +# 2.7.5 3.3.2 +# FilesCompleter 75.1109 69.2116 +# FastFilesCompleter 0.7383 1.0760 + + +if __name__ == '__main__': + import sys + import timeit + from argcomplete.completers import FilesCompleter + from _pytest._argcomplete import FastFilesCompleter + count = 1000 # only a few seconds + setup = 'from __main__ import FastFilesCompleter\nfc = FastFilesCompleter()' + run = 'fc("/d")' + sys.stdout.write('%s\n' % (timeit.timeit(run, + setup=setup.replace('Fast', ''), number=count))) + sys.stdout.write('%s\n' % (timeit.timeit(run, setup=setup, number=count))) diff --git a/testing/web-platform/tests/tools/pytest/bench/empty.py b/testing/web-platform/tests/tools/pytest/bench/empty.py new file mode 100644 index 000000000..ac5e25701 --- /dev/null +++ b/testing/web-platform/tests/tools/pytest/bench/empty.py @@ -0,0 +1,3 @@ +import py +for i in range(1000): + py.builtin.exec_("def test_func_%d(): pass" % i) diff --git a/testing/web-platform/tests/tools/pytest/bench/manyparam.py b/testing/web-platform/tests/tools/pytest/bench/manyparam.py new file mode 100644 index 000000000..d2bca0e8a --- /dev/null +++ b/testing/web-platform/tests/tools/pytest/bench/manyparam.py @@ -0,0 +1,12 @@ + +import pytest + +@pytest.fixture(scope='module', params=range(966)) +def foo(request): + return request.param + +def test_it(foo): + pass +def test_it2(foo): + pass + diff --git a/testing/web-platform/tests/tools/pytest/bench/skip.py b/testing/web-platform/tests/tools/pytest/bench/skip.py new file mode 100644 index 000000000..960b30864 --- /dev/null +++ b/testing/web-platform/tests/tools/pytest/bench/skip.py @@ -0,0 +1,10 @@ + +import pytest + + +SKIP = True + +@pytest.mark.parametrize("x", xrange(5000)) +def test_foo(x): + if SKIP: + pytest.skip("heh") |