?? make_table.php
字號:
<?php
// Make results table
// (c) Peter Kankowski, 2008
$columns = array();
$rows = array(
'<a href="http://www.cse.yorku.ca/~oz/hash.html#djb2">Bernstein</a>',
'K&R',
'x17 unrolled',
'<a href="http://www.cse.yorku.ca/~oz/hash.html#sdbm">x65599</a>',
'<a href="http://isthe.com/chongo/tech/comp/fnv/">FNV-1a</a>',
'Sedgewick',
'Weinberger',
'<a href="http://research.microsoft.com/~PALARSON/">Paul Larson</a>',
'<a href="http://www.azillionmonkeys.com/qed/hash.html">Paul Hsieh</a>',
'<a href="http://www.burtleburtle.net/bob/hash/doobs.html">One At Time</a>',
'<a href="http://www.burtleburtle.net/bob/hash/doobs.html">lookup3</a>',
'<a href="http://www.partow.net/programming/hashfunctions/">Arash Partow</a>',
'CRC-32',
'Ramakrishna',
'<a href="http://en.wikipedia.org/wiki/Fletcher\'s_checksum">Fletcher</a>',
'<a href="http://murmurhash.googlepages.com/MurmurHash2.cpp">Murmur2</a>',
);
$time = array();
$collisions = array();
$lines = file('test_results.txt');
function select_best(&$max) {
if(!isset($max))
return;
asort($max);
$i = 0;
reset($max);
foreach($max as $key => $value) {
if( $i++ >= 3 )
break;
$max[$key] = '<span class="g">' . $max[$key] . '</span>';
}
return $max;
}
foreach($lines as $line) {
if(preg_match('/\| +(\d+) \[ *(\d+)\]/', $line, $match)) {
array_push($time[$cur_col], $match[1]);
array_push($collisions[$cur_col], $match[2]);
$cur_row++;
} else if(0 == strspn($line, "1234567890")) {
# Mark the best results with green color
if(isset($cur_col))
select_best($time[$cur_col]);
# Check number of rows
//if(isset($cur_row) && $cur_row != count($rows))
// die($columns[count($columns)-1] . ': should be ' . count($rows) . " columns, found {$cur_row}");
$cur_row = 0;
array_push($columns, rtrim($line));
array_push($time, array());
$cur_col = array_push($collisions, array()) - 1;
}
}
select_best($time[$cur_col]);
echo '<style>.g {color:green} td{border:1px solid #336699; padding:5px} table{border:1px solid #336699; border-collapse:collapse}</style>';
echo '<table>';
echo '<tr><td></td><td colspan="2"><b>' . implode('</b></td><td colspan="2"><b>', $columns) . "</b></td></tr>\r\n";
for($i = 0; $i < count($rows); $i++) {
echo '<tr><td>' . $rows[$i] . '</td>';
for($j = 0; $j < count($columns); $j++) {
echo '<td style="text-align:right;border-right:0px">' . $time[$j][$i] . '</td>'.
'<td style="text-align:right;border-left:0px"><small>[' . $collisions[$j][$i] . ']</small></td>';
}
echo "</tr>\r\n";
}
echo '</table>';
?>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -