Skip to content

Commit

Permalink
Added columns with total execution time per command.
Browse files Browse the repository at this point in the history
  • Loading branch information
Slava Baginov committed Nov 1, 2018
1 parent 3dc2f08 commit a912973
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
20 changes: 20 additions & 0 deletions lib/static/components/panel-commands.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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}-й, мс`,
Expand Down
31 changes: 29 additions & 2 deletions lib/static/components/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ 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);
}

data.cl.forEach((command) => goDeep(command, browser));
Expand All @@ -47,6 +50,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;
Expand All @@ -62,6 +80,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);
Expand All @@ -80,7 +105,7 @@ const groupByExecutionThread = (tests) => {
}

return threads.length;
}
};

return _.sortBy(tests, 'ts').reduce((threads, test) => {
const idx = findThreadIdx(test, threads);
Expand All @@ -100,8 +125,10 @@ export default {
return countTestCommands(groupedData);
},
prepareDataForCommandsTab: (data) => {
data.forEach(fixD);
const groupedData = groupByCommand(data);
fetchPercentiles(groupedData);
fetchSums(groupedData);
return groupedData;
},
prepareDataForTimelineTab: (data) => {
Expand Down

0 comments on commit a912973

Please sign in to comment.