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

Untracked time [DNM] #16

Open
wants to merge 2 commits 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
48 changes: 46 additions & 2 deletions lib/static/components/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_(data.cl).map('d').sum()?

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));
Expand All @@ -47,6 +67,21 @@ const groupByCommand = (data) => {
return _.values(map);
};

/**
* Для некоторых команд поле d не заполнено. Чтобы незаполненное значение не влияло на последующие вычисления,
* установим его в 0.
* @param {Object} command
*/
const fixD = (command) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем вставлять этот костыль? эти данные сохраняет этот же плагин. Добавь эту логику туда

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 +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);
Expand All @@ -80,7 +122,7 @@ const groupByExecutionThread = (tests) => {
}

return threads.length;
}
};

return _.sortBy(tests, 'ts').reduce((threads, test) => {
const idx = findThreadIdx(test, threads);
Expand All @@ -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) => {
Expand Down