From a9f2b6787463dcf19582b03e1b9141e8becd6f72 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Thu, 23 Jan 2020 01:41:13 -0800 Subject: [PATCH] Fix background plugin stats Summary: Discovered that all gathered plugin stats where empty due to mis-using Object.entries. Fixed that. Also added a accumulated cpuTime metric, which should be great for a uniform trend line. Reviewed By: jknoxville Differential Revision: D19517279 fbshipit-source-id: a6df83eea000a5d59fe692a3795fd58ae6457821 --- src/utils/messageQueue.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/utils/messageQueue.tsx b/src/utils/messageQueue.tsx index f58594a35..873714d0f 100644 --- a/src/utils/messageQueue.tsx +++ b/src/utils/messageQueue.tsx @@ -38,14 +38,23 @@ export function resetPluginBackgroundStatsDelta() { }); } -export function getPluginBackgroundStats(): {[plugin: string]: StatEntry} { - return Array.from(Object.entries(pluginBackgroundStats)).reduce( +export function getPluginBackgroundStats(): { + cpuTime: number; // amount of ms cpu used since the last stats (typically every minute) + byPlugin: {[plugin: string]: StatEntry}; +} { + let cpuTime: number = 0; + const byPlugin = Array.from(pluginBackgroundStats.entries()).reduce( (aggregated, [pluginName, data]) => { + cpuTime += data.cpuTimeDelta; aggregated[pluginName] = data; return aggregated; }, {} as {[plugin: string]: StatEntry}, ); + return { + cpuTime, + byPlugin, + }; } if (window) {