Пример #1
0
for ($i = 0; $i < $len; $i++) {
    $ips[$i] = mt_rand(0, 255) . "." . mt_rand(0, 255) . "." . mt_rand(0, 255) . "." . mt_rand(0, 255);
}
println("Warm up done");
println("Resolving addresses:");
println();
println("Testing bin file : {$bin_name}");
println("----------- NO CACHING ---------------");
$ip2c = new ip2country($bin_name);
runBenchmark($ip2c, $ips, $len);
println("------------------------------------");
println();
println();
println("----------- CACHING ------------------");
$ip2c = new ip2country("{$bin_name}", true);
runBenchmark($ip2c, $ips, $len);
println("------------------------------------");
function runBenchmark($ip2c, $ips, $len)
{
    $now = microtime_float();
    $progress = $len / 20;
    for ($i = 0; $i < $len; $i++) {
        if ($i % $progress == 0 && $i != 0) {
            echo ".";
            flush();
        }
        $ip2c->get_country($ips[$i]);
    }
    $t = microtime_float() - $now;
    println();
    println($t . " ms for {$len} searches (" . $len / $t . " searches/sec)");
Пример #2
0
<?php

/**
 * IMagick Benchmarking Suite
 * 
 * This test was designed to ease the process of testing different techniques for reducing
 * the overall processing time required to generate tile, screenshots and movies used in
 * Helioviewer.org. 
 * 
 * @author Keith Hughitt <*****@*****.**>
 */
runBenchmark(20, array("input_quality" => 1, "output_format" => "PNG", "imagestrings" => true));
//
// printResults
//
function printResults($times, $options)
{
    print "<h1>Helioviewer Benchmark Results:</h1><br />\n";
    print "<b style='text-decoration:underline;'>Options:</b><br />\n<pre>";
    foreach ($options as $key => $val) {
        if (is_bool($val)) {
            $val = $val ? "True" : "False";
        }
        printf("%-13s : %s<br />\n", strtoupper($key), $val);
    }
    $average = array_sum($times) / count($times);
    printf("</pre><br />\n<span style='color: darkblue;'>Average time: %0.2fs</span><br /><br />\n", $average);
    printf("Filesize: %0.04f Mb<br /><br />\n", filesize("final." . strtolower($options["output_format"])) / 1000000.0);
    printf("<b style='text-decoration:underline;'>Times (n=%d):</b><br />\n", count($times));
    $timesStr = "";
    foreach ($times as $time) {
Пример #3
0
    return $btree;
}
function runBenchmark()
{
    $btree = loadBtree();
    $existing_words = array('SKANKY', 'WEEKEND', 'EQUIVOCATION', 'PONDERABLE', 'WHEEDLING', 'SLEEK');
    $non_existing_words = array('!!KKK', '!!KDJFKD', 'DFKJDF', 'Z!DF');
    $start = microtime_float();
    foreach ($existing_words as $word) {
        if (!$btree->hasValue($word)) {
            throw new Exception('BTREE not working');
        }
    }
    foreach ($non_existing_words as $word) {
        if ($btree->hasValue($word)) {
            throw new Exception('BTREE not working');
        }
    }
    $end = microtime_float();
    $total_time = $end - $start;
    $avg_time = $total_time / 10;
    echo "Searched 10 words in {$total_time} seconds\n";
    echo "Average word search time: {$avg_time} seconds\n";
}
function microtime_float()
{
    list($usec, $sec) = explode(" ", microtime());
    return (double) $usec + (double) $sec;
}
runBenchmark();