diff --git a/lib/static/components/panel-commands.jsx b/lib/static/components/panel-commands.jsx index de0a8dd..ced17a3 100644 --- a/lib/static/components/panel-commands.jsx +++ b/lib/static/components/panel-commands.jsx @@ -7,6 +7,8 @@ class PanelCommands extends PanelBase { getColumns() { return [].concat( this.commandsCountColumn(), + this.timeSumColumn(), + this.exclusiveTimeSumColumn(), this.percentileColumn(95), this.percentileColumn(80), this.percentileColumn(50), @@ -27,6 +29,24 @@ class PanelCommands extends PanelBase { }; } + timeSumColumn() { + return { + Header: 'Время вкл., мс', + getHeaderProps: () => ({title: 'Суммарное время работы команды, включая вложенные'}), + accessor: 'dSum', + width: 120 + } + } + + exclusiveTimeSumColumn() { + return { + Header: 'Время искл., мс', + getHeaderProps: () => ({title: 'Суммарное время работы команды, исключая вложенные'}), + accessor: 'dExclusiveSum', + width: 120 + } + } + percentileColumn(percentile) { return { Header: `${percentile}-й, мс`, diff --git a/lib/static/components/utils.js b/lib/static/components/utils.js index 21ff2d1..f279bf1 100644 --- a/lib/static/components/utils.js +++ b/lib/static/components/utils.js @@ -33,11 +33,31 @@ const groupByCommand = (data) => { command = { cn: data.cn, bid: browser, - d: [] + d: [], + dExclusive: [] }; map[key] = command; } command.d.push(data.d); + const dExclusive = data.d - _.sum(_.map(data.cl, 'd')); + command.dExclusive.push(dExclusive); + } + + if (data.n) { + const key = `${browser}#untracked`; + let command = map[key]; + if (!command) { + command = { + cn: "untracked", + bid: browser, + d: [], + dExclusive: [] + }; + map[key] = command; + } + const untracked = Math.max(0, data.te - data.ts - _.sum(_.map(data.cl, 'd'))); + command.d.push(untracked); + command.dExclusive.push(untracked); } data.cl.forEach((command) => goDeep(command, browser)); @@ -47,6 +67,21 @@ const groupByCommand = (data) => { return _.values(map); }; +/** + * Для некоторых команд поле d не заполнено. Чтобы незаполненное значение не влияло на последующие вычисления, + * установим его в 0. + * @param {Object} command + */ +const fixD = (command) => { + if (command.cn) { + if (!command.d) { + command.d = 0; + } + } + + command.cl.forEach(fixD); +}; + const fetchPercentiles = (data) => { const writePercentile = (test, perc) => { const arr = test.d; @@ -62,6 +97,13 @@ const fetchPercentiles = (data) => { }); }; +const fetchSums = (data) => { + data.forEach((command) => { + command.dSum = _.sum(command.d); + command.dExclusiveSum = _.sum(command.dExclusive); + }); +}; + const groupByExecutionThread = (tests) => { const findThreadIdx = (test, threads) => { const idxBySession = threads.findIndex((thread) => _.last(thread).sid === test.sid); @@ -80,7 +122,7 @@ const groupByExecutionThread = (tests) => { } return threads.length; - } + }; return _.sortBy(tests, 'ts').reduce((threads, test) => { const idx = findThreadIdx(test, threads); @@ -100,8 +142,10 @@ export default { return countTestCommands(groupedData); }, prepareDataForCommandsTab: (data) => { + data.forEach(fixD); const groupedData = groupByCommand(data); fetchPercentiles(groupedData); + fetchSums(groupedData); return groupedData; }, prepareDataForTimelineTab: (data) => {