4 * benchmark.php - benchmarks thumbnailing methods
8 require dirname(__FILE__
) . '/inc/cli.php';
9 require 'inc/image.php';
11 // move back to this directory
12 chdir(dirname(__FILE__
));
15 die("Usage: {$argv[0]} [file]\n");
18 $extension = strtolower(substr($file, strrpos($file, '.') +
1));
19 $out = tempnam($config['tmp'], 'thumb');
22 function benchmark($method) {
23 global $config, $file, $extension, $out, $count;
25 $config['thumb_method'] = $method;
27 printf("Method: %s\nThumbnailing %d times... ", $method, $count);
29 $start = microtime(true);
30 for($i = 0; $i < $count; $i++
) {
31 $image = new Image($file, $extension);
32 $thumb = $image->resize(
33 $config['thumb_ext'] ?
$config['thumb_ext'] : $extension,
34 $config['thumb_width'],
35 $config['thumb_height']
42 $end = microtime(true);
44 printf("Took %.2f seconds (%.2f/second; %.2f ms)\n", $end - $start, $rate = ($count / ($end - $start)), 1000 / $rate);
50 if (extension_loaded('imagick')) {
53 echo "Imagick extension not loaded... skipping.\n";
57 becnhmark('convert+gifsicle');