new pisilinux web sites

This commit is contained in:
Erkan IŞIK
2026-07-01 16:44:17 +03:00
commit b58488b586
21740 changed files with 2066209 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
<?php namespace ZN\Comparison;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Controller\Factory;
class Benchmark extends Factory
{
const factory =
[
'methods' =>
[
'run' => 'Run::test',
'cycle' => 'Run::cycle',
'result' => 'Run::result',
'start' => 'Testing::start',
'end' => 'Testing::end',
'elapsedtime' => 'ElapsedTime::calculate',
'usedfiles' => 'FileUsage::list',
'usedfilecount' => 'FileUsage::count',
'calculatedmemory' => 'MemoryUsage::calculate',
'memoryusage' => 'MemoryUsage::normal',
'maxmemoryusage' => 'MemoryUsage::maximum'
]
];
}
@@ -0,0 +1,39 @@
<?php namespace ZN\Comparison;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
class ElapsedTime
{
/**
* Calculate elapsed time
*
* @param string $result
* @param int $decimal = 4
*
* @return float
*/
public static function calculate(string $result, int $decimal = 4) : Float
{
$resend = $result."_end";
$restart = $result."_start";
if( ! isset(Properties::$tests[$restart]) )
{
throw new Exception\InvalidParameterException(NULL, ['&' => 'elapsedTime', '%' => $result, 'start']);
}
if( ! isset(Properties::$tests[$resend]) )
{
throw new Exception\InvalidParameterException(NULL, ['&' => 'elapsedTime', '%' => $result, 'end']);
}
return round(((float) Properties::$tests[$resend] - (float) Properties::$tests[$restart]), $decimal);
}
}
@@ -0,0 +1,21 @@
<?php namespace ZN\Comparison\Exception;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Exception;
class InvalidParameterException extends Exception
{
const lang =
[
'en' => '[Benchmark::&(\'%\')] -> The parameter is not a valid test key!',
'tr' => '[Benchmark::&(\'%\')] -> Parametre geçerli bir test anahtarı değildir!'
];
}
+73
View File
@@ -0,0 +1,73 @@
<?php namespace ZN\Comparison;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
class FileUsage
{
/**
* Usage file list
*
* @param string $result = NULL
*
* @return array
*/
public static function list(?string $result = NULL) : array
{
if( empty($result) )
{
return get_required_files();
}
$resend = $result."_end";
$restart = $result."_start";
if( ! isset(Properties::$usedtests[$restart]) )
{
throw new Exception\InvalidParameterException(NULL, ['&' => 'usedFiles', '%' => $result, 'start']);
}
if( ! isset(Properties::$usedtests[$resend]) )
{
throw new Exception\InvalidParameterException(NULL, ['&' => 'usedFiles', '%' => $result, 'end']);
}
return array_diff(Properties::$usedtests[$resend], Properties::$usedtests[$restart]);
}
/**
* Used file count
*
* @param string $result = NULL
*
* @return int
*/
public static function count(?string $result = NULL) : int
{
if( empty($result) )
{
return count(get_required_files());
}
$resend = $result."_end";
$restart = $result."_start";
if( ! isset(Properties::$usedtests[$restart]) )
{
throw new Exception\InvalidParameterException(NULL, ['&' => 'usedFileCount', '%' => $result, 'start']);
}
if( ! isset(Properties::$usedtests[$resend]) )
{
throw new Exception\InvalidParameterException(NULL, ['&' => 'usedFileCount', '%' => $result, 'end']);
}
return count(Properties::$usedtests[$resend]) - count(Properties::$usedtests[$restart]);
}
}
@@ -0,0 +1,62 @@
<?php namespace ZN\Comparison;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
class MemoryUsage
{
/**
* Calculate memory
*
* @param string $result
*
* @return float
*/
public static function calculate(string $result) : Float
{
$resend = $result."_end";
$restart = $result."_start";
if( ! isset(Properties::$memtests[$restart]) )
{
throw new Exception\InvalidParameterException(NULL, ['&' => 'calculatedMemory', '%' => $result, 'start']); // @codeCoverageIgnore
}
if( ! isset(Properties::$memtests[$resend]) )
{
throw new Exception\InvalidParameterException(NULL, ['&' => 'calculatedMemory', '%' => $result, 'end']); // @codeCoverageIgnore
}
return Properties::$memtests[$resend] - Properties::$memtests[$restart];
}
/**
* Usage memory
*
* @param bool $realMemory = false
*
* @return int
*/
public static function normal(bool $realMemory = false) : int
{
return memory_get_usage($realMemory);
}
/**
* Usage max memory
*
* @param bool $realMemory = false
*
* @return int
*/
public static function maximum(bool $realMemory = false) : int
{
return memory_get_peak_usage($realMemory);
}
}
@@ -0,0 +1,34 @@
<?php namespace ZN\Comparison;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
class Properties
{
/**
* Keeps test names
*
* @var array
*/
public static $tests = [];
/**
* Keeps memory results
*
* @var array
*/
public static $memtests = [];
/**
* Keeps used tests
*
* @var array
*/
public static $usedtests = [];
}
+70
View File
@@ -0,0 +1,70 @@
<?php namespace ZN\Comparison;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use stdClass;
class Run
{
/**
* Run test
*
* @param callable $test
*
* @return Run
*/
public function test(callable $test) : Run
{
Testing::start('run');
$test();
Testing::end('run');
return $this;
}
/**
* Run cycle
*
* @param callable $test
*
* @return Run
*/
public function cycle($count, callable $test) : Run
{
Testing::start('run');
for( $i = 0; $i < $count; $i++ )
{
$test();
}
Testing::end('run');
return $this;
}
/**
* Result test
*
* @param void
*
* @return stdClass
*/
public function result() : stdClass
{
return (object)
[
'elapsedTime' => ElapsedTime::calculate('run'),
'calculatedMemory' => MemoryUsage::calculate('run'),
'usedFileCount' => FileUsage::count('run'),
'usedFiles' => FileUsage::list('run')
];
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php namespace ZN\Comparison;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
class Testing
{
/**
* Start test
*
* @param string $test
*
* @return void
*/
public static function start(string $test)
{
$test = $test."_start";
Properties::$tests[$test] = microtime(true);
Properties::$usedtests[$test] = get_required_files();
Properties::$memtests[$test] = memory_get_usage();
}
/**
* End test
*
* @param string $test
*
* @return void
*/
public static function end(string $test)
{
$getMemoryUsage = memory_get_usage();
$test = $test."_end";
Properties::$tests[$test] = microtime(true);
Properties::$usedtests[$test] = get_required_files();
Properties::$memtests[$test] = $getMemoryUsage;
}
}