2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
22 #include <folly/portability/SysResource.h>
23 #include <folly/portability/SysTime.h>
25 #include "hphp/util/compatibility.h"
28 ///////////////////////////////////////////////////////////////////////////////
31 * Timing execution of block of codes.
47 Children
= RUSAGE_CHILDREN
,
49 Thread
= RUSAGE_THREAD
,
54 explicit Timer(Type type
, const char *name
= nullptr, ReportType r
= Log
);
57 static void GetRealtimeTime(timespec
&sp
);
58 static void GetMonotonicTime(timespec
&sp
);
59 static int64_t GetCurrentTimeMicros();
60 static int64_t GetRusageMicros(Type t
, Who who
);
61 static int64_t GetThreadCPUTimeNanos();
62 const char *getName() const;
63 int64_t getMicroSeconds() const;
72 int64_t measure() const;
75 ///////////////////////////////////////////////////////////////////////////////
78 SlowTimer(int64_t msThreshold
, const char *location
, const char *info
);
81 int64_t getTime() const;
85 int64_t m_msThreshold
;
86 std::string m_location
;
90 ///////////////////////////////////////////////////////////////////////////////
92 extern __thread
int64_t s_extra_request_nanoseconds
;
94 int gettime(clockid_t
, struct timespec
*);
95 int64_t gettime_ns(clockid_t
);
98 * Computes the difference between two timespec objects in microseconds.
100 int64_t gettime_diff_us(const timespec
&, const timespec
&);
102 ///////////////////////////////////////////////////////////////////////////////