aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Ushakov <Alexey.Ushakov@jetbrains.com>2018-02-07 16:18:10 +0300
committerAlexey Ushakov <Alexey.Ushakov@jetbrains.com>2018-02-09 00:57:36 +0300
commitceb76fddb9deaddcf412e43265e89c2563f758d4 (patch)
tree8f8ecc6e37929b816f8ee39b6fffe9e3489fb4e3
parentfb47d068c7ee60618c073ed0d13d245f512f1648 (diff)
downloadjdk8u_jdk-ceb76fddb9deaddcf412e43265e89c2563f758d4.tar.gz
JRE-646 Provide performance logging of graphics primitives
Enhanced logging (example: -Dsun.java2d.trace=log,ptime,td=3000000,verbose) (cherry picked from commit d38e16b)
-rw-r--r--src/share/classes/sun/java2d/loops/Blit.java6
-rw-r--r--src/share/classes/sun/java2d/loops/GraphicsPrimitive.java38
2 files changed, 39 insertions, 5 deletions
diff --git a/src/share/classes/sun/java2d/loops/Blit.java b/src/share/classes/sun/java2d/loops/Blit.java
index 7a337e1521..0c9b4ac940 100644
--- a/src/share/classes/sun/java2d/loops/Blit.java
+++ b/src/share/classes/sun/java2d/loops/Blit.java
@@ -324,9 +324,13 @@ public class Blit extends GraphicsPrimitive
int srcx, int srcy, int dstx, int dsty,
int width, int height)
{
- tracePrimitive(target);
+ if ((traceflags & TRACEPTIME) == 0) {
+ tracePrimitive(target);
+ }
+ long time = System.nanoTime();
target.Blit(src, dst, comp, clip,
srcx, srcy, dstx, dsty, width, height);
+ tracePrimitiveTime(target, System.nanoTime() - time);
}
}
}
diff --git a/src/share/classes/sun/java2d/loops/GraphicsPrimitive.java b/src/share/classes/sun/java2d/loops/GraphicsPrimitive.java
index 47db650374..93d8e05996 100644
--- a/src/share/classes/sun/java2d/loops/GraphicsPrimitive.java
+++ b/src/share/classes/sun/java2d/loops/GraphicsPrimitive.java
@@ -321,16 +321,24 @@ public abstract class GraphicsPrimitive {
public static int traceflags;
public static String tracefile;
public static PrintStream traceout;
+ public static long treshold = 0;
+ public static boolean verbose = false;
public static final int TRACELOG = 1;
public static final int TRACETIMESTAMP = 2;
public static final int TRACECOUNTS = 4;
+ public static final int TRACEPTIME = 8;
+
+ static void showTraceUsage() {
+ System.err.println("usage: -Dsun.java2d.trace="+
+ "[log[,timestamp]],[count],[ptime],"+
+ "[out:<filename>],[td=<treshold>],[help],[verbose]");
+ }
static {
GetPropertyAction gpa = new GetPropertyAction("sun.java2d.trace");
String trace = AccessController.doPrivileged(gpa);
if (trace != null) {
- boolean verbose = false;
int traceflags = 0;
StringTokenizer st = new StringTokenizer(trace, ",");
while (st.hasMoreTokens()) {
@@ -341,17 +349,23 @@ public abstract class GraphicsPrimitive {
traceflags |= GraphicsPrimitive.TRACELOG;
} else if (tok.equalsIgnoreCase("timestamp")) {
traceflags |= GraphicsPrimitive.TRACETIMESTAMP;
+ } else if (tok.equalsIgnoreCase("ptime")) {
+ traceflags |=GraphicsPrimitive.TRACEPTIME;
} else if (tok.equalsIgnoreCase("verbose")) {
verbose = true;
} else if (tok.regionMatches(true, 0, "out:", 0, 4)) {
tracefile = tok.substring(4);
+ } else if (tok.regionMatches(true, 0, "td=", 0, 3)) {
+ try {
+ treshold = Long.parseLong(tok.substring(3));
+ } catch (NumberFormatException e) {
+ showTraceUsage();
+ }
} else {
if (!tok.equalsIgnoreCase("help")) {
System.err.println("unrecognized token: "+tok);
}
- System.err.println("usage: -Dsun.java2d.trace="+
- "[log[,timestamp]],[count],"+
- "[out:<filename>],[help],[verbose]");
+ showTraceUsage();
}
}
if (verbose) {
@@ -474,6 +488,22 @@ public abstract class GraphicsPrimitive {
}
}
+ public synchronized static void tracePrimitiveTime(Object prim, long time) {
+ if (time > treshold && (traceflags & TRACEPTIME) != 0 && (traceflags & TRACELOG) != 0) {
+ PrintStream ps = getTraceOutputFile();
+ ps.println(prim + " time: " + time);
+ if (verbose) {
+ final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
+ if (stackTrace.length > 3) {
+ for (int i = 3; i < stackTrace.length; i++) {
+ ps.println(" " + stackTrace[i].toString());
+ }
+ }
+ ps.println();
+ }
+ }
+ }
+
protected void setupGeneralBinaryOp(GeneralBinaryOp gbo) {
int primID = gbo.getPrimTypeID();
String methodSignature = gbo.getSignature();