-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from nguyenanhung/develop
Develop
- Loading branch information
Showing
8 changed files
with
132 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,119 @@ | ||
[![Latest Stable Version](https://poser.pugx.org/nguyenanhung/my-debug/v)](https://packagist.org/packages/nguyenanhung/my-debug) | ||
[![Latest Unstable Version](https://poser.pugx.org/nguyenanhung/my-debug/v/unstable)](https://packagist.org/packages/nguyenanhung/my-debug) | ||
[![Total Downloads](https://poser.pugx.org/nguyenanhung/my-debug/downloads)](https://packagist.org/packages/nguyenanhung/my-debug) | ||
[![License](https://poser.pugx.org/nguyenanhung/my-debug/license)](https://packagist.org/packages/nguyenanhung/my-debug) | ||
[![Monthly Downloads](https://poser.pugx.org/nguyenanhung/my-debug/d/monthly)](https://packagist.org/packages/nguyenanhung/my-debug) | ||
[![Daily Downloads](https://poser.pugx.org/nguyenanhung/my-debug/d/daily)](https://packagist.org/packages/nguyenanhung/my-debug) | ||
[![composer.lock](https://poser.pugx.org/nguyenanhung/my-debug/composerlock)](https://packagist.org/packages/nguyenanhung/my-debug) | ||
|
||
# My Debug | ||
|
||
## Debug | ||
```php | ||
<?php | ||
require_once __DIR__ . '/vendor/autoload.php'; // Current Package test, remove if init other package | ||
require_once __DIR__ . '/functions.php'; | ||
|
||
use nguyenanhung\MyDebug\Debug; | ||
|
||
// Test Content | ||
$logPath = testLogPath(); | ||
$logSubPath = 'tests-debug-2'; | ||
$logFilename = 'Log-' . date('Y-m-d') . '.log'; | ||
$name = 'Test'; | ||
$msg = 'Test Log lan 2'; | ||
$context = [ | ||
'name' => 'Nguyen An Hung', | ||
'email' => '[email protected]' | ||
]; | ||
// Call | ||
$debug = new Debug(); | ||
$debug->setDebugStatus(TRUE); | ||
$debug->setGlobalLoggerLevel(NULL); | ||
$debug->setLoggerPath($logPath); | ||
$debug->setLoggerSubPath($logSubPath); | ||
$debug->setLoggerFilename($logFilename); | ||
$debug->__construct(); | ||
echo "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"; | ||
echo "\n getVersion: " . $debug->getVersion() . "\n"; | ||
echo "\n setDebugStatus: " . $debug->getDebugStatus() . "\n"; | ||
echo "\n setLoggerPath: " . $debug->getLoggerPath() . "\n"; | ||
echo "\n setLoggerSubPath: " . $debug->getLoggerSubPath() . "\n"; | ||
echo "\n setLoggerFilename: " . $debug->getLoggerFilename() . "\n"; | ||
echo "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"; | ||
|
||
d($debug->debug($name, $msg . ' - DEBUG', $context)); | ||
d($debug->info($name, $msg . ' - INFO', $context)); | ||
d($debug->notice($name, $msg . ' - NOTICE', $context)); | ||
d($debug->warning($name, $msg . ' - WARNING', $context)); | ||
d($debug->error($name, $msg . ' - ERROR', $context)); | ||
d($debug->critical($name, $msg . ' - CRITICAL', $context)); | ||
d($debug->alert($name, $msg . ' - ALERT', $context)); | ||
d($debug->emergency($name, $msg . ' - EMERGENCY', $context)); | ||
``` | ||
|
||
## Benchmark | ||
```php | ||
<?php | ||
require_once __DIR__ . '/vendor/autoload.php'; // Current Package test, remove if init other package | ||
require_once __DIR__ . '/functions.php'; | ||
|
||
use nguyenanhung\MyDebug\Benchmark; | ||
|
||
$benchmark = new Benchmark(); | ||
/***************************** SIMPLE BENCHMARKING BY CI *****************************/ | ||
$benchmark->mark('code_start'); | ||
$mathFunctions = ["abs", "acos", "asin", "atan", "bindec", "floor", "exp", "sin", "tan", "pi", "is_finite", "is_nan", | ||
"sqrt"]; | ||
$count = 9999; | ||
for ($i = 0; $i < $count; $i++) { | ||
foreach ($mathFunctions as $key => $function) { | ||
call_user_func_array($function, [$i]); | ||
echo ($key + 1) . " -> " . $function . "\n"; | ||
} | ||
} | ||
$benchmark->mark('code_end'); | ||
|
||
d($benchmark->getVersion()); | ||
d($benchmark->elapsed_time('code_start', 'code_end')); | ||
d($benchmark->memory_usage()); | ||
/***************************** SIMPLE BENCHMARKING BY CI *****************************/ | ||
``` | ||
|
||
## Manage File | ||
```php | ||
<?php | ||
require_once __DIR__ . '/vendor/autoload.php'; // Current Package test, remove if init other package | ||
require_once __DIR__ . '/functions.php'; | ||
|
||
use nguyenanhung\MyDebug\Manager\File; | ||
|
||
$file = new File(); | ||
$file->setExclude(['*.zip']); | ||
$file->setInclude(['*.log']); | ||
d($file->getVersion()); | ||
|
||
$path = testLogPath(); | ||
|
||
d($file->scanAndZip($path, 3)); | ||
``` | ||
|
||
## Utils | ||
```php | ||
<?php | ||
require_once __DIR__ . '/vendor/autoload.php'; // Current Package test, remove if init other package | ||
require_once __DIR__ . '/functions.php'; | ||
|
||
use nguyenanhung\MyDebug\Utils; | ||
|
||
$utils = new Utils(); | ||
$str = 'Nguyễn An Hưng'; | ||
|
||
d($utils->getVersion()); | ||
d($utils::slugify($str)); | ||
d($utils::convert_vi_to_en($str)); | ||
``` | ||
|
||
## Support | ||
If any question & request, please contact following information | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
"alchemy/zippy": "^0.4" | ||
}, | ||
"require-dev": { | ||
"ext-zip": "*", | ||
"kint-php/kint": "^3.0" | ||
}, | ||
"suggest": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,17 +21,20 @@ | |
* @since 2018-10-17 | ||
* @version 0.1.2.5 | ||
*/ | ||
class Benchmark implements ProjectInterface, BenchmarkInterface | ||
class Benchmark implements ProjectInterface | ||
{ | ||
use Version; | ||
|
||
/** | ||
* Benchmark constructor. | ||
* | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
*/ | ||
public function __construct() | ||
{ | ||
} | ||
/***************************** SIMPLE BENCHMARKING BY CI *****************************/ | ||
|
||
/** | ||
* List of all benchmark markers | ||
* | ||
|
@@ -45,7 +48,7 @@ public function __construct() | |
* Multiple calls to this function can be made so that several | ||
* execution points can be timed. | ||
* | ||
* @param string $name Marker name | ||
* @param string $name Marker name | ||
* | ||
* @return void | ||
*/ | ||
|
@@ -64,9 +67,9 @@ public function mark($name) | |
* execution time to be shown in a template. The output class will | ||
* swap the real value for this variable. | ||
* | ||
* @param string $point1 A particular marked point | ||
* @param string $point2 A particular marked point | ||
* @param int $decimals Number of decimal places | ||
* @param string $point1 A particular marked point | ||
* @param string $point2 A particular marked point | ||
* @param int $decimals Number of decimal places | ||
* | ||
* @return string Calculated elapsed time on success, | ||
* an '{elapsed_string}' if $point1 is empty | ||
|
@@ -99,8 +102,6 @@ public function elapsed_time($point1 = '', $point2 = '', $decimals = 4) | |
*/ | ||
public function memory_usage() | ||
{ | ||
$memory = round(memory_get_usage() / 1024 / 1024, 2) . 'MB'; | ||
|
||
return $memory; | ||
return round(memory_get_usage() / 1024 / 1024, 2) . 'MB'; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.