You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by "Auzinger, Thomas" <TA...@ert.com> on 2007/05/07 23:24:26 UTC
RE: Newbie problem with batik speed
Thomas,
Texts are slower than lines by a ratio of two to one, but that's not it.
Part of the problem I suppose is that I made use of the "opacity" attribute
in a few places. I removed "opacity" and now all the arrows and texts show
up in about a second and the application moves faster overall. One second
is bearable, but still seems slow for such little data.
Below is the source code again, and from the log I can see that all the time
(between 100 and 250 ms each) is spent in the line:
dimensioning1.appendChild(dimensioning);
No urgency on that one though now.
Thanks,
Thomas
public void displayItem(GlobalAnalysisItem ai, int beat, int height) {
long t0 = System.currentTimeMillis();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
SVGDocument doc = jsvgCanvas.getSVGDocument();
int lArrow = 3;
int x1 = ai.getOnSet().intValue() / 2;
int x2 = ai.getOffSet().intValue() / 2;
int yBase = 100;
int yTop = -200;
int yLine = -height;
int yName = yLine - 2;
int yValue = yLine + 5;
String name = AnalysisItem.displayType(ai.getTypeID());
String value = ai.getValue().intValue() + "";
Element dimensioning1 = doc.getElementById("dimensioning");
Element dimensioning = jsvgCanvas.getSVGDocument()
.createElementNS(svgNS, "g");
// calipers
long t0a0 = System.currentTimeMillis();
dimensioning.appendChild(createLine(x1, yBase, x1, yTop));
long t0a = System.currentTimeMillis();
System.err.println("displayItemA:" + (t0a - t0a0));
dimensioning.appendChild(createLine(x2, yBase, x2, yTop));
// line
dimensioning.appendChild(createLine(x1, yLine, x2, yLine));
// left arrow
dimensioning.appendChild(createLine(x1, yLine, x1 + lArrow,
yLine + (lArrow / 2)));
dimensioning.appendChild(createLine(x1, yLine, x1 + lArrow,
yLine - (lArrow / 2)));
// right arrow
dimensioning.appendChild(createLine(x2, yLine, x2 - lArrow,
yLine + (lArrow / 2)));
dimensioning.appendChild(createLine(x2, yLine, x2 - lArrow,
yLine - (lArrow / 2)));
// name
dimensioning.appendChild(createText((x1 + x2) / 2, yName, name));
// value
dimensioning.appendChild(createText((x1 + x2) / 2, yValue, value));
long t2 = System.currentTimeMillis();
dimensioning1.appendChild(dimensioning);
long t1 = System.currentTimeMillis();
System.err.println("displayItem:" + (t1 - t0)+" "+(t1-t2));
}
public Element createLine(int x1, int y1, int x2, int y2) {
long t0 = System.currentTimeMillis();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Element line = jsvgCanvas.getSVGDocument().createElementNS(svgNS,
"line");
line.setAttributeNS(null, "x1", x1 + "");
line.setAttributeNS(null, "y1", y1 + "");
line.setAttributeNS(null, "x2", x2 + "");
line.setAttributeNS(null, "y2", y2 + "");
line.setAttributeNS(null, "style", "fill:none;stroke:black");
line.setAttributeNS(null, "stroke-width", ".25");
long t1 = System.currentTimeMillis();
System.err.println("line:" + (t1 - t0));
return line;
}
-----Original Message-----
From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
Sent: Friday, April 20, 2007 9:01 PM
To: batik-users@xmlgraphics.apache.org
Cc: batik-users@xmlgraphics.apache.org
Subject: RE: Newbie problem with batik speed
Hi Thomas,
"Auzinger, Thomas" <TA...@ert.com> wrote on 04/19/2007 10:01:06 AM:
> Actually that's what's happening ... displayIDMs() calls displayItem()
12
> times, there is only one Runnable. The DOM tree is updated 12 times
though
> from within this Runnable, could this be causing the problem?
No the 12 updates aren't likely to be the problem. 3secs is awfully
long. I would try skipping the text elements and see if that speeds
things up. If it helps a lot the problem might be a "bad" font on
the system.
>
> Thanks,
>
> Thomas
>
> -----Original Message-----
> From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
> Sent: Thursday, April 19, 2007 9:28 AM
> To: batik-users@xmlgraphics.apache.org
> Subject: Re: Newbie problem with batik speed
>
> Hi Thomas,
>
> "Auzinger, Thomas" <TA...@ert.com> wrote on 04/13/2007 03:40:46 PM:
>
> > 2. Displaying the measurements (i.e. drawing about 84 lines and
> > 24 texts) takes about 2-3 seconds on a 3GHz dual core machine.
> > The method below is called 12 times:
>
> > public void displayItem(GlobalAnalysisItem ai, int beat, int
height)
> {
>
>
> try {
> jsvgCanvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
> Runnable() {
> public void run() { ea.displayIDMs(); }
> });
> } catch (Exception ix) {}
>
> You shouldn't submit 12 separate Runnables otherwise the canvas will
> rerender the document between each runnable. Submit one runnable that
> calls displayItem 12 times.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org