mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
src,lib: optimize nodeTiming.uvMetricsInfo
PR-URL: https://github.com/nodejs/node/pull/55614 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
This commit is contained in:
parent
9b6cea6ebe
commit
2d6f9c613c
@ -128,7 +128,14 @@ class PerformanceNodeTiming {
|
|||||||
__proto__: null,
|
__proto__: null,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true,
|
configurable: true,
|
||||||
get: uvMetricsInfo,
|
get: () => {
|
||||||
|
const metrics = uvMetricsInfo();
|
||||||
|
return {
|
||||||
|
loopCount: metrics[0],
|
||||||
|
events: metrics[1],
|
||||||
|
eventsWaiting: metrics[2],
|
||||||
|
};
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
namespace node {
|
namespace node {
|
||||||
namespace performance {
|
namespace performance {
|
||||||
|
|
||||||
|
using v8::Array;
|
||||||
using v8::Context;
|
using v8::Context;
|
||||||
using v8::DontDelete;
|
using v8::DontDelete;
|
||||||
using v8::Function;
|
using v8::Function;
|
||||||
@ -264,26 +265,17 @@ void LoopIdleTime(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
void UvMetricsInfo(const FunctionCallbackInfo<Value>& args) {
|
void UvMetricsInfo(const FunctionCallbackInfo<Value>& args) {
|
||||||
Environment* env = Environment::GetCurrent(args);
|
Environment* env = Environment::GetCurrent(args);
|
||||||
|
Isolate* isolate = env->isolate();
|
||||||
uv_metrics_t metrics;
|
uv_metrics_t metrics;
|
||||||
|
|
||||||
// uv_metrics_info always return 0
|
// uv_metrics_info always return 0
|
||||||
CHECK_EQ(uv_metrics_info(env->event_loop(), &metrics), 0);
|
CHECK_EQ(uv_metrics_info(env->event_loop(), &metrics), 0);
|
||||||
|
Local<Value> data[] = {
|
||||||
Local<Object> obj = Object::New(env->isolate());
|
Integer::New(isolate, metrics.loop_count),
|
||||||
obj->Set(env->context(),
|
Integer::New(isolate, metrics.events),
|
||||||
env->loop_count(),
|
Integer::New(isolate, metrics.events_waiting),
|
||||||
Integer::NewFromUnsigned(env->isolate(), metrics.loop_count))
|
};
|
||||||
.Check();
|
Local<Array> arr = Array::New(env->isolate(), data, arraysize(data));
|
||||||
obj->Set(env->context(),
|
args.GetReturnValue().Set(arr);
|
||||||
env->events(),
|
|
||||||
Integer::NewFromUnsigned(env->isolate(), metrics.events))
|
|
||||||
.Check();
|
|
||||||
obj->Set(env->context(),
|
|
||||||
env->events_waiting(),
|
|
||||||
Integer::NewFromUnsigned(env->isolate(), metrics.events_waiting))
|
|
||||||
.Check();
|
|
||||||
|
|
||||||
args.GetReturnValue().Set(obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateELDHistogram(const FunctionCallbackInfo<Value>& args) {
|
void CreateELDHistogram(const FunctionCallbackInfo<Value>& args) {
|
||||||
|
Loading…
Reference in New Issue
Block a user