GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage/nodes/benchmark/out/../src/node_perf_common.h Lines: 6 6 100.0 %
Date: 2019-01-07 12:15:22 Branches: 2 2 100.0 %

Line Branch Exec Source
1
#ifndef SRC_NODE_PERF_COMMON_H_
2
#define SRC_NODE_PERF_COMMON_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "node.h"
7
#include "v8.h"
8
9
#include <algorithm>
10
#include <map>
11
#include <string>
12
13
namespace node {
14
namespace performance {
15
16
#define PERFORMANCE_NOW() uv_hrtime()
17
18
// These occur before the environment is created. Cache them
19
// here and add them to the milestones when the env is init'd.
20
extern uint64_t performance_node_start;
21
extern uint64_t performance_v8_start;
22
23
#define NODE_PERFORMANCE_MILESTONES(V)                                        \
24
  V(ENVIRONMENT, "environment")                                               \
25
  V(NODE_START, "nodeStart")                                                  \
26
  V(V8_START, "v8Start")                                                      \
27
  V(LOOP_START, "loopStart")                                                  \
28
  V(LOOP_EXIT, "loopExit")                                                    \
29
  V(BOOTSTRAP_COMPLETE, "bootstrapComplete")
30
31
32
#define NODE_PERFORMANCE_ENTRY_TYPES(V)                                       \
33
  V(NODE, "node")                                                             \
34
  V(MARK, "mark")                                                             \
35
  V(MEASURE, "measure")                                                       \
36
  V(GC, "gc")                                                                 \
37
  V(FUNCTION, "function")                                                     \
38
  V(HTTP2, "http2")
39
40
enum PerformanceMilestone {
41
#define V(name, _) NODE_PERFORMANCE_MILESTONE_##name,
42
  NODE_PERFORMANCE_MILESTONES(V)
43
#undef V
44
  NODE_PERFORMANCE_MILESTONE_INVALID
45
};
46
47
enum PerformanceEntryType {
48
#define V(name, _) NODE_PERFORMANCE_ENTRY_TYPE_##name,
49
  NODE_PERFORMANCE_ENTRY_TYPES(V)
50
#undef V
51
  NODE_PERFORMANCE_ENTRY_TYPE_INVALID
52
};
53
54
3338
class performance_state {
55
 public:
56
3685
  explicit performance_state(v8::Isolate* isolate) :
57
    root(
58
      isolate,
59
      sizeof(performance_state_internal)),
60
    milestones(
61
      isolate,
62
      offsetof(performance_state_internal, milestones),
63
      NODE_PERFORMANCE_MILESTONE_INVALID,
64
      root),
65
    observers(
66
      isolate,
67
      offsetof(performance_state_internal, observers),
68
      NODE_PERFORMANCE_ENTRY_TYPE_INVALID,
69
3685
      root) {
70
25795
    for (size_t i = 0; i < milestones.Length(); i++)
71
22110
      milestones[i] = -1.;
72
3685
  }
73
74
  AliasedBuffer<uint8_t, v8::Uint8Array> root;
75
  AliasedBuffer<double, v8::Float64Array> milestones;
76
  AliasedBuffer<uint32_t, v8::Uint32Array> observers;
77
78
  uint64_t performance_last_gc_start_mark = 0;
79
80
  void Mark(enum PerformanceMilestone milestone,
81
            uint64_t ts = PERFORMANCE_NOW());
82
83
 private:
84
  struct performance_state_internal {
85
    // doubles first so that they are always sizeof(double)-aligned
86
    double milestones[NODE_PERFORMANCE_MILESTONE_INVALID];
87
    uint32_t observers[NODE_PERFORMANCE_ENTRY_TYPE_INVALID];
88
  };
89
};
90
91
}  // namespace performance
92
}  // namespace node
93
94
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
95
96
#endif  // SRC_NODE_PERF_COMMON_H_