recreate project

This commit is contained in:
root
2026-02-10 22:11:06 -05:00
commit 663c0cdbda
10149 changed files with 1379710 additions and 0 deletions
@@ -0,0 +1,26 @@
<?php
use Mike42\GfxPhp\Image;
/**
* @BeforeMethods({"init"})
* @Revs(1000)
*/
class GifDecodeBenchmark {
private static $blob;
public function init()
{
self::$blob = file_get_contents(__DIR__ . "/../../../resources/pygif/high-color.gif");
}
/**
* @Subject
*/
public function gifDecode()
{
Image::fromBlob(self::$blob, "foo.gif");
}
}
@@ -0,0 +1,52 @@
<?php
use Mike42\GfxPhp\Util\LzwCompression;
/**
* @BeforeMethods({"init"})
* @Revs(100)
*/
class LzwDecodeBenchmark
{
private $blank;
private $random;
private $repeating;
public function init()
{
$this -> blank = LzwCompression::compress(str_repeat("\0", 65536), 0x08);
$this -> random = LzwCompression::compress($this -> random_str(65536), 0x08);
$this -> repeating = LzwCompression::compress(str_repeat($this -> random_str(256), 256), 0x08);
}
/**
* @Subject
*/
public function lzwDecodeBlank() {
LzwCompression::decompress($this -> blank, 0x08);
}
/**
* @Subject
*/
public function lzwDecodeRandom() {
LzwCompression::decompress($this -> random, 0x08);
}
/**
* @Subject
*/
public function lzwDecodeRepeating() {
LzwCompression::decompress($this -> repeating, 0x08);
}
/** Random string, not cryptographically strong */
public static function random_str(int $len)
{
$str = str_repeat("\0", $len);
for($i = 0 ; $i < $len; $i++) {
$str[$i] = chr(rand(0, 255));
}
return $str;
}
}
@@ -0,0 +1,52 @@
<?php
use Mike42\GfxPhp\Util\LzwCompression;
/**
* @BeforeMethods({"init"})
* @Revs(10)
*/
class LzwEncodeBenchmark
{
private $blank;
private $random;
private $repeating;
public function init()
{
$this -> blank = str_repeat("\0", 65536);
$this -> random = $this -> random_str(65536);
$this -> repeating = str_repeat($this -> random_str(256), 256);
}
/**
* @Subject
*/
public function lzwEncodeBlank() {
LzwCompression::compress($this -> blank, 0x08);
}
/**
* @Subject
*/
public function lzwEncodeRandom() {
LzwCompression::compress($this -> random, 0x08);
}
/**
* @Subject
*/
public function lzwEncodeRepeating() {
LzwCompression::compress($this -> repeating, 0x08);
}
/** Random string, not cryptographically strong */
public static function random_str(int $len)
{
$str = str_repeat("\0", $len);
for($i = 0 ; $i < $len; $i++) {
$str[$i] = chr(rand(0, 255));
}
return $str;
}
}
@@ -0,0 +1,26 @@
<?php
use Mike42\GfxPhp\Image;
/**
* @BeforeMethods({"init"})
* @Revs(1000)
*/
class PngDecodeBenchmark {
private static $blob;
public function init()
{
self::$blob = file_get_contents(__DIR__ . "/../../../resources/pngsuite/z09n2c08.png");
}
/**
* @Subject
*/
public function pngDecode()
{
Image::fromBlob(self::$blob, "foo.png");
}
}
@@ -0,0 +1,151 @@
<?php
use Mike42\GfxPhp\Image;
/**
* @BeforeMethods({"init"})
* @Revs(1000)
*/
class ConvertRasterImageBenchmark
{
private static $bw100;
private static $gray100;
private static $indexed100;
private static $rgb100;
public function init()
{
self::$rgb100 = Image::fromFile(__DIR__ . "/../../resources/pngsuite/z09n2c08.png");
self::$bw100 = self::$rgb100 -> toBlackAndWhite();
self::$indexed100 = self::$rgb100 -> toIndexed();
self::$gray100 = self::$rgb100 -> toGrayscale();
}
/**
* @Subject
*/
public function convertBwToBw()
{
self::$bw100->toBlackAndWhite();
}
/**
* @Subject
*/
public function convertBwToGray()
{
self::$bw100->toGrayscale();
}
/**
* @Subject
*/
public function convertBwToIndexed()
{
self::$bw100->toIndexed();
}
/**
* @Subject
*/
public function convertBwToRgb()
{
self::$bw100->toRgb();
}
/**
* @Subject
*/
public function convertGrayToBw()
{
self::$gray100->toBlackAndWhite();
}
/**
* @Subject
*/
public function convertGrayToGray()
{
self::$gray100->toGrayscale();
}
/**
* @Subject
*/
public function convertGrayToIndexed()
{
self::$gray100->toIndexed();
}
/**
* @Subject
*/
public function convertGrayToRgb()
{
self::$gray100->toRgb();
}
/**
* @Subject
*/
public function convertIndexedToBw()
{
self::$indexed100->toBlackAndWhite();
}
/**
* @Subject
*/
public function convertIndexedToGray()
{
self::$indexed100->toGrayscale();
}
/**
* @Subject
*/
public function convertIndexedToIndexed()
{
self::$indexed100->toIndexed();
}
/**
* @Subject
*/
public function convertIndexedToRgb()
{
self::$indexed100->toRgb();
}
/**
* @Subject
*/
public function convertRgbToBw()
{
self::$rgb100->toBlackAndWhite();
}
/**
* @Subject
*/
public function convertRgbToGray()
{
self::$rgb100->toGrayscale();
}
/**
* @Subject
*/
public function convertRgbToIndexed()
{
self::$rgb100->toIndexed();
}
/**
* @Subject
*/
public function convertRgbToRgb()
{
self::$rgb100->toRgb();
}
}
@@ -0,0 +1,58 @@
<?php
use Mike42\GfxPhp\BlackAndWhiteRasterImage;
use Mike42\GfxPhp\GrayscaleRasterImage;
use Mike42\GfxPhp\IndexedRasterImage;
use Mike42\GfxPhp\RgbRasterImage;
/**
* @BeforeMethods({"init"})
* @Revs(10000)
*/
class ScaleDownBenchmark
{
private static $bw100;
private static $rgb100;
private static $indexed100;
private static $gray100;
public function init()
{
self::$bw100 = BlackAndWhiteRasterImage::create(100, 100);
self::$rgb100 = RgbRasterImage::create(100, 100);
self::$indexed100 = IndexedRasterImage::create(100, 100);
self::$gray100 = GrayscaleRasterImage::create(100, 100);
}
/**
* @Subject
*/
public function scaleDownBw()
{
self::$bw100->scale(10, 10);
}
/**
* @Subject
*/
public function scaleDownGrayscale()
{
self::$gray100->scale(10, 10);
}
/**
* @Subject
*/
public function scaleDownIndexed()
{
self::$indexed100->scale(10, 10);
}
/**
* @Subject
*/
public function scaleDownRgb()
{
self::$rgb100->scale(10, 10);
}
}
@@ -0,0 +1,58 @@
<?php
use Mike42\GfxPhp\BlackAndWhiteRasterImage;
use Mike42\GfxPhp\GrayscaleRasterImage;
use Mike42\GfxPhp\IndexedRasterImage;
use Mike42\GfxPhp\RgbRasterImage;
/**
* @BeforeMethods({"init"})
* @Revs(10)
*/
class ScaleUpBenchmark
{
private static $bw10;
private static $rgb10;
private static $indexed10;
private static $gray10;
public function init()
{
self::$bw10 = BlackAndWhiteRasterImage::create(10, 10);
self::$rgb10 = RgbRasterImage::create(10, 10);
self::$indexed10 = IndexedRasterImage::create(10, 10);
self::$gray10 = GrayscaleRasterImage::create(10, 10);
}
/**
* @Subject
*/
public function scaleUpBw()
{
self::$bw10->scale(100, 100);
}
/**
* @Subject
*/
public function scaleUpGrayscale()
{
self::$gray10->scale(100, 100);
}
/**
* @Subject
*/
public function scaleUpIndexed()
{
self::$indexed10->scale(100, 100);
}
/**
* @Subject
*/
public function scaleUpRgb()
{
self::$rgb10->scale(100, 100);
}
}