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-04-09 04:13:47 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(HTTP2, "http2")
37
38
enum PerformanceMilestone {
39
#define V(name, _) NODE_PERFORMANCE_MILESTONE_##name,
40
  NODE_PERFORMANCE_MILESTONES(V)
41
#undef V
42
  NODE_PERFORMANCE_MILESTONE_INVALID
43
};
44
45
enum PerformanceEntryType {
46
#define V(name, _) NODE_PERFORMANCE_ENTRY_TYPE_##name,
47
  NODE_PERFORMANCE_ENTRY_TYPES(V)
48
#undef V
49
  NODE_PERFORMANCE_ENTRY_TYPE_INVALID
50
};
51
52
4596
class PerformanceState {
53
 public:
54
  struct SerializeInfo {
55
    AliasedBufferIndex root;
56
    AliasedBufferIndex milestones;
57
    AliasedBufferIndex observers;
58
  };
59
60
  explicit PerformanceState(v8::Isolate* isolate, const SerializeInfo* info);
61
  SerializeInfo Serialize(v8::Local<v8::Context> context,
62
                          v8::SnapshotCreator* creator);
63
  void Deserialize(v8::Local<v8::Context> context);
64
  friend std::ostream& operator<<(std::ostream& o, const SerializeInfo& i);
65
66
  AliasedUint8Array root;
67
  AliasedFloat64Array milestones;
68
  AliasedUint32Array observers;
69
70
  uint64_t performance_last_gc_start_mark = 0;
71
72
  void Mark(enum PerformanceMilestone milestone,
73
            uint64_t ts = PERFORMANCE_NOW());
74
75
 private:
76
  struct performance_state_internal {
77
    // doubles first so that they are always sizeof(double)-aligned
78
    double milestones[NODE_PERFORMANCE_MILESTONE_INVALID];
79
    uint32_t observers[NODE_PERFORMANCE_ENTRY_TYPE_INVALID];
80
  };
81
};
82
83
}  // namespace performance
84
}  // namespace node
85
86
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
87
88
#endif  // SRC_NODE_PERF_COMMON_H_