summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorTimur Achmetow2013-04-18 15:58:45 (EDT)
committer Timur Achmetow2013-04-19 10:13:30 (EDT)
commitdb33172bf2b9bd2b1db8bfc4f1271a2ec1a11bfd (patch)
treecaa3f60c35c21b831a95ea34c44adafeb0ddf220
parent1098a10c03a21d8feae44c9d4b947d56ea4d014d (diff)
downloadorg.eclipse.recommenders-db33172bf2b9bd2b1db8bfc4f1271a2ec1a11bfd.zip
org.eclipse.recommenders-db33172bf2b9bd2b1db8bfc4f1271a2ec1a11bfd.tar.gz
org.eclipse.recommenders-db33172bf2b9bd2b1db8bfc4f1271a2ec1a11bfd.tar.bz2
NEW - bug 401851: [gsoc] Usage Data Collection for Code Completion refs/changes/37/12037/3
- final declaration for local vars removed Change-Id: I304a1943a0f682bf6b0d8938ffb713d987eade9b Signed-off-by: Timur Achmetow <achmetow84@googlemail.com>
-rw-r--r--plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/StatisticsPreferencePage.java43
1 files changed, 27 insertions, 16 deletions
diff --git a/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/StatisticsPreferencePage.java b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/StatisticsPreferencePage.java
index e6ea252..fb7d087 100644
--- a/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/StatisticsPreferencePage.java
+++ b/plugins/org.eclipse.recommenders.completion.rcp.sandbox/src/org/eclipse/recommenders/internal/completion/rcp/sandbox/StatisticsPreferencePage.java
@@ -56,7 +56,7 @@ public class StatisticsPreferencePage extends PreferencePage implements IWorkben
private final class BuggyEventsPredicate implements Predicate<CompletionEvent> {
@Override
public boolean apply(CompletionEvent input) {
- return input.numberOfProposals < 1 || input.sessionEnded < input.sessionStarted;
+ return (input.numberOfProposals < 1) || (input.sessionEnded < input.sessionStarted);
}
}
@@ -100,8 +100,8 @@ public class StatisticsPreferencePage extends PreferencePage implements IWorkben
protected Control createContents(Composite parent) {
createWidgets(parent);
appendNumberOfCompletionEvents();
- appendTimeSpent();
appendNumberOfKeystrokesSaved();
+ appendTimeSpent();
appendNumberOfCompletionsByCompletionKind();
appendNumberOfCompletionsByReceiverType();
@@ -143,14 +143,25 @@ public class StatisticsPreferencePage extends PreferencePage implements IWorkben
for (CompletionEvent e : okayEvents) {
total += e.numberOfProposals;
}
- int selected = appliedEvents.size();
+ int completedInPercent = calculatePercentData(appliedEvents);
styledString.append("Number of times code completion triggered: ")
.append(format("%,d", okayEvents.size()), COUNTER_STYLER).append("\n");
- int aborted = abortedEvents.size();
+ int abortedInPercent = calculatePercentData(abortedEvents);
+
+ styledString.append("Number of concluded completions: ")
+ .append(appliedEvents.size() + " (" + completedInPercent + "%)", COUNTER_STYLER).append("\n");
+ styledString.append("Number of aborted completions: ")
+ .append(abortedEvents.size() + " (" + abortedInPercent + "%)", COUNTER_STYLER).append("\n");
styledString.append("Number of proposals offered by code completion: ").append(total + "", COUNTER_STYLER)
.append("\n");
- styledString.append("Number of aborted completions: ").append(aborted + "", COUNTER_STYLER).append("\n");
- styledString.append("Number of concluded completions: ").append(selected + "", COUNTER_STYLER).append("\n");
+ }
+
+ private int calculatePercentData(Collection<CompletionEvent> list) {
+ if (okayEvents.size() == 0) {
+ return okayEvents.size();
+ }
+ double division = (list.size() / (double) okayEvents.size()) * 100;
+ return (int) Math.round(division);
}
private void appendNumberOfKeystrokesSaved() {
@@ -169,6 +180,7 @@ public class StatisticsPreferencePage extends PreferencePage implements IWorkben
double mean = mean(strokes.toArray());
styledString.append("Average number of keystrokes saved per completion: ").append(format("%.2f", mean),
COUNTER_STYLER);
+ styledString.append("\n");
}
private void appendTimeSpent() {
@@ -190,9 +202,7 @@ public class StatisticsPreferencePage extends PreferencePage implements IWorkben
//
.append("\n - concluded session: ").append(format("%,d ms", meanApplied), COUNTER_STYLER)
//
- .append("\n - aborted session: ").append(format("%,d ms", meanAborted), COUNTER_STYLER)
- //
- .append("\n");
+ .append("\n - aborted session: ").append(format("%,d ms", meanAborted), COUNTER_STYLER);
}
private String toTimeString(long time) {
@@ -216,13 +226,14 @@ public class StatisticsPreferencePage extends PreferencePage implements IWorkben
Bag<ProposalKind> b = TreeBag.newTreeBag();
for (final ProposalKind kind : ProposalKind.values()) {
- Collection<CompletionEvent> byKind = Collections2.filter(okayEvents, new Predicate<CompletionEvent>() {
-
- @Override
- public boolean apply(CompletionEvent input) {
- return kind == input.applied;
- }
- });
+ Collection<CompletionEvent> byKind = Collections2.filter(okayEvents,
+ new Predicate<CompletionEvent>() {
+
+ @Override
+ public boolean apply(CompletionEvent input) {
+ return kind == input.applied;
+ }
+ });
if (byKind.size() > 0) {
b.add(kind, byKind.size());
}