From e056b1eb70d47675dd4658abe830a2a609227ef5 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Thu, 12 Apr 2012 12:53:45 +1000 Subject: fix fatal errors. works with v0.9.6 --- tools/benchmark.php | 78 ++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'tools/benchmark.php') diff --git a/tools/benchmark.php b/tools/benchmark.php index 60aba638..8c97364c 100755 --- a/tools/benchmark.php +++ b/tools/benchmark.php @@ -4,49 +4,49 @@ * benchmark.php - benchmarks thumbnailing methods * */ - - require dirname(__FILE__) . '/inc/cli.php'; - require 'inc/image.php'; + +require dirname(__FILE__) . '/inc/cli.php'; +require 'inc/image.php'; + +// move back to this directory +chdir(dirname(__FILE__)); + +if(count($argv) != 2) + die("Usage: {$argv[0]} [file]\n"); + +$file = $argv[1]; +$extension = strtolower(substr($file, strrpos($file, '.') + 1)); +$out = tempnam($config['tmp'], 'thumb'); +$count = 300; + +function benchmark($method) { + global $config, $file, $extension, $out, $count; - // move back to this directory - chdir(dirname(__FILE__)); + $config['thumb_method'] = $method; - if(count($argv) != 2) - die("Usage: {$argv[0]} [file]\n"); + printf("Method: %s\nThumbnailing %d times... ", $method, $count); - $file = $argv[1]; - $extension = strtolower(substr($file, strrpos($file, '.') + 1)); - $out = tempnam($config['tmp'], 'thumb'); - $count = 300; - - function benchmark($method) { - global $config, $file, $extension, $out, $count; - - $config['thumb_method'] = $method; - - printf("Method: %s\nThumbnailing %d times... ", $method, $count); - - $start = microtime(true); - for($i = 0; $i < $count; $i++) { - $image = new Image($file, $extension); - $thumb = $image->resize( - $config['thumb_ext'] ? $config['thumb_ext'] : $extension, - $config['thumb_width'], - $config['thumb_height'] - ); - - $thumb->to($out); - $thumb->_destroy(); - $image->destroy(); - } - $end = microtime(true); - - printf("Took %.2f seconds (%.2f/second; %.2f ms)\n", $end - $start, $rate = ($count / ($end - $start)), 1000 / $rate); + $start = microtime(true); + for($i = 0; $i < $count; $i++) { + $image = new Image($file, $extension); + $thumb = $image->resize( + $config['thumb_ext'] ? $config['thumb_ext'] : $extension, + $config['thumb_width'], + $config['thumb_height'] + ); - unlink($out); + $thumb->to($out); + $thumb->_destroy(); + $image->destroy(); } + $end = microtime(true); - benchmark('gd'); - benchmark('imagick'); - benchmark('convert'); + printf("Took %.2f seconds (%.2f/second; %.2f ms)\n", $end - $start, $rate = ($count / ($end - $start)), 1000 / $rate); + unlink($out); +} + +benchmark('gd'); +benchmark('imagick'); +benchmark('convert'); + -- cgit v1.3