7 files changed +9
-16
lines changed Original file line number Diff line number Diff line change 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 );
Original file line number Diff line number Diff line change @@ -109,15 +109,13 @@ public function handleRequest(AphrontRequest $request) {
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 ();
Original file line number Diff line number Diff line change @@ -73,15 +73,13 @@ public function execute(PhutilArgumentParser $args) {
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
}
Original file line number Diff line number Diff line change @@ -1113,14 +1113,13 @@ private function newPushEvent() {
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 )) {
Original file line number Diff line number Diff line change @@ -772,8 +772,7 @@ private function synchronizeWorkingCopyFromBinding(
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,10 +805,8 @@ private function synchronizeWorkingCopyFromBinding(
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 ();
Original file line number Diff line number Diff line change @@ -169,8 +169,7 @@ public function executeTask() {
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 ,
Original file line number Diff line number Diff line change @@ -64,6 +64,8 @@ public static function getStartTime() {
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
0 commit comments