PhpBench\Extensions\Dbal\Storage\Driver\Dbal\Persister::persist PHP Method

persist() public method

public persist ( SuiteCollection $collection )
$collection PhpBench\Model\SuiteCollection
    public function persist(SuiteCollection $collection)
    {
        $conn = $this->manager->getConnection();
        foreach ($collection->getSuites() as $suite) {
            $summary = $suite->getSummary();
            $id = $this->insertUpdate($conn, 'run', ['uuid' => $suite->getUuid(), 'context' => $suite->getContextName(), 'date' => $suite->getDate()->format('Y-m-d H:i:s'), 'nb_subjects' => $summary->getNbSubjects(), 'nb_iterations' => $summary->getNbIterations(), 'nb_revolutions' => $summary->getNbRevolutions(), 'min_time' => $summary->getMinTime(), 'max_time' => $summary->getMaxTime(), 'mean_time' => $summary->getMeanTime(), 'mean_rstdev' => $summary->getMeanRelStDev(), 'total_time' => $summary->getTotalTime()]);
            $envData = [];
            foreach ($suite->getEnvInformations() as $information) {
                foreach ($information as $key => $value) {
                    $envData[] = ['run_id' => $id, 'provider' => $information->getName(), 'ekey' => $key, 'value' => $value];
                }
            }
            $this->insertMultiple($conn, 'environment', $envData);
            $iterationDatas = [];
            $parameterAssocs = [];
            foreach ($suite->getBenchmarks() as $benchmark) {
                foreach ($benchmark->getSubjects() as $subject) {
                    $data = ['benchmark' => $benchmark->getClass(), 'name' => $subject->getName()];
                    $subjectId = $this->getSubjectId($conn, $data['benchmark'], $data['name']);
                    $subjectId = $this->insertUpdate($conn, 'subject', $data, $subjectId);
                    foreach ($subject->getGroups() as $groupName) {
                        $this->associateGroup($conn, $subjectId, $groupName);
                    }
                    foreach ($subject->getVariants() as $variant) {
                        $data = ['revolutions' => $variant->getRevolutions(), 'retry_threshold' => $subject->getRetryThreshold(), 'output_time_unit' => $subject->getOutputTimeUnit(), 'output_time_precision' => $subject->getOutputTimePrecision(), 'output_mode' => $subject->getOutputMode(), 'sleep' => $subject->getSleep(), 'warmup' => $variant->getWarmup(), 'subject_id' => $subjectId, 'run_id' => $id];
                        $variantId = $this->insertUpdate($conn, 'variant', $data);
                        foreach ($variant->getParameterSet() as $key => $value) {
                            $value = json_encode($value);
                            $parameterId = $this->getOrCreateParameter($conn, $key, $value);
                            $parameterAssocs[] = ['variant_id' => $variantId, 'parameter_id' => $parameterId];
                        }
                        foreach ($variant as $iteration) {
                            $iterationDatas[] = ['time' => $iteration->getMetric(TimeResult::class, 'net', null), 'memory' => $iteration->getMetricOrDefault(MemoryResult::class, 'peak', -1), 'reject_count' => $iteration->getMetricOrDefault(RejectionCountResult::class, 'count', 0), 'variant_id' => $variantId];
                        }
                    }
                }
            }
            // insert the iterations and variant parameter relations in batch
            $this->insertMultiple($conn, 'iteration', $iterationDatas);
            $this->insertMultiple($conn, 'variant_parameter', $parameterAssocs);
        }
    }