|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Koded\Logging\Tests\PhpBench; |
| 4 | + |
| 5 | +use Koded\Logging\Log; |
| 6 | + |
| 7 | +/** |
| 8 | + * @BeforeMethods({"setUp"}) |
| 9 | + * @AfterMethods({"tearDown"}) |
| 10 | + * @OutputTimeUnit("milliseconds") |
| 11 | + */ |
| 12 | +abstract class AbstractBench |
| 13 | +{ |
| 14 | + /** |
| 15 | + * @var Log |
| 16 | + */ |
| 17 | + protected $log; |
| 18 | + |
| 19 | + public function setUp(): void |
| 20 | + { |
| 21 | + $this->log = new Log($this->getConfig()); |
| 22 | + } |
| 23 | + |
| 24 | + public function tearDown(): void |
| 25 | + { |
| 26 | + $this->log = null; |
| 27 | + } |
| 28 | + |
| 29 | + abstract protected function getConfig(): array; |
| 30 | + |
| 31 | + protected function message(): array |
| 32 | + { |
| 33 | + $messages = [ |
| 34 | + ['One morning, when {1} woke from troubled dreams, he found himself {2} in his bed into a {3}.', ['1' => 'Gregor Samsa', '2' => 'transformed', '3' => 'horrible vermin']], |
| 35 | + ['He lay on his {back}, and if he lifted his head a little he could see his brown belly, slightly {state} by arches into stiff sections.', ['back' => 'armour-like back', 'state' => 'domed and divided']], |
| 36 | + ['The bedding was hardly able to cover it and seemed ready to slide off any moment.', ['' => '', '' => '', '' => '']], |
| 37 | + ['His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked.', ['' => '', '' => '', '' => '']], |
| 38 | + ['"What\'s happened to {0}?" he thought. It wasn\'t a {1}.', ['me', 'dream']], |
| 39 | + ['His room, a proper {room} although a little too small, lay peacefully {position} familiar walls.', ['room' => 'human room', 'position' => 'between its four']], |
| 40 | + ['A collection of textile samples lay spread out on the table - {name} was a travelling salesman - and above it there hung a picture that he had recently cut out of an {object} and housed in a nice, gilded frame.', ['name' => 'Samsa', 'object' => 'illustrated magazine']], |
| 41 | + ['It showed a {someone} who sat upright, raising a {something} that covered {somewhere} towards the viewer. ', ['someone' => 'lady fitted out with a fur hat and fur boa', 'something' => 'heavy fur muff', 'somewhere' => 'the whole of her lower arm']], |
| 42 | + ]; |
| 43 | + |
| 44 | + return $messages[rand(0, 7)]; |
| 45 | + } |
| 46 | +} |
0 commit comments