You are here

public function MarkdownParserBenchmarkTrait::benchmarkRender in Markdown 3.0.x

Return value

\Drupal\markdown\MarkdownBenchmark

See also

\Drupal\markdown\Plugin\Markdown\MarkdownParserBenchmarkInterface::benchmarkRender()

1 call to MarkdownParserBenchmarkTrait::benchmarkRender()
MarkdownParserBenchmarkTrait::benchmark in src/Traits/MarkdownParserBenchmarkTrait.php

File

src/Traits/MarkdownParserBenchmarkTrait.php, line 71

Class

MarkdownParserBenchmarkTrait

Namespace

Drupal\markdown\Traits

Code

public function benchmarkRender($markdown, $format = NULL) {
  if ($format === NULL) {

    /** @var \Drupal\Core\Render\RendererInterface $renderer */
    $renderer = \Drupal::service('renderer');
    $start = microtime(TRUE);
    $build = [
      '#markup' => $this
        ->parse($markdown),
    ];
    $result = $renderer
      ->renderPlain($build);
    $end = microtime(TRUE);
  }
  else {
    $start = microtime(TRUE);
    $result = check_markup($markdown, $format);
    $end = microtime(TRUE);
  }
  return MarkdownBenchmark::create('rendered', $start, $end, $result);
}