99
1010use LibreSign \XObjectTemplate \Dto \CompileRequest ;
1111use 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+
2113class 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>
5145HTML;
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