@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+9 -16
+1 -1
scripts/ssh/ssh-exec.php
··· 307 307 $ssh_log->setData( 308 308 array( 309 309 'c' => $err, 310 - 'T' => (int)(1000000 * (microtime(true) - $ssh_start_time)), 310 + 'T' => phutil_microseconds_since($ssh_start_time), 311 311 )); 312 312 313 313 exit($err);
+1 -3
src/applications/conduit/controller/PhabricatorConduitAPIController.php
··· 109 109 $error_info = $ex->getMessage(); 110 110 } 111 111 112 - $time_end = microtime(true); 113 - 114 112 $log 115 113 ->setCallerPHID( 116 114 isset($conduit_user) 117 115 ? $conduit_user->getPHID() 118 116 : null) 119 117 ->setError((string)$error_code) 120 - ->setDuration(1000000 * ($time_end - $time_start)); 118 + ->setDuration(phutil_microseconds_since($time_start)); 121 119 122 120 if (!PhabricatorEnv::isReadOnly()) { 123 121 $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
+1 -3
src/applications/conduit/ssh/ConduitSSHWorkflow.php
··· 73 73 // if the response is large and the receiver is slow to read it. 74 74 $this->getIOChannel()->flush(); 75 75 76 - $time_end = microtime(true); 77 - 78 76 $connection_id = idx($metadata, 'connectionID'); 79 77 $log = id(new PhabricatorConduitMethodCallLog()) 80 78 ->setCallerPHID($this->getSSHUser()->getPHID()) 81 79 ->setConnectionID($connection_id) 82 80 ->setMethod($method) 83 81 ->setError((string)$error_code) 84 - ->setDuration(1000000 * ($time_end - $time_start)) 82 + ->setDuration(phutil_microseconds_since($time_start)) 85 83 ->save(); 86 84 } 87 85 }
+1 -2
src/applications/diffusion/engine/DiffusionCommitHookEngine.php
··· 1113 1113 $viewer = $this->getViewer(); 1114 1114 1115 1115 $hook_start = $this->getStartTime(); 1116 - $hook_end = microtime(true); 1117 1116 1118 1117 $event = PhabricatorRepositoryPushEvent::initializeNewEvent($viewer) 1119 1118 ->setRepositoryPHID($this->getRepository()->getPHID()) 1120 1119 ->setRemoteAddress($this->getRemoteAddress()) 1121 1120 ->setRemoteProtocol($this->getRemoteProtocol()) 1122 1121 ->setEpoch(PhabricatorTime::getNow()) 1123 - ->setHookWait((int)(1000000 * ($hook_end - $hook_start))); 1122 + ->setHookWait(phutil_microseconds_since($hook_start)); 1124 1123 1125 1124 $identifier = $this->getRequestIdentifier(); 1126 1125 if (strlen($identifier)) {
+2 -5
src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php
··· 772 772 try { 773 773 $future->resolvex(); 774 774 } catch (Exception $ex) { 775 - $sync_end = microtime(true); 776 - $log->setSyncWait((int)(1000000 * ($sync_end - $sync_start))); 775 + $log->setSyncWait(phutil_microseconds_since($sync_start)); 777 776 778 777 if ($ex instanceof CommandException) { 779 778 if ($future->getWasKilledByTimeout()) { ··· 806 805 throw $ex; 807 806 } 808 807 809 - $sync_end = microtime(true); 810 - 811 808 $log 812 - ->setSyncWait((int)(1000000 * ($sync_end - $sync_start))) 809 + ->setSyncWait(phutil_microseconds_since($sync_start)) 813 810 ->setResultCode(0) 814 811 ->setResultType(PhabricatorRepositorySyncEvent::RESULT_SYNC) 815 812 ->save();
+1 -2
src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php
··· 169 169 170 170 $t_start = microtime(true); 171 171 $worker->executeTask(); 172 - $t_end = microtime(true); 173 - $duration = (int)(1000000 * ($t_end - $t_start)); 172 + $duration = phutil_microseconds_since($t_start); 174 173 175 174 $result = $this->archiveTask( 176 175 PhabricatorWorkerArchiveTask::RESULT_SUCCESS,
+2
support/startup/PhabricatorStartup.php
··· 64 64 * @task info 65 65 */ 66 66 public static function getMicrosecondsSinceStart() { 67 + // This is the same as "phutil_microseconds_since()", but we may not have 68 + // loaded libphutil yet. 67 69 return (int)(1000000 * (microtime(true) - self::getStartTime())); 68 70 } 69 71