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