Add workload stats.
[hiphop-php.git] / hphp / runtime / vm / workload-stats.h
blobc732c3d18e8b8e8b3ac539f3a64e597592379718
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 namespace HPHP {
22 // WorkloadStats is used to track per request timing for different states
23 // of the VM. At the entrypoint to a change of vm state a WorkloadStats object
24 // should be made to guard the state change with appropriate timers and
25 // counters.
27 // The states tracked are:
28 // - In a request (this is a superset of the interpreter state)
29 // - In the interpreter through Dispatch, or DispatchBB (interpOne disregarded)
30 // - In the JIT (currently tracks time inside the translate routine)
32 // Note the time in the TC is not tracked. This is roughly:
33 // Time in request - Time in interp
35 // This gives us the relative interp time formula of:
36 // Relative interp time = Time in interp / Time in request
37 struct WorkloadStats final {
38 enum State {
39 InRequest,
40 // -> InInterp Okay (entering Dispatch loop)
41 // -> InTrans Okay (entering translate)
42 InInterp,
43 // -> InRequest Okay (leaving the dispatch loop)
44 // -> InTrans Okay (entering translate)
45 InTrans,
46 // -> InRequest Okay (leaving translate)
47 // -> InInterp Okay (leaving translate)
50 explicit WorkloadStats(State guardedState);
51 ~WorkloadStats();
53 WorkloadStats (const WorkloadStats&) = delete;
54 WorkloadStats& operator=(const WorkloadStats&) = delete;
59 #endif