Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added columns with total execution time per command. #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
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 = Math.max(0, 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