GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/node_perf_common.h Lines: 1 1 100.0 %
Date: 2021-06-10 04:11:54 Branches: 0 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 "aliased_buffer.h"
7
#include "node.h"
8
#include "uv.h"
9
#include "v8.h"
10
11
#include <algorithm>
12
#include <iostream>
13
#include <map>
14
#include <string>
15
16
namespace node {
17
namespace performance {
18
19
#define PERFORMANCE_NOW() uv_hrtime()
20
21
// These occur before the environment is created. Cache them
22
// here and add them to the milestones when the env is init'd.
23
extern uint64_t performance_v8_start;
24
25
#define NODE_PERFORMANCE_MILESTONES(V)                                        \
26
  V(ENVIRONMENT, "environment")                                               \
27
  V(NODE_START, "nodeStart")                                                  \
28
  V(V8_START, "v8Start")                                                      \
29
  V(LOOP_START, "loopStart")                                                  \
30
  V(LOOP_EXIT, "loopExit")                                                    \
31
  V(BOOTSTRAP_COMPLETE, "bootstrapComplete")
32
33
34
#define NODE_PERFORMANCE_ENTRY_TYPES(V)                                       \
35
  V(GC, "gc")                                                                 \
36
  V(HTTP, "http")                                                             \
37
  V(HTTP2, "http2")
38
39
enum PerformanceMilestone {
40
#define V(name, _) NODE_PERFORMANCE_MILESTONE_##name,
41
  NODE_PERFORMANCE_MILESTONES(V)
42
#undef V
43
  NODE_PERFORMANCE_MILESTONE_INVALID
44
};
45
46
enum PerformanceEntryType {
47
#define V(name, _) NODE_PERFORMANCE_ENTRY_TYPE_##name,
48
  NODE_PERFORMANCE_ENTRY_TYPES(V)
49
#undef V
50
  NODE_PERFORMANCE_ENTRY_TYPE_INVALID
51
};
52
53
4741
class PerformanceState {
54
 public:
55
  struct SerializeInfo {
56
    AliasedBufferIndex root;
57
    AliasedBufferIndex milestones;
58
    AliasedBufferIndex observers;
59
  };
60
61
  explicit PerformanceState(v8::Isolate* isolate, const SerializeInfo* info);
62
  SerializeInfo Serialize(v8::Local<v8::Context> context,
63
                          v8::SnapshotCreator* creator);
64
  void Deserialize(v8::Local<v8::Context> context);
65
  friend std::ostream& operator<<(std::ostream& o, const SerializeInfo& i);
66
67
  AliasedUint8Array root;
68
  AliasedFloat64Array milestones;
69
  AliasedUint32Array observers;
70
71
  uint64_t performance_last_gc_start_mark = 0;
72
73
  void Mark(enum PerformanceMilestone milestone,
74
            uint64_t ts = PERFORMANCE_NOW());
75
76
 private:
77
  struct performance_state_internal {
78
    // doubles first so that they are always sizeof(double)-aligned
79
    double milestones[NODE_PERFORMANCE_MILESTONE_INVALID];
80
    uint32_t observers[NODE_PERFORMANCE_ENTRY_TYPE_INVALID];
81
  };
82
};
83
84
}  // namespace performance
85
}  // namespace node
86
87
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
88
89
#endif  // SRC_NODE_PERF_COMMON_H_