We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 547fad1 commit 4f60a18Copy full SHA for 4f60a18
tests/benchmarks/test_bench_doc.py
@@ -0,0 +1,24 @@
1
+"""Benches from the CodSpeed Getting Started Documentation."""
2
+
3
+import pytest
4
5
6
+def sum_of_squares_fast(arr) -> int:
7
+ total = 0
8
+ for x in arr:
9
+ total += x * x
10
+ return total
11
12
13
+def sum_of_squares_slow(arr) -> int:
14
+ return sum(map(lambda x: x**2, arr)) # noqa: C417
15
16
17
+@pytest.mark.benchmark
18
+def test_sum_squares_fast():
19
+ assert sum_of_squares_fast(range(1000)) == 332833500
20
21
22
23
+def test_sum_squares_slow():
24
+ assert sum_of_squares_slow(range(1000)) == 332833500
0 commit comments