Example #1
0
<?php

/*
Plugin Name: Benchmark
Plugin URI: http://markmaunder.com/
Description: Benchmark your WordPress server, network and database 
Author: Mark Maunder
Version: 1.1
Author URI: http://markmaunder.com/
*/
define('BENCHMARK_VERSION', '1.1');
require_once 'lib/benchmarkClass.php';
register_activation_hook(WP_PLUGIN_DIR . '/benchmark/benchmark.php', 'benchmark::installPlugin');
register_deactivation_hook(WP_PLUGIN_DIR . '/benchmark/benchmark.php', 'benchmark::uninstallPlugin');
benchmark::installActions();
Example #2
0
                }
            }
            $this->_maxTagLength = $len;
        }
        return $this->_maxTagLength;
    }
    /**
     * Return the usage help.
     *
     * @return string
     */
    public function usageHelp()
    {
        return <<<USAGE
This scrit initialize all cache tag symlinks.
The script needs read/write permissions to access the magento cache files.

Usage:  php -f app/code/local/Netzarbeiter/Cache/shell/benchmark.php -- [options]

    --init <num> Clear existing cache records and create <num> entries
    --tag <num>  If init was used, specify the number of tags to create (default to 30)
\t--min <num>  If init was used, the min number of tags to use for each record (default 5)
\t--max <num>  If init was used, the max number of tags to use for each record (default min +5)
\t-v           Display statistics for every cache tag
\t--help       This help

USAGE;
    }
}
$init = new benchmark();
$init->run();
Example #3
0
        foreach ($urls as $label => $url) {
            $size = strlen($label);
            if ($size > $maxSize) {
                $maxSize = $size;
            }
        }
        echo "Repetitions: {$repetition}" . PHP_EOL;
        echo '|_. ' . str_pad('URL', $maxSize - 1) . '|_. Time |_. SQL |' . PHP_EOL;
        foreach ($urls as $label => $url) {
            echo '| ' . str_pad($label, $maxSize) . ' | ';
            $stats = [];
            for ($i = 0; $i < $repetition; ++$i) {
                echo `> logs/all.log`;
                $time = trim(`{ time -p wget -q -O "/dev/null" "{$url}"; } 2>&1`);
                preg_match('/\\d+(.\\d+)/', $time, $m);
                $stats['time'][] = $m[0];
                $stats['sql'][] = trim(`grep -cE "SELECT .*" logs/all.log`);
            }
            echo str_pad($this->average($stats['time']), 6, ' ', STR_PAD_LEFT) . ' | ';
            echo str_pad($this->average($stats['sql']), 5, ' ', STR_PAD_LEFT) . ' |';
            echo PHP_EOL;
        }
    }
}
$benchmark = new benchmark();
$repetition = @$argv[1] ?: 1;
if ($repetition === 'url') {
    var_export($benchmark->getUrls());
} else {
    $benchmark->run((int) $repetition);
}
Example #4
0
            if ($i == -1) {
            } elseif ($i == -2) {
            } else {
                if ($i == -3) {
                }
            }
        }
        return number_format(microtime(true) - $time_start, 3);
    }
    public static function run($echo = true)
    {
        $total = 0;
        $server = (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '?') . '@' . (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '?');
        $methods = get_class_methods('benchmark');
        $line = str_pad("-", 38, "-");
        $return = "<pre>{$line}\n|" . str_pad("PHP BENCHMARK SCRIPT", 36, " ", STR_PAD_BOTH) . "|\n{$line}\nStart : " . date("Y-m-d H:i:s") . "\nServer : {$server}\nPHP version : " . PHP_VERSION . "\nPlatform : " . PHP_OS . "\n{$line}\n";
        foreach ($methods as $method) {
            if (preg_match('/^test_/', $method)) {
                $total += $result = self::$method();
                $return .= str_pad($method, 25) . " : " . $result . " sec.\n";
            }
        }
        $return .= str_pad("-", 38, "-") . "\n" . str_pad("Total time:", 25) . " : " . $total . " sec.</pre>";
        if ($echo) {
            echo $return;
        }
        return $return;
    }
}
benchmark::run();
Example #5
0
 public static function startTimer()
 {
     self::$startTime = microtime(true);
 }
Example #6
0
    # Support for non-namespaced classes.
    $parts[] = str_replace('_', DIRECTORY_SEPARATOR, array_pop($parts));
    //$path = implode(DIRECTORY_SEPARATOR, $parts);
    $path = '../lib/' . implode(DIRECTORY_SEPARATOR, $parts);
    $file = stream_resolve_include_path($path . '.php');
    if ($file !== false) {
        require $file;
    }
});
use Igo\Tagger;
$encode = "UTF-8";
ini_set("memory_limit", "1073741824");
//1024^3
$text = file_get_contents("./yoshinoya.txt");
$igo = new Tagger(array('dict_dir' => '../jdic', 'reduce_mode' => false));
$bench = new benchmark();
$bench->start();
$result = $igo->parse($text);
$bench->end();
print_r("score: " . $bench->score);
print_r("\n");
$fp = fopen("./php-igo.result", "w");
foreach ($result as $res) {
    $buf = "";
    $buf .= $res->surface;
    $buf .= ",";
    $buf .= $res->feature;
    $buf .= ",";
    $buf .= $res->start;
    $buf .= "\r\n";
    fwrite($fp, $buf);