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 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_TIMER_H_
18 #define incl_HPHP_TIMER_H_
23 #include <folly/portability/SysResource.h>
24 #include <folly/portability/SysTime.h>
26 #include "hphp/util/compatibility.h"
29 ///////////////////////////////////////////////////////////////////////////////
32 * Timing execution of block of codes.
48 Children
= RUSAGE_CHILDREN
,
50 Thread
= RUSAGE_THREAD
,
55 explicit Timer(Type type
, const char *name
= nullptr, ReportType r
= Log
);
58 static void GetRealtimeTime(timespec
&sp
);
59 static void GetMonotonicTime(timespec
&sp
);
60 static int64_t GetCurrentTimeMicros();
61 static int64_t GetRusageMicros(Type t
, Who who
);
62 static int64_t GetThreadCPUTimeNanos();
63 const char *getName() const;
64 int64_t getMicroSeconds() const;
73 int64_t measure() const;
76 ///////////////////////////////////////////////////////////////////////////////
79 SlowTimer(int64_t msThreshold
, const char *location
, const char *info
);
82 int64_t getTime() const;
86 int64_t m_msThreshold
;
87 std::string m_location
;
91 ///////////////////////////////////////////////////////////////////////////////
93 extern __thread
int64_t s_extra_request_nanoseconds
;
95 int gettime(clockid_t
, struct timespec
*);
96 int64_t gettime_ns(clockid_t
);
99 * Computes the difference between two timespec objects in microseconds.
101 int64_t gettime_diff_us(const timespec
&, const timespec
&);
103 ///////////////////////////////////////////////////////////////////////////////
106 #endif // incl_HPHP_TIMER_H_