File tree Expand file tree Collapse file tree 4 files changed +22
-36
lines changed
Expand file tree Collapse file tree 4 files changed +22
-36
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -23,7 +23,25 @@ public function __construct(
2323 * It might be a callable or an array with class name and non-public method name.
2424 */
2525 public readonly array $ callables ,
26+
27+ /**
28+ * @var array Arguments to pass to the benchmarked functions.
29+ */
2630 public readonly array $ arguments = [],
27- public readonly BenchOptions $ options = new BenchOptions (),
28- ) {}
31+
32+ /**
33+ * @var int<1, max> Number of iterations to run for each benchmark.
34+ */
35+ public readonly int $ iterations = 1000 ,
36+
37+ /**
38+ * @var int<1, max> Number of revolutions to run for each benchmark.
39+ * A revolution is a single execution of the benchmarked function.
40+ */
41+ public readonly int $ revolutions = 5 ,
42+ ) {
43+ \count ($ callables ) < 1 or throw new \InvalidArgumentException ('At least one callable must be provided. ' );
44+ $ iterations > 0 or throw new \InvalidArgumentException ('Iterations must be greater than 0. ' );
45+ $ revolutions > 0 or throw new \InvalidArgumentException ('Revolutions must be greater than 0. ' );
46+ }
2947}
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ public function __invoke(TestInfo $info): mixed
3939
4040 Benchmark::start ()
4141 ->withoutData ()
42- ->iterations ($ attr ->options -> iterations )
42+ ->iterations ($ attr ->iterations )
4343 ->compare (
4444 ...$ functions ,
4545 );
Original file line number Diff line number Diff line change 44
55namespace Tests \Bench \Self ;
66
7- use Testo \Bench \BenchOptions ;
87use Testo \Bench \BenchWith ;
98
109final class BenchWithAttr
@@ -15,9 +14,7 @@ final class BenchWithAttr
1514 [self ::class, 'sumSlow ' ],
1615 ],
1716 arguments: [1 , 2 ],
18- options: new BenchOptions (
19- iterations: 10_000 ,
20- )
17+ iterations: 10_000 ,
2118 )]
2219 public static function sumFast (int $ a , int $ b ): int
2320 {
You can’t perform that action at this time.
0 commit comments