diff --git a/desktop/flipper-ui-core/src/utils/messageQueue.tsx b/desktop/flipper-ui-core/src/utils/messageQueue.tsx index 0dcb03aa2..8c6470a06 100644 --- a/desktop/flipper-ui-core/src/utils/messageQueue.tsx +++ b/desktop/flipper-ui-core/src/utils/messageQueue.tsx @@ -29,7 +29,11 @@ function processMessagesImmediately( const reducerStartTime = Date.now(); try { plugin.receiveMessages(messages); - addBackgroundStat(plugin.definition.id, Date.now() - reducerStartTime); + addBackgroundStat( + plugin.definition.id, + messages, + Date.now() - reducerStartTime, + ); } catch (e) { console.error( `Failed to process event for plugin ${plugin.definition.id}`, diff --git a/desktop/flipper-ui-core/src/utils/pluginStats.tsx b/desktop/flipper-ui-core/src/utils/pluginStats.tsx index f5462426c..730b2869c 100644 --- a/desktop/flipper-ui-core/src/utils/pluginStats.tsx +++ b/desktop/flipper-ui-core/src/utils/pluginStats.tsx @@ -8,6 +8,7 @@ */ import {onBytesReceived} from '../dispatcher/tracking'; +import {Message} from '../reducers/pluginMessageQueue'; type StatEntry = { cpuTimeTotal: number; // Total time spend in persisted Reducer @@ -105,7 +106,11 @@ function createEmptyStat(): StatEntry { }; } -export function addBackgroundStat(plugin: string, cpuTime: number) { +export function addBackgroundStat( + plugin: string, + messages: Message[], + cpuTime: number, +) { if (!pluginBackgroundStats.has(plugin)) { pluginBackgroundStats.set(plugin, createEmptyStat()); } @@ -118,6 +123,7 @@ export function addBackgroundStat(plugin: string, cpuTime: number) { if (cpuTime > MAX_BACKGROUND_TASK_TIME) { console.warn( `Plugin ${plugin} took too much time while doing background: ${cpuTime}ms. Handling background messages should take less than ${MAX_BACKGROUND_TASK_TIME}ms.`, + messages, ); } }