rb_renderer_normal.php

来自「linux下安装不上mysql5与php5的可用此关联」· PHP 代码 · 共 515 行 · 第 1/2 页

PHP
515
字号
FROM  rb_res_run AS r1  INNER JOIN rb_res_normal_times AS t1     ON (r1.run_id = t1.fk_run_id)WHERE  r1.run_id = %d AND  r1.file = "%s"ORDER BY   t1.label',     $info['run_id'],    $file);         $html.= <<<EOT      <h3>Database</h3>      <p>      Use the following SQL statement as a starting point, if you      want to analyze the results manually.      </p>      <p>      <pre>$sql            </pre>      </p>EOT;    $html .= <<<EOT      <h3>php -i for every binary</h3>      <table cellspacing="2" cellpadding="2" border="1"> EOT;        $binaries = array_merge(array($master_bin_label => $master_bin_file), $binaries);    $i = 0;    foreach ($binaries as $bin_label => $bin_file) {      $color = (++$i % 2) ? ' bgcolor="#f0f0f0" ' : '';      $anchor = urlencode($bin_label);      $cmd = sprintf("%s -i", $bin_file);      $output = array();      $ret = 0;      exec($cmd, $output, $ret);      $output = htmlspecialchars(implode("\n", $output));      $html.= <<<EOT        <tr $color>          <th align="left" valign="top"><a name="$anchor">$bin_label ($bin_file)</a></th>                  </tr>        <tr>          <td align="left" valign="top"><pre><code>$output</code></pre></td>        </tr>EOT;          }        $html.= <<<EOT      </table>    </font>  </body></html>EOT;    fwrite($fp, $html);    fclose($fp);            }    public function renderOverviewHTML($run_label, $run_datetime) {            $fastest = $this->storage->getFastestBinaries($run_label, $run_datetime);    list($file, ) = each($fastest);    $binaries = $this->storage->getBinaries($run_label, $file, $run_datetime);            if (!file_exists(RB_OUTPUT_HTML_DIR) && !mkdir(RB_OUTPUT_HTML_DIR, 0755, true))            throw new Exception(sprintf("Cannot create output directory '%s'", RB_OUTPUT_HTML_DIR));                $htmlfile = sprintf('%s/index.html', RB_OUTPUT_HTML_DIR);    if (!$fp = fopen($htmlfile, 'w'))      throw new Exception(sprintf("Cannot open output file '%s'", $htmlfile));        $html = <<<EOT<html>  <head>    <title>Bench: $run_label ($run_datetime) $file</title>  </head>  <body>    <font face="sans-serif">      <h1>$run_label ($run_datetime)</h1>      <h3>Binaries</h3>      <table cellspacing="2" cellpadding="2" border="1">EOT;           $clean_stats = array();    foreach ($binaries as $bin_label => $bin_file) {      $anchor = urlencode($bin_label);      $html .= <<<EOT      <tr>        <th align="left" valign="top"><a href="#$anchor">$bin_label</a></th>        <td align="left" valign="top"><a href="#$anchor">$bin_file</a></td>      </tr>EOT;      $clean_stats[$bin_label] = 0;    }        $html .= <<<EOT      </table>      <h3>Summary</h3>      <p>      Counters show for how many time figures a certain binary      has been the fastest. For example, the following says that      three figures are available for 'file.php' and for one figure      'Binary A' was faster than the other binaries and for the      other two figures 'Binary C' was the fastest:      <table cellspacing="2" cellpadding="2" border="1">        <tr>          <td>&nbsp;</td>          <th align="left" valign="top">Binary A</th>          <th align="left" valign="top">Binary B</th>          <th align="left" valign="top">Binary C</th>        </tr>        <tr>          <td align="left valign="top">file.php</td>          <td align="right" valign="top">1 (33%)</td>          <td align="right" valign="top">0 (0%)</td>          <td align="right" valign="top">2 (66%)</td>        </tr>      </table>            </p>      <table cellspacing="2" cellpadding="2" border="1">        <tr>          <td colspan="3">&nbsp;</td>EOT;    foreach ($binaries as $bin_label => $bin_file)      $html .= sprintf('<th colspan="2" align="left" valign="top">%s</th>', $bin_label);          $html .= '</tr>' . "\n";        $i = 0;    foreach ($fastest as $file => $filestats) {            $stats = $clean_stats;      $color = (++$i % 2) ? ' bgcolor="#f0f0f0" ' : '';            foreach ($filestats as $time_label => $bin_label)        $stats[$bin_label]++;              $total = array_sum($stats);      $html .= sprintf('<tr%s><th align="left" valign="top">                        <a href="%s.html">%s</a></th>                        <td align="right" valign="top">%d</td>                        <td align="right" valign="top">100%%</td>',                        $color,                        str_replace('.', '_', basename($file)),                        basename($file),                         $total);            foreach ($binaries as $bin_label => $bin_file) {        $html .= sprintf('<td align="right" valign="top">%d</td><td align="right" valign="top">%3d%%</td>',                  $stats[$bin_label], ($total) ? (100 / $total) * $stats[$bin_label] : 0);      }      $html .= '</tr>' . "\n";    }                $html.= <<<EOT      <h3>php -i for every binary</h3>      <table cellspacing="2" cellpadding="2" border="1"> EOT;        $i = 0;    foreach ($binaries as $bin_label => $bin_file) {      $color = (++$i % 2) ? ' bgcolor="#f0f0f0" ' : '';      $anchor = urlencode($bin_label);      $cmd = sprintf("%s -i", $bin_file);      $output = array();      $ret = 0;      exec($cmd, $output, $ret);      $output = htmlspecialchars(implode("\n", $output));            $html.= <<<EOT        <tr $color>          <th align="left" valign="top"><a name="$anchor">$bin_label ($bin_file)</a></th>                  </tr>        <tr>          <td align="left" valign="top"><pre><code>$output</code></pre></td>        </tr>EOT;          }                   $html.= <<<EOT      </table>    </font>  </body></html>EOT;    fwrite($fp, $html);    fclose($fp);          }    public function renderRunWiki($run_label, $file, $run_datetime) {        $this->renderRunHTML($run_label, $file, $run_datetime);    $htmlfile = sprintf('%s/%s.html', RB_OUTPUT_HTML_DIR, str_replace('.', '_', basename($file)));    $wikifile = sprintf('%s/%s_wiki.txt', RB_OUTPUT_HTML_DIR, str_replace('.', '_', basename($file)));    preg_match_all("=<body[^>]*>(.*)</body>=siU", file_get_contents($htmlfile), $a);    $body = explode("\n", $a[1][0]);    foreach ($body as $k => $line)      $body[$k] = '|' . str_replace('|', '', $line) . "\n";        $fp = fopen($wikifile, 'w');    fwrite($fp, implode('', $body));    fclose($fp);      }    public function renderOverviewWiki($run_label, $run_datetime) {        $this->renderOverviewHTML($run_label, $run_datetime);    $htmlfile = sprintf('%s/index.html', RB_OUTPUT_HTML_DIR);    $wikifile = sprintf('%s/index_wiki.txt', RB_OUTPUT_HTML_DIR);    preg_match_all("=<body[^>]*>(.*)</body>=siU", file_get_contents($htmlfile), $a);    $body = explode("\n", $a[1][0]);    foreach ($body as $k => $line)      $body[$k] = '|' . str_replace('|', '', $line) . "\n";        $fp = fopen($wikifile, 'w');    fwrite($fp, implode('', $body));    fclose($fp);      }    protected function renderTimesTxt($master_times, $master_bin_label, $binary_label, $binary_file, $times) {        $master_sum = array_sum($master_times);    $times_sum = array_sum($times);           printf("Binary   : %-20s %3.5fs (vs. %-20s: %3.5fs = %02d%%)\n",      $binary_label,       $times_sum,      $master_bin_label,       $master_sum,      (($master_sum != 0) ? ((100 / $master_sum) * $times_sum) : 0)    );        printf("\n");              foreach ($times as $label => $runtime) {      printf("%-40s %3.5fs (%3.5fs = %02d%%)\n",        $label,         $runtime,        $master_times[$label],        (($master_times[$label] != 0) ? (100 / $master_times[$label]) * $runtime : 0));    }  }     }?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?