32 using v8::FunctionCallbackInfo;
33 using v8::FunctionTemplate;
34 using v8::GCCallbackFlags;
36 using v8::HandleScope;
43 static uint64_t counter_gc_start_time;
44 static uint64_t counter_gc_end_time;
77 static void counter_gc_start(Isolate* isolate,
79 GCCallbackFlags flags) {
84 static void counter_gc_done(Isolate* isolate,
86 GCCallbackFlags flags) {
89 uint64_t totalperiod = endgc - counter_gc_end_time;
90 uint64_t gcperiod = endgc - counter_gc_start_time;
92 if (totalperiod > 0) {
93 unsigned int percent =
static_cast<unsigned int>(
94 (gcperiod * 100) / totalperiod);
97 counter_gc_end_time = endgc;
104 HandleScope scope(env->isolate());
108 void (*
func)(
const FunctionCallbackInfo<Value>&);
110 #define NODE_PROBE(name) #name, name 120 for (
size_t i = 0; i < arraysize(tab); i++) {
121 Local<String> key = OneByteString(env->isolate(), tab[i].name);
122 Local<Value> val = env->NewFunctionTemplate(tab[i].
func)->GetFunction();
123 target->Set(key, val);
132 counter_gc_end_time = counter_gc_start_time;
134 env->isolate()->AddGCPrologueCallback(counter_gc_start);
135 env->isolate()->AddGCEpilogueCallback(counter_gc_done);
void NODE_COUNT_HTTP_SERVER_RESPONSE()
void InitPerfCountersWin32()
void TermPerfCounters(Local< Object > target)
void NODE_COUNT_SERVER_CONN_OPEN()
void NODE_COUNT_HTTP_CLIENT_RESPONSE()
void NODE_COUNT_HTTP_SERVER_REQUEST()
void NODE_COUNT_SERVER_CONN_CLOSE()
void COUNTER_HTTP_SERVER_RESPONSE(const FunctionCallbackInfo< Value > &)
void COUNTER_HTTP_CLIENT_RESPONSE(const FunctionCallbackInfo< Value > &)
void NODE_COUNT_GC_PERCENTTIME(unsigned int percent)
void COUNTER_NET_SERVER_CONNECTION(const FunctionCallbackInfo< Value > &)
void InitPerfCounters(Environment *env, Local< Object > target)
void COUNTER_HTTP_SERVER_REQUEST(const FunctionCallbackInfo< Value > &)
void COUNTER_HTTP_CLIENT_REQUEST(const FunctionCallbackInfo< Value > &)
void TermPerfCountersWin32()
void COUNTER_NET_SERVER_CONNECTION_CLOSE(const FunctionCallbackInfo< Value > &)
uint64_t NODE_COUNT_GET_GC_RAWTIME()
void NODE_COUNT_HTTP_CLIENT_REQUEST()