Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/nodejs/src/node_perf_common.h
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 const uint64_t performance_process_start; 24 extern const double performance_process_start_timestamp; 25 extern uint64_t performance_v8_start; 26 27 #define NODE_PERFORMANCE_MILESTONES(V) \ 28 V(TIME_ORIGIN_TIMESTAMP, "timeOriginTimestamp") \ 29 V(TIME_ORIGIN, "timeOrigin") \ 30 V(ENVIRONMENT, "environment") \ 31 V(NODE_START, "nodeStart") \ 32 V(V8_START, "v8Start") \ 33 V(LOOP_START, "loopStart") \ 34 V(LOOP_EXIT, "loopExit") \ 35 V(BOOTSTRAP_COMPLETE, "bootstrapComplete") 36 37 #define NODE_PERFORMANCE_ENTRY_TYPES(V) \ 38 V(GC, "gc") \ 39 V(HTTP, "http") \ 40 V(HTTP2, "http2") \ 41 V(NET, "net") \ 42 V(DNS, "dns") 43 44 enum PerformanceMilestone { 45 #define V(name, _) NODE_PERFORMANCE_MILESTONE_##name, 46 NODE_PERFORMANCE_MILESTONES(V) 47 #undef V 48 NODE_PERFORMANCE_MILESTONE_INVALID 49 }; 50 51 enum PerformanceEntryType { 52 #define V(name, _) NODE_PERFORMANCE_ENTRY_TYPE_##name, 53 NODE_PERFORMANCE_ENTRY_TYPES(V) 54 #undef V 55 NODE_PERFORMANCE_ENTRY_TYPE_INVALID 56 }; 57 58 class PerformanceState { 59 public: 60 struct SerializeInfo { 61 AliasedBufferIndex root; 62 AliasedBufferIndex milestones; 63 AliasedBufferIndex observers; 64 }; 65 66 explicit PerformanceState(v8::Isolate* isolate, 67 uint64_t time_origin, 68 double time_origin_timestamp, 69 const SerializeInfo* info); 70 SerializeInfo Serialize(v8::Local<v8::Context> context, 71 v8::SnapshotCreator* creator); 72 void Deserialize(v8::Local<v8::Context> context, 73 uint64_t time_origin, 74 double time_origin_timestamp); 75 friend std::ostream& operator<<(std::ostream& o, const SerializeInfo& i); 76 77 AliasedUint8Array root; 78 AliasedFloat64Array milestones; 79 AliasedUint32Array observers; 80 81 uint64_t performance_last_gc_start_mark = 0; 82 uint16_t current_gc_type = 0; 83 84 void Mark(enum PerformanceMilestone milestone, 85 uint64_t ts = PERFORMANCE_NOW()); 86 87 private: 88 void Initialize(uint64_t time_origin, double time_origin_timestamp); 89 void ResetMilestones(); 90 struct performance_state_internal { 91 // doubles first so that they are always sizeof(double)-aligned 92 double milestones[NODE_PERFORMANCE_MILESTONE_INVALID]; 93 uint32_t observers[NODE_PERFORMANCE_ENTRY_TYPE_INVALID]; 94 }; 95 }; 96 97 } // namespace performance 98 } // namespace node 99 100 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 101 102 #endif // SRC_NODE_PERF_COMMON_H_