diff --git a/bindings/cpu_profiler.cc b/bindings/cpu_profiler.cc index c3a733d2..06779fbd 100644 --- a/bindings/cpu_profiler.cc +++ b/bindings/cpu_profiler.cc @@ -139,8 +139,6 @@ void MeasurementsTicker::remove_heap_listener(std::string& profile_id, const std // CPU tickers void MeasurementsTicker::cpu_callback() { - uint64_t ts = uv_hrtime(); - uv_cpu_info_t* cpu = &cpu_stats; int count; int err = uv_cpu_info(&cpu, &count); @@ -148,6 +146,14 @@ void MeasurementsTicker::cpu_callback() { return; } + uint64_t ts = uv_hrtime(); + if(count < 1) { + for(auto cb : cpu_listeners) { + cb.second(ts, 0); + } + return; + } + uint64_t total = 0; uint64_t idle_total = 0;