private function processSubject(SubjectMetadata $subject, $annotation) { if ($annotation instanceof Annotations\BeforeMethods) { $subject->setBeforeMethods($this->resolveValue($annotation, $subject->getBeforeMethods(), $annotation->getMethods())); } if ($annotation instanceof Annotations\AfterMethods) { $subject->setAfterMethods($this->resolveValue($annotation, $subject->getAfterMethods(), $annotation->getMethods())); } if ($annotation instanceof Annotations\ParamProviders) { $subject->setParamProviders($this->resolveValue($annotation, $subject->getParamProviders(), $annotation->getProviders())); } if ($annotation instanceof Annotations\Iterations) { $subject->setIterations($annotation->getIterations()); } if ($annotation instanceof Annotations\Sleep) { $subject->setSleep($annotation->getSleep()); } if ($annotation instanceof Annotations\Groups) { $subject->setGroups($this->resolveValue($annotation, $subject->getGroups(), $annotation->getGroups())); } if ($annotation instanceof Annotations\Revs) { $subject->setRevs($annotation->getRevs()); } if ($annotation instanceof Annotations\Warmup) { $subject->setWarmup($annotation->getRevs()); } if ($annotation instanceof Annotations\Skip) { $subject->setSkip(true); } if ($annotation instanceof Annotations\OutputTimeUnit) { $subject->setOutputTimeUnit($annotation->getTimeUnit()); $subject->setOutputTimePrecision($annotation->getPrecision()); } if ($annotation instanceof Annotations\OutputMode) { $subject->setOutputMode($annotation->getMode()); } }
/** * It should allow the sleep value to be overridden. * It should allow the warmup value to be overridden. * It should allow the revs value to be overridden. * It should allow the retry threshold value to be overridden. */ public function testOverrideThings() { $subject = new SubjectMetadata($this->benchmark->reveal(), 'name', 0); $subject->setSleep(50); $this->benchmark->getSubjects()->willReturn([$subject]); TestUtil::configureBenchmarkMetadata($this->benchmark); $test = $this; $this->executor->execute(Argument::type('PhpBench\\Benchmark\\Metadata\\SubjectMetadata'), Argument::type('PhpBench\\Model\\Iteration'), $this->executorConfig)->will(function ($args) use($test) { $iteration = $args[1]; $test->assertEquals(100, $iteration->getVariant()->getSubject()->getSleep()); $test->assertEquals(12, $iteration->getVariant()->getSubject()->getRetryThreshold()); $test->assertEquals(66, $iteration->getVariant()->getWarmup()); $test->assertEquals(88, $iteration->getVariant()->getRevolutions()); $callback = $test->loadIterationResultCallback(); $callback($args); }); $suite = $this->runner->run(new RunnerContext(__DIR__, ['sleep' => 100, 'retry_threshold' => 12, 'warmup' => [66], 'revolutions' => [88]])); $this->assertNoErrors($suite); }