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,
|
||||
enumerable: 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 performance {
|
||||
|
||||
using v8::Array;
|
||||
using v8::Context;
|
||||
using v8::DontDelete;
|
||||
using v8::Function;
|
||||
@ -264,26 +265,17 @@ void LoopIdleTime(const FunctionCallbackInfo<Value>& args) {
|
||||
|
||||
void UvMetricsInfo(const FunctionCallbackInfo<Value>& args) {
|
||||
Environment* env = Environment::GetCurrent(args);
|
||||
Isolate* isolate = env->isolate();
|
||||
uv_metrics_t metrics;
|
||||
|
||||
// uv_metrics_info always return 0
|
||||
CHECK_EQ(uv_metrics_info(env->event_loop(), &metrics), 0);
|
||||
|
||||
Local<Object> obj = Object::New(env->isolate());
|
||||
obj->Set(env->context(),
|
||||
env->loop_count(),
|
||||
Integer::NewFromUnsigned(env->isolate(), metrics.loop_count))
|
||||
.Check();
|
||||
obj->Set(env->context(),
|
||||
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);
|
||||
Local<Value> data[] = {
|
||||
Integer::New(isolate, metrics.loop_count),
|
||||
Integer::New(isolate, metrics.events),
|
||||
Integer::New(isolate, metrics.events_waiting),
|
||||
};
|
||||
Local<Array> arr = Array::New(env->isolate(), data, arraysize(data));
|
||||
args.GetReturnValue().Set(arr);
|
||||
}
|
||||
|
||||
void CreateELDHistogram(const FunctionCallbackInfo<Value>& args) {
|
||||
|
Loading…
Reference in New Issue
Block a user