Skip to content

Commit

Permalink
Another tweak for displaying performance.
Browse files Browse the repository at this point in the history
1. It is still interesting to see performance tags, even with the next task model.

2. Factor out "WorkOrder.moveNext" as a separate performance tag, something like "intertask" for new tasks.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1161183004
  • Loading branch information
scheglov committed Jun 5, 2015
1 parent 3fd32d4 commit 1c1497f
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 56 deletions.
80 changes: 45 additions & 35 deletions pkg/analysis_server/lib/src/get_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,40 @@ class GetHandler {
_writePage(buffer, 'Analysis Server - Analysis Performance', [],
(StringBuffer buffer) {
buffer.write('<h3>Analysis Performance</h3>');

//
// Write performance tags.
//
{
buffer.write('<p><b>Time spent in each phase of analysis</b></p>');
buffer.write(
'<table style="border-collapse: separate; border-spacing: 10px 5px;">');
_writeRow(buffer, ['Time (in ms)', 'Percent', 'Analysis Phase'],
header: true);
// prepare sorted tags
List<PerformanceTag> tags = PerformanceTag.all.toList();
tags.remove(ServerPerformanceStatistics.idle);
tags.sort((a, b) => b.elapsedMs - a.elapsedMs);
// prepare total time
int totalTime = 0;
tags.forEach((PerformanceTag tag) {
totalTime += tag.elapsedMs;
});
// write rows
void writeRow(PerformanceTag tag) {
double percent = (tag.elapsedMs * 100) / totalTime;
String percentStr = '${percent.toStringAsFixed(2)}%';
_writeRow(buffer, [tag.elapsedMs, percentStr, tag.label],
classes: ["right", "right", null]);
}
tags.forEach(writeRow);
buffer.write('</table>');
}

//
// Write new task model timing information.
//
if (AnalysisEngine.instance.useTaskModel) {
//
// Write new task model timing information.
//
buffer.write('<p><b>Task performace data</b></p>');
buffer.write(
'<table style="border-collapse: separate; border-spacing: 10px 5px;">');
Expand All @@ -281,50 +311,30 @@ class GetHandler {
List<Type> taskClasses = stopwatchMap.keys.toList();
taskClasses.sort((Type first, Type second) =>
first.toString().compareTo(second.toString()));
int totalTime = 0;
taskClasses.forEach((Type taskClass) {
int count = countMap[taskClass];
if (count == null) {
count = 0;
}
int totalTime = stopwatchMap[taskClass].elapsedMilliseconds;
int taskTime = stopwatchMap[taskClass].elapsedMilliseconds;
totalTime += taskTime;
_writeRow(buffer, [
taskClass.toString(),
count,
totalTime,
count <= 0 ? '-' : (totalTime / count).toStringAsFixed(3)
taskTime,
count <= 0 ? '-' : (taskTime / count).toStringAsFixed(3)
], classes: [null, "right", "right", "right"]);
});
_writeRow(buffer, ['Total', '-', totalTime, '-'],
classes: [null, "right", "right", "right"]);
buffer.write('</table>');
} else {
//
// Write old task model timing information.
//
{
buffer.write('<p><b>Time spent in each phase of analysis</b></p>');
buffer.write(
'<table style="border-collapse: separate; border-spacing: 10px 5px;">');
_writeRow(buffer, ['Time (in ms)', 'Percent', 'Analysis Phase'],
header: true);
// prepare sorted tags
List<PerformanceTag> tags = PerformanceTag.all.toList();
tags.remove(ServerPerformanceStatistics.idle);
tags.sort((a, b) => b.elapsedMs - a.elapsedMs);
// prepare total time
int totalTime = 0;
tags.forEach((PerformanceTag tag) {
totalTime += tag.elapsedMs;
});
// write rows
void writeRow(PerformanceTag tag) {
double percent = (tag.elapsedMs * 100) / totalTime;
String percentStr = '${percent.toStringAsFixed(2)}%';
_writeRow(buffer, [tag.elapsedMs, percentStr, tag.label],
classes: ["right", "right", null]);
}
tags.forEach(writeRow);
buffer.write('</table>');
}
}

//
// Write old task model transition information.
//
{
Map<DataDescriptor, Map<CacheState, int>> transitionMap =
SourceEntry.transitionMap;
buffer.write(
Expand Down
47 changes: 26 additions & 21 deletions pkg/analyzer/lib/src/task/driver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import 'package:analyzer/src/task/inputs.dart';
import 'package:analyzer/src/task/manager.dart';
import 'package:analyzer/task/model.dart';

final PerformanceTag workOrderMoveNextPerfTag =
new PerformanceTag('WorkOrder.moveNext');

/**
* An object that is used to cause analysis to be performed until all of the
* required analysis information has been computed.
Expand Down Expand Up @@ -716,29 +719,31 @@ class WorkOrder implements Iterator<WorkItem> {

@override
bool moveNext() {
if (currentItems != null && currentItems.length > 1) {
// Yield more items.
currentItems.removeLast();
return true;
} else {
// Get a new strongly connected component.
StronglyConnectedComponent<WorkItem> nextStronglyConnectedComponent =
_dependencyWalker.getNextStronglyConnectedComponent();
if (nextStronglyConnectedComponent == null) {
currentItems = null;
return false;
}
currentItems = nextStronglyConnectedComponent.nodes;
if (nextStronglyConnectedComponent.containsCycle) {
// A cycle has been found.
for (WorkItem item in currentItems) {
item.dependencyCycle = currentItems.toList();
}
return workOrderMoveNextPerfTag.makeCurrentWhile(() {
if (currentItems != null && currentItems.length > 1) {
// Yield more items.
currentItems.removeLast();
return true;
} else {
assert(currentItems.length == 1);
// Get a new strongly connected component.
StronglyConnectedComponent<WorkItem> nextStronglyConnectedComponent =
_dependencyWalker.getNextStronglyConnectedComponent();
if (nextStronglyConnectedComponent == null) {
currentItems = null;
return false;
}
currentItems = nextStronglyConnectedComponent.nodes;
if (nextStronglyConnectedComponent.containsCycle) {
// A cycle has been found.
for (WorkItem item in currentItems) {
item.dependencyCycle = currentItems.toList();
}
} else {
assert(currentItems.length == 1);
}
return true;
}
return true;
}
});
}
}

Expand Down

0 comments on commit 1c1497f

Please sign in to comment.