The version of vichan running on lainchan.org
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

58 строки
1.3KB

  1. #!/usr/bin/php
  2. <?php
  3. /*
  4. * benchmark.php - benchmarks thumbnailing methods
  5. *
  6. */
  7. require dirname(__FILE__) . '/inc/cli.php';
  8. require 'inc/image.php';
  9. // move back to this directory
  10. chdir(dirname(__FILE__));
  11. if(count($argv) != 2)
  12. die("Usage: {$argv[0]} [file]\n");
  13. $file = $argv[1];
  14. $extension = strtolower(substr($file, strrpos($file, '.') + 1));
  15. $out = tempnam($config['tmp'], 'thumb');
  16. $count = 300;
  17. function benchmark($method) {
  18. global $config, $file, $extension, $out, $count;
  19. $config['thumb_method'] = $method;
  20. printf("Method: %s\nThumbnailing %d times... ", $method, $count);
  21. $start = microtime(true);
  22. for($i = 0; $i < $count; $i++) {
  23. $image = new Image($file, $extension);
  24. $thumb = $image->resize(
  25. $config['thumb_ext'] ? $config['thumb_ext'] : $extension,
  26. $config['thumb_width'],
  27. $config['thumb_height']
  28. );
  29. $thumb->to($out);
  30. $thumb->_destroy();
  31. $image->destroy();
  32. }
  33. $end = microtime(true);
  34. printf("Took %.2f seconds (%.2f/second; %.2f ms)\n", $end - $start, $rate = ($count / ($end - $start)), 1000 / $rate);
  35. unlink($out);
  36. }
  37. benchmark('gd');
  38. if (extension_loaded('imagick')) {
  39. benchmark('imagick');
  40. } else {
  41. echo "Imagick extension not loaded... skipping.\n";
  42. }
  43. benchmark('convert');
  44. benchmark('gm');
  45. becnhmark('convert+gifsicle');