Remove .hh_file from hhas
[hiphop-php.git] / hphp / runtime / vm / workload-stats.h
blobe9722af262bbc373ce76695b07b5e14a7de73843
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
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_WORKLOAD_STATS_H_
18 #define incl_HPHP_WORKLOAD_STATS_H_
20 #include <cstdint>
22 namespace HPHP {
24 // WorkloadStats is used to track per request timing for different states
25 // of the VM. At the entrypoint to a change of vm state a WorkloadStats object
26 // should be made to guard the state change with appropriate timers and
27 // counters.
29 // The states tracked are:
30 // - In a request (this is a superset of the interpreter state)
31 // - In the interpreter through Dispatch, or DispatchBB (interpOne disregarded)
32 // - In the JIT (currently tracks time inside the translate routine)
34 // Note the time in the TC is not tracked. This is roughly:
35 // Time in request - Time in interp
37 // This gives us the relative interp time formula of:
38 // Relative interp time = Time in interp / Time in request
39 struct WorkloadStats final {
40 enum State {
41 InRequest,
42 // -> InInterp Okay (entering Dispatch loop)
43 // -> InTrans Okay (entering translate)
44 InInterp,
45 // -> InRequest Okay (leaving the dispatch loop)
46 // -> InTrans Okay (entering translate)
47 InTrans,
48 // -> InRequest Okay (leaving translate)
49 // -> InInterp Okay (leaving translate)
52 explicit WorkloadStats(State guardedState);
53 ~WorkloadStats();
55 WorkloadStats (const WorkloadStats&) = delete;
56 WorkloadStats& operator=(const WorkloadStats&) = delete;
58 static int64_t GetAndResetAvgRelativeInterp();
63 #endif