Created
January 4, 2018 14:32
-
-
Save pekhota/9d44f900e46b2fdf2edee6c848adae8c to your computer and use it in GitHub Desktop.
Пример того, как можно собирать метрики в едином месте.
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
<?php | |
function do($msg, callable $cb, array $params = []) { | |
$executionStartTime = microtime(true); | |
$result = call_user_func_array($cb, $params); | |
$executionEndTime = microtime(true); | |
$seconds = $executionEndTime - $executionStartTime; | |
event(new BlockOfCodeExecuted( | |
$msg, | |
$params, | |
$result, | |
$executionStartTime, | |
$executionEndTime | |
)); | |
return $result; | |
} |
// Call method
do($msg, [$this, 'someMethod'], $params);
$result = $cb($params);
Треба ще додати в BlockOfCodeExecuted імя $cb.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$seconds = $executionEndTime - $executionStartTime;
Де потім юзається?