Hi.

My drawing operation was too slow with respect to Java.
I observed the code. So I get Canvas is faster than Graphics2D with AA
on.
But what was that slowness?

Many times, I'm creating  a point object with several methods. The
creation of those objects were much slower than java.

I deleted the unnecessary methods. Then I reduced the problem as
follows:

CODE BEGIN
<code>

public class MGPoint
{
  public double[] coor;

  public MGPoint(double x, double y ) {
    coor = new double[2];
    coor[0] = x;
    coor[1] = y;
  }

  public double getX()
  {
     return coor[0];
  }


  public double getY()
  {
     return coor[1];
  }

  public int getDimension()
  {
     return coor.length;
  }

  public void setCoordinates(double x, double y)
  {
       coor[0] = x;
       coor[1] = y;
   }

}


public class MGPoint2
{
  public double x;
  public double y;

  public MGPoint2(double x, double y ) {
    this.x  = x;
    this.y = y;
  }

  public double getX()
  {
     x;
  }


  public double getY()
  {
     y;
  }

  public int getDimension()
  {
     return 2;
  }

  public void setCoordinates(double x, double y)
  {
       this.x = x;
       this.y = y;
   }

}


public class Performance implements EntryPoint
{
  public void onModuleLoad()
  {
     final TextBox box = new TextBox();
     box.setText("100000");

     final Button button = new Button("");
     button.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event)
        {
             int times = Integer.parseInt(box.getText());
             Duration d = new Duration();
             double z = 0;
             for(int i = 0; i < times; i++)
             {
                  MGPoint point = new MGPoint(26,45);
                  double x = point.getX();
                  double y = point.getY();
                  int dimension = point.getDimension();
                  z = x + y + dimension;
             }
             int time = d.elapsedMillis();

             button.setText(time + "::::" + z) ;
        }

     });

     final Button button2 = new Button("");
     button.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event)
        {
             int times = Integer.parseInt(box.getText());
             Duration d = new Duration();
             double z = 0;
             for(int i = 0; i < times; i++)
             {
                  MGPoint2 point = new MGPoint2(26,45);
                  double x = point.getX();
                  double y = point.getY();
                  int dimension = point.getDimension();
                  z = x + y + dimension;
             }
             int time = d.elapsedMillis();

             button2.setText(time + "::::" + z) ;
        }

     });

      RootPanel.get().add(box);
      RootPanel.get().add(button1);
      RootPanel.get().add(button2);
   }
}

</code>
CODE END


The x,y approach takes 2 ms in chrome, 10 ms in firefox.
The double array approach takes 200 ms in chrome, 400 ms in firefox.

Java (Development mode) does below 4 ms in both case.

Is it GWT specific?
What are your suggestions? How can I decrease the time?




-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to