📄 make_table_wiki.php
字号:
<?php
// Make results table
// (c) Peter Kankowski, 2008
$columns = array();
$rows = array(
'[[http://www.cse.yorku.ca/~oz/hash.html#djb2|Bernstein]]',
'K&R',
'x17 unrolled',
'[[http://www.cse.yorku.ca/~oz/hash.html#sdbm|x65599]]',
'[[http://isthe.com/chongo/tech/comp/fnv/|FNV-1a]]',
'Sedgewick',
'Weinberger',
'[[http://research.microsoft.com/~PALARSON/|Paul Larson]]',
'[[http://www.azillionmonkeys.com/qed/hash.html|Paul Hsieh]]',
'[[http://www.burtleburtle.net/bob/hash/doobs.html|One At Time]]',
'[[http://www.burtleburtle.net/bob/hash/doobs.html|lookup3]]',
'[[http://www.partow.net/programming/hashfunctions/|Arash Partow]]',
'CRC-32',
'Ramakrishna',
'[[http://en.wikipedia.org/wiki/Fletcher\'s_checksum|Fletcher]]',
'[[http://murmurhash.googlepages.com/MurmurHash2.cpp|Murmur2]]'
);
$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] = '**' . $max[$key] . '**';
}
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
if(isset($cur_col))
select_best($time[$cur_col]);
$cur_row = 0;
array_push($columns, rtrim($line));
array_push($time, array());
$cur_col = array_push($collisions, array()) - 1;
}
}
select_best($time[$cur_col]);
// Print the table
echo '^ ^' . implode('^^', $columns) . "^^\r\n";
for($i = 0; $i < count($rows); $i++) {
echo '|' . $rows[$i];
for($j = 0; $j < count($columns); $j++) {
echo '| ' . $time[$j][$i] . '| <color #CCCCCC>[' . $collisions[$j][$i] . ']</color>';
}
echo "|\r\n";
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -