You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blog/collider.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,10 +29,10 @@ Here's my reasoning:
29
29
30
30
> The array solution should be slower than the `for` loop, since extra resources go into computing hashes for the hash table when creating the array, and more memory is needed for intermediate values.
31
31
32
-
Let's verify this: we'll write the functions and add the `#[BenchWith]` attribute to one of them.
32
+
Let's verify this: we'll write the functions and add the `#[Bench]` attribute to one of them.
33
33
34
34
```php
35
-
#[BenchWith(
35
+
#[Bench(
36
36
callables: [
37
37
'in_array' => [self::class, 'sumInArray'],
38
38
],
@@ -56,7 +56,7 @@ public static function sumInArray(int $a, int $b): int
56
56
}
57
57
```
58
58
59
-
With the `#[BenchWith]` attribute, we're telling Testo that:
59
+
With the `#[Bench]` attribute, we're telling Testo that:
60
60
- we want to compare the performance of the current function (`sumInCycle`) with another function (`sumInArray`);
61
61
- both functions will receive the same arguments: `1` and `5_000`;
62
62
- to measure execution time, each function will be called 100 times in a row (`calls: 100`).
@@ -94,7 +94,7 @@ Statistics comes to the rescue with the [coefficient of variation](https://en.wi
94
94
The smaller this coefficient, the more stable the results.
95
95
96
96
All we need to do is collect more data spread over time — that is, rerun the benchmarks multiple times.
97
-
The `#[BenchWith]` attribute has an `iterations` parameter responsible for the number of benchmark reruns.
97
+
The `#[Bench]` attribute has an `iterations` parameter responsible for the number of benchmark reruns.
98
98
99
99
Let's set `iterations: 10` and rerun:
100
100
@@ -135,7 +135,7 @@ Of course, you could experiment with a larger range, enable JIT, and prove that
135
135
but I want to draw your attention to how quick it is to benchmark something now!
0 commit comments