summaryrefslogtreecommitdiff
path: root/tools/benchmark.php
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-04-12 12:53:45 +1000
committerMichael Save <savetheinternet@tinyboard.org>2012-04-12 12:53:45 +1000
commite056b1eb70d47675dd4658abe830a2a609227ef5 (patch)
tree54a06283a34aa3225939beca5c7942196dee2667 /tools/benchmark.php
parent1758f750fd90f9fde06363808d39c46502e9375d (diff)
fix fatal errors. works with v0.9.6
Diffstat (limited to 'tools/benchmark.php')
-rwxr-xr-xtools/benchmark.php78
1 files changed, 39 insertions, 39 deletions
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');
+