Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! os: do not call into JS to push values to an array in GetCPUInfo
  • Loading branch information
joyeecheung committed Nov 13, 2018
commit 07b541734546aa86d87fbba766d21b4e07f733ed
4 changes: 4 additions & 0 deletions src/node_os.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ static void GetCPUInfo(const FunctionCallbackInfo<Value>& args) {
if (err)
return;

// It's faster to create an array packed with all the data and
// assemble them into objects in JS than to call Object::Set() repeatedly
// The array is in the format
// [model, speed, (5 entries of cpu_times), model2, speed2, ...]
std::vector<Local<Value>> result(count * 7);
for (size_t i = 0; i < count; i++) {
Comment thread
refack marked this conversation as resolved.
uv_cpu_info_t* ci = cpu_infos + i;
Expand Down