mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-09 16:32:39 +01:00
Use phutil_microseconds_since(...) to simplify some timing arithmetic
Summary: Depends on D19796. Simplify some timing code by using phutil_microseconds_since() instead of duplicate casting and arithmetic. Test Plan: Grepped for `1000000` to find these. Pulled, pushed, made a conduit call. This isn't exhaustive but it should be hard for these to break in a bad way since they're all just diagnostic. Reviewers: amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D19797
This commit is contained in:
parent
b12e92e6e2
commit
c32fa06266
7 changed files with 9 additions and 16 deletions
|
@ -307,7 +307,7 @@ try {
|
|||
$ssh_log->setData(
|
||||
array(
|
||||
'c' => $err,
|
||||
'T' => (int)(1000000 * (microtime(true) - $ssh_start_time)),
|
||||
'T' => phutil_microseconds_since($ssh_start_time),
|
||||
));
|
||||
|
||||
exit($err);
|
||||
|
|
|
@ -109,15 +109,13 @@ final class PhabricatorConduitAPIController
|
|||
$error_info = $ex->getMessage();
|
||||
}
|
||||
|
||||
$time_end = microtime(true);
|
||||
|
||||
$log
|
||||
->setCallerPHID(
|
||||
isset($conduit_user)
|
||||
? $conduit_user->getPHID()
|
||||
: null)
|
||||
->setError((string)$error_code)
|
||||
->setDuration(1000000 * ($time_end - $time_start));
|
||||
->setDuration(phutil_microseconds_since($time_start));
|
||||
|
||||
if (!PhabricatorEnv::isReadOnly()) {
|
||||
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
|
||||
|
|
|
@ -73,15 +73,13 @@ final class ConduitSSHWorkflow extends PhabricatorSSHWorkflow {
|
|||
// if the response is large and the receiver is slow to read it.
|
||||
$this->getIOChannel()->flush();
|
||||
|
||||
$time_end = microtime(true);
|
||||
|
||||
$connection_id = idx($metadata, 'connectionID');
|
||||
$log = id(new PhabricatorConduitMethodCallLog())
|
||||
->setCallerPHID($this->getSSHUser()->getPHID())
|
||||
->setConnectionID($connection_id)
|
||||
->setMethod($method)
|
||||
->setError((string)$error_code)
|
||||
->setDuration(1000000 * ($time_end - $time_start))
|
||||
->setDuration(phutil_microseconds_since($time_start))
|
||||
->save();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1113,14 +1113,13 @@ final class DiffusionCommitHookEngine extends Phobject {
|
|||
$viewer = $this->getViewer();
|
||||
|
||||
$hook_start = $this->getStartTime();
|
||||
$hook_end = microtime(true);
|
||||
|
||||
$event = PhabricatorRepositoryPushEvent::initializeNewEvent($viewer)
|
||||
->setRepositoryPHID($this->getRepository()->getPHID())
|
||||
->setRemoteAddress($this->getRemoteAddress())
|
||||
->setRemoteProtocol($this->getRemoteProtocol())
|
||||
->setEpoch(PhabricatorTime::getNow())
|
||||
->setHookWait((int)(1000000 * ($hook_end - $hook_start)));
|
||||
->setHookWait(phutil_microseconds_since($hook_start));
|
||||
|
||||
$identifier = $this->getRequestIdentifier();
|
||||
if (strlen($identifier)) {
|
||||
|
|
|
@ -772,8 +772,7 @@ final class DiffusionRepositoryClusterEngine extends Phobject {
|
|||
try {
|
||||
$future->resolvex();
|
||||
} catch (Exception $ex) {
|
||||
$sync_end = microtime(true);
|
||||
$log->setSyncWait((int)(1000000 * ($sync_end - $sync_start)));
|
||||
$log->setSyncWait(phutil_microseconds_since($sync_start));
|
||||
|
||||
if ($ex instanceof CommandException) {
|
||||
if ($future->getWasKilledByTimeout()) {
|
||||
|
@ -806,10 +805,8 @@ final class DiffusionRepositoryClusterEngine extends Phobject {
|
|||
throw $ex;
|
||||
}
|
||||
|
||||
$sync_end = microtime(true);
|
||||
|
||||
$log
|
||||
->setSyncWait((int)(1000000 * ($sync_end - $sync_start)))
|
||||
->setSyncWait(phutil_microseconds_since($sync_start))
|
||||
->setResultCode(0)
|
||||
->setResultType(PhabricatorRepositorySyncEvent::RESULT_SYNC)
|
||||
->save();
|
||||
|
|
|
@ -169,8 +169,7 @@ final class PhabricatorWorkerActiveTask extends PhabricatorWorkerTask {
|
|||
|
||||
$t_start = microtime(true);
|
||||
$worker->executeTask();
|
||||
$t_end = microtime(true);
|
||||
$duration = (int)(1000000 * ($t_end - $t_start));
|
||||
$duration = phutil_microseconds_since($t_start);
|
||||
|
||||
$result = $this->archiveTask(
|
||||
PhabricatorWorkerArchiveTask::RESULT_SUCCESS,
|
||||
|
|
|
@ -64,6 +64,8 @@ final class PhabricatorStartup {
|
|||
* @task info
|
||||
*/
|
||||
public static function getMicrosecondsSinceStart() {
|
||||
// This is the same as "phutil_microseconds_since()", but we may not have
|
||||
// loaded libphutil yet.
|
||||
return (int)(1000000 * (microtime(true) - self::getStartTime()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue