当前位置: 首页>>代码示例>>PHP>>正文


PHP DOMElement::appendElement方法代码示例

本文整理汇总了PHP中DOMElement::appendElement方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMElement::appendElement方法的具体用法?PHP DOMElement::appendElement怎么用?PHP DOMElement::appendElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DOMElement的用法示例。


在下文中一共展示了DOMElement::appendElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processVariant

 private function processVariant(Subject $subject, Variant $variant, \DOMElement $subjectEl)
 {
     $variantEl = $subjectEl->appendElement('variant');
     // TODO: These attributes should be on the subject, see
     // https://github.com/phpbench/phpbench/issues/307
     $variantEl->setAttribute('sleep', $subject->getSleep());
     $variantEl->setAttribute('output-time-unit', $subject->getOutputTimeUnit() ?: TimeUnit::MICROSECONDS);
     $variantEl->setAttribute('output-time-precision', $subject->getOutputTimePrecision());
     $variantEl->setAttribute('output-mode', $subject->getOutputMode() ?: TimeUnit::MODE_TIME);
     $variantEl->setAttribute('revs', $variant->getRevolutions());
     $variantEl->setAttribute('warmup', $variant->getWarmup());
     $variantEl->setAttribute('retry-threshold', $subject->getRetryThreshold());
     foreach ($variant->getParameterSet() as $name => $value) {
         $this->createParameter($variantEl, $name, $value);
     }
     if ($variant->hasErrorStack()) {
         $errorsEl = $variantEl->appendElement('errors');
         foreach ($variant->getErrorStack() as $error) {
             $errorEl = $errorsEl->appendElement('error', $error->getMessage());
             $errorEl->setAttribute('exception-class', $error->getClass());
             $errorEl->setAttribute('code', $error->getCode());
             $errorEl->setAttribute('file', $error->getFile());
             $errorEl->setAttribute('line', $error->getLine());
         }
         return;
     }
     $stats = $variant->getStats();
     $stats = iterator_to_array($stats);
     $resultClasses = [];
     // ensure same order (for testing)
     ksort($stats);
     foreach ($variant as $iteration) {
         $iterationEl = $variantEl->appendElement('iteration');
         foreach ($iteration->getResults() as $result) {
             // we need to store the class FQNs of the results for deserialization later.
             if (!isset($resultClasses[$result->getKey()])) {
                 $resultClasses[$result->getKey()] = get_class($result);
             }
             $prefix = $result->getKey();
             $metrics = $result->getMetrics();
             foreach ($metrics as $key => $value) {
                 $iterationEl->setAttribute(sprintf('%s-%s', $prefix, str_replace('_', '-', $key)), $value);
             }
         }
     }
     $statsEl = $variantEl->appendElement('stats');
     foreach ($stats as $statName => $statValue) {
         $statsEl->setAttribute($statName, $statValue);
     }
     foreach ($resultClasses as $resultKey => $classFqn) {
         if ($subjectEl->queryOne('ancestor::suite/result[@key="' . $resultKey . '"]')) {
             continue;
         }
         $resultEl = $subjectEl->queryOne('ancestor::suite')->appendElement('result');
         $resultEl->setAttribute('key', $resultKey);
         $resultEl->setAttribute('class', $classFqn);
     }
 }
开发者ID:dantleech,项目名称:phpbench,代码行数:58,代码来源:XmlEncoder.php

示例2: appendEnvironment

 private function appendEnvironment(\DOMElement $suiteEl)
 {
     $envEl = $suiteEl->appendElement('env');
     $informations = $this->envSupplier->getInformations();
     foreach ($informations as $information) {
         $infoEl = $envEl->appendElement($information->getName());
         foreach ($information as $key => $value) {
             $infoEl->setAttribute($key, $value);
         }
     }
 }
开发者ID:lmaslowski,项目名称:phpbench,代码行数:11,代码来源:Runner.php

示例3: runIterations

 private function runIterations(RunnerContext $context, SubjectMetadata $subject, ParameterSet $parameterSet, \DOMElement $variantEl)
 {
     $iterationCount = $context->getIterations($subject->getIterations());
     $revolutionCount = $context->getRevolutions($subject->getRevs());
     $iterationCollection = new IterationCollection($subject, $parameterSet, $context->getRetryThreshold($this->retryThreshold));
     $this->logger->iterationsStart($iterationCollection);
     $iterations = $iterationCollection->spawnIterations($iterationCount, $revolutionCount);
     foreach ($iterations as $iteration) {
         $this->runIteration($iteration, $subject->getSleep());
         $iterationCollection->add($iteration);
     }
     $iterationCollection->computeStats();
     $this->logger->iterationsEnd($iterationCollection);
     while ($iterationCollection->getRejectCount() > 0) {
         $this->logger->retryStart($iterationCollection->getRejectCount());
         $this->logger->iterationsStart($iterationCollection);
         foreach ($iterationCollection->getRejects() as $reject) {
             $reject->incrementRejectionCount();
             $this->runIteration($reject, $context->getSleep($subject->getSleep()));
         }
         $iterationCollection->computeStats();
         $this->logger->iterationsEnd($iterationCollection);
     }
     $stats = $iterationCollection->getStats();
     foreach ($iterationCollection as $iteration) {
         $iterationEl = $variantEl->ownerDocument->createElement('iteration');
         $iterationEl->setAttribute('revs', $iteration->getRevolutions());
         $iterationEl->setAttribute('time-net', $iteration->getResult()->getTime());
         $iterationEl->setAttribute('time', $iteration->getResult()->getTime() / $iteration->getRevolutions());
         $iterationEl->setAttribute('z-value', $iteration->getZValue());
         $iterationEl->setAttribute('memory', $iteration->getResult()->getMemory());
         $iterationEl->setAttribute('deviation', $iteration->getDeviation());
         $iterationEl->setAttribute('rejection-count', $iteration->getRejectionCount());
         $variantEl->appendChild($iterationEl);
     }
     $statsEl = $variantEl->appendElement('stats');
     foreach ($stats as $statName => $statValue) {
         $statsEl->setAttribute($statName, $statValue);
     }
 }
开发者ID:stof,项目名称:phpbench,代码行数:40,代码来源:Runner.php

示例4: appendException

 private function appendException(\DOMElement $node, \Exception $exception)
 {
     $errorsEl = $node->appendElement('errors');
     do {
         $errorEl = $errorsEl->appendElement('error', $exception->getMessage());
         $errorEl->setAttribute('exception-class', get_class($exception));
         $errorEl->setAttribute('code', $exception->getCode());
         $errorEl->setAttribute('file', $exception->getFile());
         $errorEl->setAttribute('line', $exception->getLine());
     } while ($exception = $exception->getPrevious());
 }
开发者ID:Remo,项目名称:phpbench,代码行数:11,代码来源:Runner.php


注:本文中的DOMElement::appendElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。