Is the coffee cup getting colder? (Part 2)

Filed under: , , , , by: PritinTheGreat

So, in this series of tests, .NET seems to be the clear winner so far. If this makes you really happy, you may be in for a disappointment today. I unveil now, the results of two more tests that we performed recently.

TEST 3
DRAWING A HELL LOT OF STUFF
--------------------------------------------
In this test, we had both our competitors draw, as the title says, a hell lot of stuff onto a single window. Apparently one of them had a lot of fun doing the same, while the other got extremely stressed out. The task was to draw 1000 rectangles and 1000 circles. Now just in case you're thinking whether life would've been simpler had we drawn 2 rectangles and 2 circles, you're wrong. The time needed for either platform to draw any single shape is a lot less than 1 millisecond. To measure enough time so that comparing is possible, we've overloaded them with a heavily time consuming task.

Let us, as usual, have a quick glance at the code before moving over to the results.

Java program (extract)

(not available at the moment)

C#.NET program (extract)

static void F1_Paint(object sender, PaintEventArgs e)
{
g = e.Graphics;
Rectangle R = new Rectangle(10,10,100,100);
g.DrawRectangle(Pens.Black, R);
g.DrawEllipse(Pens.Black, R);
g.DrawRectangle(Pens.Black, R);
g.DrawEllipse(Pens.Black, R);
...
...
}

The rather stunning results, are as follows... (lesser is better)



Java SE 6 : 63 ms
.NET 3.5 : 227 ms

So as you can see, the time needed by .NET 3.5 to draw the same set of figures (2000 in total) is a staggering 300% more than that required by the JVM! Java uses OpenGL for all it's drawings, while .NET uses GDI+. This significant difference can indeed be credited to the difference between OpenGL and GDI+. Most people prefer OpenGL to GDI, primarily because it is known to be faster (especially in game development) and performing actions such as rotating and scaling of drawings is simpler. However, GDI too has it's advantages; the most notable of them being that it is guaranteed 100% to run on any default windows installation, because GL is dependent on, and requires, that the latest graphics drivers be installed.

TEST 4
ADDING LOTS OF CONTROLS TO A WINDOW
--------------------------------------------
-----------
In this test, we tried adding 1000 controls to a window programatically; that is, we're not using Visual Studio or NetBeans to "drag-and-drop" the controls ; we're adding them at runtime. Considering the fact that the .NET framework was created primarily for Windows, the results of this test may be disturbing to some.

The programs in both languages are very similar, in that they both just add() controls to the window / applet. (I'll make the programs available anyway, later)

So we're heading off to the results directly...




In this test, Java is marginally ahead of .NET .
So apparently, as far as graphics and visual stuff are involved, Java is a few steps ahead of .NET. This isn't enough to say "Graphics are better in Java than .NET" , because at the moment, Microsoft endeavours such as WPF are far far ahead of Java when it comes to rich and intutive user interfaces.

So those were the two test results for today, more tests are lined up, so don't loose hope! For now, it's a tie between .NET and Java, and the coffee cup may not be getting cold after all.

1 comments:

On April 9, 2009 at 12:17 PM , Piyush said...

Way to go...