mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
print median
This commit is contained in:
@@ -47,19 +47,24 @@ class DelayMeter {
|
||||
}
|
||||
|
||||
double getMin() {
|
||||
return myStats.getMin() / 1000000.0D;
|
||||
return myStats.getMin();
|
||||
}
|
||||
|
||||
double getMax() {
|
||||
return myStats.getMax() / 1000000.0D;
|
||||
return myStats.getMax();
|
||||
}
|
||||
|
||||
double getMean() {
|
||||
return myStats.getMean() / 1000000.0D;
|
||||
return myStats.getMean();
|
||||
}
|
||||
|
||||
double getStandardDeviation() {
|
||||
return myStats.getStandardDeviation() / 1000000.0D;
|
||||
return myStats.getStandardDeviation();
|
||||
}
|
||||
|
||||
public String stat() {
|
||||
return myStats.stat();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+1
-7
@@ -173,7 +173,7 @@ class ImmediatePainterImpl implements ImmediatePainter {
|
||||
myCharsTyped++;
|
||||
|
||||
if (myCharsTyped == TYPING_STATS_SAMPLE_SIZE) {
|
||||
String stats = formatTypingLatencyStats(myTypingLatencyMeter);
|
||||
String stats = "Zero-latency: "+isZeroLatencyTypingEnabled()+"; "+myTypingLatencyMeter.stat();
|
||||
printToEventLog(stats);
|
||||
|
||||
resetTypingLatencyStats();
|
||||
@@ -181,12 +181,6 @@ class ImmediatePainterImpl implements ImmediatePainter {
|
||||
}
|
||||
}
|
||||
|
||||
private static String formatTypingLatencyStats(DelayMeter meter) {
|
||||
return String.format("Zero-latency: %3s; typing delay, ms: min: %5.1f | max: %5.1f | avg: %5.1f | sigma: %4.1f",
|
||||
isZeroLatencyTypingEnabled() ? "on" : "off",
|
||||
meter.getMin(), meter.getMax(), meter.getMean(), meter.getStandardDeviation());
|
||||
}
|
||||
|
||||
private void printToEventLog(String message) {
|
||||
NotificationGroup group = NotificationGroup.logOnlyGroup("typing-delay-stats");
|
||||
Notification notification = group.createNotification(message, NotificationType.INFORMATION);
|
||||
|
||||
@@ -15,21 +15,25 @@
|
||||
*/
|
||||
package com.intellij.openapi.editor.impl;
|
||||
|
||||
import gnu.trove.TDoubleArrayList;
|
||||
|
||||
/**
|
||||
* @author Pavel Fatin
|
||||
*/
|
||||
class SummaryStatistics {
|
||||
private int myCount = 0;
|
||||
private int myCount;
|
||||
|
||||
private double myMin = Double.MAX_VALUE;
|
||||
|
||||
private double myMax = 0.0D;
|
||||
private double myMax;
|
||||
|
||||
private double myMean = 0.0D;
|
||||
private double myMean;
|
||||
|
||||
private double myS = 0.0D;
|
||||
private double myS;
|
||||
private final TDoubleArrayList values = new TDoubleArrayList();
|
||||
|
||||
void accept(double value) {
|
||||
values.add(value);
|
||||
myCount++;
|
||||
|
||||
myMin = Math.min(myMin, value);
|
||||
@@ -47,18 +51,25 @@ class SummaryStatistics {
|
||||
}
|
||||
|
||||
double getMin() {
|
||||
return myMin == Double.MAX_VALUE ? 0.0D : myMin;
|
||||
return (myMin == Double.MAX_VALUE ? 0.0D : myMin) / 1000000;
|
||||
}
|
||||
|
||||
double getMax() {
|
||||
return myMax;
|
||||
return myMax / 1000000;
|
||||
}
|
||||
|
||||
double getMean() {
|
||||
return myMean;
|
||||
return myMean / 1000000;
|
||||
}
|
||||
|
||||
double getStandardDeviation() {
|
||||
return Math.sqrt(myS / (myCount - 1));
|
||||
return Math.sqrt(myS / (myCount - 1)) / 1000000;
|
||||
}
|
||||
|
||||
public String stat() {
|
||||
values.sort();
|
||||
double median = values.get(values.size() / 2)/1000000;
|
||||
return String.format("typing delay, ms: min: %5.1f | max: %5.1f | avg: %5.1f | median: %4.1f",
|
||||
getMin(), getMax(), getMean(), median);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user