Skip to content

Commit 774d93a

Browse files
committed
fix(bench): remove attribute hooks and lazy-init compiler
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 3a22cc8 commit 774d93a

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

benchmarks/CompilerBench.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,22 @@
99

1010
use LibreSign\XObjectTemplate\Dto\CompileRequest;
1111
use LibreSign\XObjectTemplate\XObjectTemplateCompiler;
12-
use PhpBench\Attributes\Iterations;
13-
use PhpBench\Attributes\OutputTimeUnit;
14-
use PhpBench\Attributes\Revs;
15-
use PhpBench\Attributes\Warmup;
16-
17-
#[Warmup(1)]
18-
#[Revs(5)]
19-
#[Iterations(10)]
20-
#[OutputTimeUnit('milliseconds')]
12+
2113
class CompilerBench
2214
{
23-
private XObjectTemplateCompiler $compiler;
15+
private ?XObjectTemplateCompiler $compiler = null;
2416

25-
public function setup(): void
17+
private function compiler(): XObjectTemplateCompiler
2618
{
27-
$this->compiler = new XObjectTemplateCompiler();
19+
$this->compiler ??= new XObjectTemplateCompiler();
20+
21+
return $this->compiler;
2822
}
2923

3024
public function benchSimpleHtml(): void
3125
{
3226
$html = '<div style="font-size:10;color:#000">Signed by Demo User</div><p style="font-size:9">Document approved</p>';
33-
$this->compiler->compile(new CompileRequest(html: $html, width: 240, height: 84));
27+
$this->compiler()->compile(new CompileRequest(html: $html, width: 240, height: 84));
3428
}
3529

3630
public function benchComplexHtml(): void
@@ -49,6 +43,6 @@ public function benchComplexHtml(): void
4943
<p>Signature validated and timestamp recorded.</p>
5044
</div>
5145
HTML;
52-
$this->compiler->compile(new CompileRequest(html: $html, width: 280, height: 120));
46+
$this->compiler()->compile(new CompileRequest(html: $html, width: 280, height: 120));
5347
}
5448
}

0 commit comments

Comments
 (0)