setBeforeClassMethods() 공개 메소드

Set any methods that should be called before the benchmark class is executed.
public setBeforeClassMethods ( array $beforeClassMethods )
$beforeClassMethods array
예제 #1
0
 private function buildBenchmarkMetadata(BenchmarkMetadata $classMetadata, ReflectionHierarchy $hierarchy)
 {
     $annotations = array();
     $reflectionHierarchy = array_reverse(iterator_to_array($hierarchy));
     foreach ($reflectionHierarchy as $reflection) {
         $benchAnnotations = $this->docParser->parse($reflection->comment, sprintf('benchmark %s', $reflection->class));
         $annotations = array_merge($annotations, $benchAnnotations);
         foreach ($benchAnnotations as $annotation) {
             if ($annotation instanceof BeforeClassMethods) {
                 $classMetadata->setBeforeClassMethods($annotation->getMethods());
             }
             if ($annotation instanceof AfterClassMethods) {
                 $classMetadata->setAfterClassMethods($annotation->getMethods());
             }
             $this->processAbstractMetadata($classMetadata, $annotation);
         }
     }
     foreach ($reflectionHierarchy as $reflection) {
         foreach ($reflection->methods as $reflectionMethod) {
             if ('bench' !== substr($reflectionMethod->name, 0, 5)) {
                 continue;
             }
             $subjectMetadata = $classMetadata->getOrCreateSubjectMetadata($reflectionMethod->name);
             // apply the benchmark annotations to the subject
             foreach ($annotations as $annotation) {
                 $this->processAbstractMetadata($subjectMetadata, $annotation);
             }
             $this->buildSubjectMetadata($subjectMetadata, $reflectionMethod);
             $classMetadata->setSubjectMetadata($subjectMetadata);
         }
     }
 }
예제 #2
0
 public function processBenchmark(BenchmarkMetadata $benchmark, $annotation)
 {
     if ($annotation instanceof BeforeClassMethods) {
         $benchmark->setBeforeClassMethods($annotation->getMethods());
     }
     if ($annotation instanceof AfterClassMethods) {
         $benchmark->setAfterClassMethods($annotation->getMethods());
     }
 }