Re: Array Performance

2011-10-25 Thread ihsan ciftci
I forgot to mention the for loop invariant.

By test results are according to

var times = document.getElementById("times").value;
//Began capturing time
for(i=0; i < times; ++i)
{
   ...
}

I have converted it to

var times = parseInt(document.getElementById("times").value);
//Began capturing time
for(i=0; i < times; ++i)
{
   ...
}


So the results are:


My results are a bit strange.
1 million times
(Chrome 14 results)
JS X-Y: mgpoint1 : 645
JS Array: mgpoint2 : 718
Proto X-Y: mgpoint3 : 37
Proto Array: mgpoint4 : 56
Optimized X-Y: mgpoint5 : 23
GWT X-Y: MGPoint2 : 31
GWT Array: MGPoint : 2461

1 million times
(Firefox 5 results)
JS X-Y: mgpoint1 : 414
JS Array: mgpoint2 : 576
Proto X-Y: mgpoint3 : 120
Proto Array: mgpoint4 : 204
Optimized X-Y: mgpoint5: 114
GWT X-Y: MGPoint2 : 137
GWT Array: MGPoint : 4014


-XdisableCastChecking resulted with no change.


On Oct 25, 1:09 pm, Thomas Broyer  wrote:
> Compile in -style PRETTY to see how GWT compiles your Java code down to JS.
> There won't be getX/getY (they'll be inlined), at least in the x,y case (and
> if there are, they'll be "staticified": getX(point) instead of
> point.getX()). And you'll probably see type coercion/checking in the array
> case (and if that's the case, as I suspect, it's what causes the difference
> in performance between your two implementations).

-- 
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.



Re: Array Performance

2011-10-25 Thread ihsan ciftci
I wrote JS equivalent of my test case in 4 ways.

function mgpoint1(x,y)
{
  this.x = x;
  this.y = y;
  this.getX = function()
  {
 return this.x;
  }

  this.getY = function()
  {
 return this.y;
  }
  this.getDimension = function()
  {
 return 2;
  }
  this.setCoordinates = function(x,y)
  {
 this.x = x;
 this.y = y;
  }
}

mgpoint2 is array version of mgpoint1.
mgpoint3 is prototype version of mgpoin1.
mgpoint4 is prototype version of mgpoint2.


function mgpoint3(x,y)
{
  this.x = x;
  this.y = y;
}

  mgpoint3.prototype.getX = function()
  {
 return this.x;
  }

  mgpoint3.prototype.getY = function()
  {
 return this.y;
  }
  mgpoint3.prototype.getDimension = function()
  {
 return 2;
  }
  mgpoint3.prototype.setCoordinates = function(x,y)
  {
 this.x = x;
 this.y = y;
  }

The test code is

var i;
var z = 0;
for(i=0; i < 100; ++i )
{
  var point = new mgpoint1(26,45);
  var x = point.getX();
  var y = point.getY();
  var dimension = point.getDimension();
  z = x + y + dimension;
}

Then I wrote another case for simple optimization in js.

function mgpoint5()
{
 this.x = 26;
 this.y = 45;
}

var i, x, y, point;
var z = 0;
for(i=0; i < 100; ++i )
{
  point = new mgpoint5();
  x = point.x;
  y = point.y;
  z = x + y + 2;
}



My results are a bit strange.
1 million times
(Chrome 14 results)
JS X-Y: mgpoint1 : 1021
JS Array: mgpoint2 : 1061
Proto X-Y: mgpoint3 : 310
Proto Array: mgpoint4 : 356
Optimized X-Y: mgpoint5 : 308

GWT X-Y: MGPoint2 : 31
GWT Array: MGPoint : 2327


1 million times
(Firefox 5 results)
JS X-Y: mgpoint1 : 1499
JS Array: mgpoint2 : 1732
Proto X-Y: mgpoint3 : 1166
Proto Array: mgpoint4 : 1379
Optimized X-Y: mgpoint5: 455

GWT X-Y: MGPoint2 : 342
GWT Array: MGPoint : 5613









On Oct 24, 7:21 pm, Thomas Broyer  wrote:
> Are you compiling with -XdisableCastChecking? That might make a difference.

-- 
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.



Re: Array Performance

2011-10-24 Thread ihsan ciftci
No effect.

On 24 Ekim, 19:21, Thomas Broyer  wrote:
> Are you compiling with -XdisableCastChecking? That might make a difference.

-- 
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.



Array Performance

2011-10-24 Thread ihsan ciftci
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


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("10");

 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 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.



Re: Yet another obfuscation question, but related with Java Source Code Obfuscation

2011-09-26 Thread ihsan ciftci
I forgot mentioning the condition that we are creating a library (API)
not a web page.
The API contains a part of an IP (the gwt-safe Java library), because
of that reason it should be at least obfuscated.


On Sep 26, 6:48 pm, Jeff Larsen  wrote:
> you could use the unobfuscated version of the project to create the
> javascript, then post javascript compile you could make sure sources are not
> included and your obfuscation scheme is implemented.
>
> You will probably want to implement a -noserver implementation to really get
> this going.

-- 
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.



Yet another obfuscation question, but related with Java Source Code Obfuscation

2011-09-26 Thread ihsan ciftci
There are many topics about obfuscation, but they are about js
obfuscation.
I'm sure my question was asked before. But I didn't find.

We have a java library which is closed source. With some effort, we
modified the library as gwt-safe.
The problem here is that this library should be closed source. I have
tried the "decompile the obfuscated code" approach. But it fails.
The remaining solution is to use java source code obfuscators? Is
there anyone having same needs? Have you ever tried one of these java
source code obfuscators?
What are the results?

-- 
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.



Gwt Emulation and Maven

2011-09-21 Thread ihsan ciftci
I'm emulating some of java.awt classes in GWT.
I'm using such a scheme:
1. I'm creating a separate project for the emulation library.
2. Suppose my module is com.mylib.AWT (Think for the class
com.mylib.emul.java.awt.Color)
3. I'm setting com.mylib.emul as Source folder.
4. The emul project now can be compiled by eclipse.
5. Also my original project adds it to the build path.
6. From now, for eclipse binary classes are starting from java.awt.*
 For GWT, source files are starting from com.mylib.emul.java.awt.*

This is a very useful approach, I think.
Also I have extracted java emulated source files from gwt jars. Add
them to a project called GWTJava.
I've removed the JRE from the build path. Then added GWTJava to the
build path. By the help of this approach, you can develop your library
by only using your emulated jar methods. If you do not emulated a
method, eclipse will warn you.

You can consider this approach a bit complex. It is not so much. Maybe
it is because of my English.

Now, I want to move my projects to Maven. What do you suggest if I
want to see my compile errors of my emulation (java.awt) project? One
approach is to move the emuls to the resource folder. But this will
not show my compile errors.

What's your strategy when you use emulation in Gwt maven project?

-- 
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.



Rebind

2011-06-30 Thread ihsan ciftci
What is the purpose of com.google.user.rebind package?
Are they server-side classes? I ask this because they contain
references to BufferedImage.

-- 
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.



Canvas clear rectangle

2011-05-31 Thread ihsan ciftci
I think canvas should contain a method to clear entire canvas
regardless of current context.

The clearing approach with Integer.MIN-MAX works great on
chrome,safar,opera but not ie and ff.

/*
 * canvas.getContext2d().save();
 * canvas.getContext2d().setTransform(1,0,0,1,0,0);
 * canvas.getContext2d().clearRect(0, 0,
 * canvas.getCoordinateSpaceWidth(),
canvas.getCoordinateSpaceHeight());
 * canvas.getContext2d().restore();
 */

canvas.getContext2d().clearRect(Integer.MIN_VALUE / 2,
Integer.MIN_VALUE / 2, Integer.MAX_VALUE, Integer.MAX_VALUE);

/* canvas.getContext2d().clearRect(0,0,
canvas.getCanvasElement().getWidth(),
canvas.getCanvasElement().getHeight());
*/

-- 
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.