From 42773e2be5ad2056ccd8766e3335c330c0274a6d Mon Sep 17 00:00:00 2001 From: Horst Schirmeier Date: Tue, 6 Jan 2015 15:09:36 +0100 Subject: [PATCH] visualfail: speedup by using the ".=" operator Using "$x .= $y" instead of "$x = $x . $y" is actually an extreme speedup for long $x. I had no idea PHP's "compiler" was that bad and doesn't optimize this. Change-Id: I39aec5f14f45b75a2467d8074b5ea2ffe5d4b856 --- tools/analysis/VisualFAIL/core.php | 52 ++++++++++++++---------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/tools/analysis/VisualFAIL/core.php b/tools/analysis/VisualFAIL/core.php index 3e5ed05d..f1b06a1a 100644 --- a/tools/analysis/VisualFAIL/core.php +++ b/tools/analysis/VisualFAIL/core.php @@ -170,7 +170,7 @@ function asmCode() $content = $content; while($row = mysql_fetch_object($ergebnis)) { - $content = $content . '' . dechex($row->instr_address) . ' ' . htmlspecialchars($row->disassemble) . '
'; + $content .= '' . dechex($row->instr_address) . ' ' . htmlspecialchars($row->disassemble) . '
'; } echo json_encode($content); } @@ -193,26 +193,25 @@ function getAsmCode() $content = '
'; + $content .= ' >'; while($row = mysql_fetch_object($asmcode)) { if (array_key_exists($row->instr_address,$fehlerdaten['Daten'])) { - $content = $content . 'instr_address) . '" class="hasFehler" '; foreach ($resulttypes as $value) { - $temp = $value . '="' . $fehlerdaten['Daten'][$row->instr_address][$value] . '" '; - $content = $content . $temp; + $content .= $value . '="' . $fehlerdaten['Daten'][$row->instr_address][$value] . '" '; } - $content = $content . ' cursor: pointer;>' . dechex($row->instr_address) . ' ' . htmlspecialchars($row->disassemble) . '
'; + $content .= ' cursor: pointer;>' . dechex($row->instr_address) . ' ' . htmlspecialchars($row->disassemble) . '
'; } else { - $content = $content . '' . dechex($row->instr_address) . ' ' . htmlspecialchars($row->disassemble) . '
'; + $content .= '' . dechex($row->instr_address) . ' ' . htmlspecialchars($row->disassemble) . '
'; } } - $content = $content . '
'; + $content .= ' '; echo json_encode($content); } @@ -268,15 +267,14 @@ function getHighlevelCode() while($row = mysql_fetch_object($mappingErgebnis)) { if (array_key_exists($row->instr_address,$fehlerdaten['Daten'])) { - $newline = $newline . 'instr_address) . '" class="hasFehler" '; foreach ($resulttypes as $value) { - $temp = $value . '="' . $fehlerdaten['Daten'][$row->instr_address][$value] . '" '; - $newline = $newline . $temp; + $newline .= $value . '="' . $fehlerdaten['Daten'][$row->instr_address][$value] . '" '; $maxFehler[$value] = $maxFehler[$value] + $fehlerdaten['Daten'][$row->instr_address][$value]; } - $newline = $newline . ' cursor: pointer;>' . dechex($row->instr_address) . ' ' . htmlspecialchars($row->disassemble) . '
'; + $newline .= ' cursor: pointer;>' . dechex($row->instr_address) . ' ' . htmlspecialchars($row->disassemble) . '
'; } else { $newline = '' . dechex($row->instr_address) . ' ' . htmlspecialchars($row->disassemble) . '
'; } @@ -293,18 +291,18 @@ function getHighlevelCode() while($row = mysql_fetch_object($highlevelCode)) { - $content = $content . '' . $row->linenumber . ' : ' . $row->line . '
'; + $content .= '' . $row->linenumber . ' : ' . $row->line . '
'; if(array_key_exists($row->linenumber, $mapping)) { - $content = $content . '
'; + $content .= '
'; foreach ($mapping[$row->linenumber] as $index => $span) { - $content = $content . $span; + $content .= $span; } - $content = $content . '
'; - $content = $content .'
'; + $content .= '>
'; } } @@ -363,11 +361,10 @@ function askDBFehler($variant_id, $resulttypes, $version) GROUP BY ft.instr_absolute;"; } else if ($version == 'latestip') { $abfrage = "SELECT r.latest_ip "; - foreach ( $resulttypes as $value) { - $temp = ", SUM(IF(r.resulttype = '" . $value . "', 1, 0)*(t.time2-t.time1+1)) AS " . $value; - $abfrage = $abfrage . $temp; - } - $abfrage = $abfrage . " FROM trace t + foreach ( $resulttypes as $value) { + $abfrage .= ", SUM(IF(r.resulttype = '" . $value . "', 1, 0)*(t.time2-t.time1+1)) AS " . $value; + } + $abfrage .= " FROM trace t JOIN fsppilot p ON t.variant_id = p.variant_id AND t.data_address = p.data_address @@ -379,10 +376,9 @@ function askDBFehler($variant_id, $resulttypes, $version) } else { $abfrage = "SELECT ft.instr, ft.instr_absolute "; foreach ( $resulttypes as $value) { - $temp = ", SUM(IF(r.resulttype = '" . $value . "', 1, 0)*(t.time2-t.time1+1)) AS " . $value; - $abfrage = $abfrage . $temp; + $abfrage .= ", SUM(IF(r.resulttype = '" . $value . "', 1, 0)*(t.time2-t.time1+1)) AS " . $value; } - $abfrage = $abfrage . " FROM fulltrace ft + $abfrage .= " FROM fulltrace ft LEFT JOIN trace t ON ft.variant_id = '" . $variant_id . "' AND t.variant_id = '" . $variant_id . "'