Skip to content

Commit 6620d73

Browse files
committed
Replace BenchWith with Bench in collider article
1 parent 973ffce commit 6620d73

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

blog/collider.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ Here's my reasoning:
2929

3030
> 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.
3131
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.
3333

3434
```php
35-
#[BenchWith(
35+
#[Bench(
3636
callables: [
3737
'in_array' => [self::class, 'sumInArray'],
3838
],
@@ -56,7 +56,7 @@ public static function sumInArray(int $a, int $b): int
5656
}
5757
```
5858

59-
With the `#[BenchWith]` attribute, we're telling Testo that:
59+
With the `#[Bench]` attribute, we're telling Testo that:
6060
- we want to compare the performance of the current function (`sumInCycle`) with another function (`sumInArray`);
6161
- both functions will receive the same arguments: `1` and `5_000`;
6262
- 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
9494
The smaller this coefficient, the more stable the results.
9595

9696
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.
9898

9999
Let's set `iterations: 10` and rerun:
100100

@@ -135,7 +135,7 @@ Of course, you could experiment with a larger range, enable JIT, and prove that
135135
but I want to draw your attention to how quick it is to benchmark something now!
136136

137137

138-
## BenchWith
138+
## Bench
139139

140140
![Shock](/blog/collider/img-04.png)
141141

public/blog/collider/img-04-ru.png

-825 Bytes
Loading

public/blog/collider/img-04.png

-863 Bytes
Loading

ru/blog/collider.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ PHP очень хорош в синтетических тестах, обгон
3030
> Решение на массивах будет медленнее цикла `for`, ведь дополнительные ресурсы уходят на вычисление хешей в хеш-таблице при создании массива,
3131
а ещё нужно больше памяти для промежуточных значений.
3232

33-
Давайте в этом убедимся: напишем функции и добавим атрибут `#[BenchWith]` на одну из функций.
33+
Давайте в этом убедимся: напишем функции и добавим атрибут `#[Bench]` на одну из функций.
3434

3535
```php
36-
#[BenchWith(
36+
#[Bench(
3737
callables: [
3838
'in_array' => [self::class, 'sumInArray'],
3939
],
@@ -57,7 +57,7 @@ public static function sumInArray(int $a, int $b): int
5757
}
5858
```
5959

60-
С помощью атрибута `#[BenchWith]` мы говорим Testo, что:
60+
С помощью атрибута `#[Bench]` мы говорим Testo, что:
6161
- хотим сравнить производительность текущей функции (`sumInCycle`) с другой функцией (`sumInArray`);
6262
- в обе функции будут передаваться одинаковые аргументы: `1` и `5_000`;
6363
- для замера времени каждая функция будет запущена 100 раз подряд (`calls: 100`).
@@ -95,7 +95,7 @@ Summary:
9595
Чем меньше этот коэффициент, тем стабильнее результаты.
9696

9797
Всё, что нам нужно сделать, — это получить больше данных, размазанных во времени, то есть перезапустить бенчмарки несколько раз.
98-
В атрибуте `#[BenchWith]` есть параметр `iterations`, который и отвечает за количество перезапусков бенчмарков.
98+
В атрибуте `#[Bench]` есть параметр `iterations`, который и отвечает за количество перезапусков бенчмарков.
9999

100100
Выставим `iterations: 10` и перезапустим:
101101

@@ -136,7 +136,7 @@ Summary:
136136
но я хочу обратить ваше внимание на то, как быстро теперь можно что-то забенчить!
137137

138138

139-
## BenchWith
139+
## Bench
140140

141141
![Шок](/blog/collider/img-04-ru.png)
142142

0 commit comments

Comments
 (0)