Click here to Skip to main content
15,886,873 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Why .NET CLR so slow compared to JVM or Dart or V8 ? Call for help Pin
Pete O'Hanlon1-Sep-14 9:40
mvePete O'Hanlon1-Sep-14 9:40 
AnswerRe: Why .NET CLR so slow compared to JVM or Dart or V8 ? Call for help Pin
Pete O'Hanlon1-Sep-14 7:38
mvePete O'Hanlon1-Sep-14 7:38 
GeneralRe: Why .NET CLR so slow compared to JVM or Dart or V8 ? Call for help Pin
Antonino Porcino1-Sep-14 21:47
Antonino Porcino1-Sep-14 21:47 
GeneralRe: Why .NET CLR so slow compared to JVM or Dart or V8 ? Call for help Pin
Pete O'Hanlon1-Sep-14 22:03
mvePete O'Hanlon1-Sep-14 22:03 
GeneralRe: Why .NET CLR so slow compared to JVM or Dart or V8 ? Call for help Pin
Antonino Porcino2-Sep-14 0:19
Antonino Porcino2-Sep-14 0:19 
GeneralRe: Why .NET CLR so slow compared to JVM or Dart or V8 ? Call for help Pin
Pete O'Hanlon2-Sep-14 0:36
mvePete O'Hanlon2-Sep-14 0:36 
GeneralRe: Why .NET CLR so slow compared to JVM or Dart or V8 ? Call for help Pin
Antonino Porcino2-Sep-14 1:30
Antonino Porcino2-Sep-14 1:30 
AnswerRe: Why .NET CLR so slow compared to JVM or Dart or V8 ? Call for help Pin
Ben M Watson4-Sep-14 5:43
Ben M Watson4-Sep-14 5:43 
I get about 10s on my machine with the .NET version -- have not tested the others, but 40 seconds seems way too long. I've actually written a ray tracer in C# before, and it could render images very quickly (it included advanced features like transparency as well). There is definitely something wrong.

I see a bunch of odd things that could be making this much less efficient than it could be:

* Color should probably be a struct instead of class (but measure and find out)
* The stopwatch class uses DateTime, which is really, really bad for measuring small amounts of time. It's slow and inprecise for this usage. Use System.Diagnostics.Stopwatch instead.
* Outputting to the console is slow -- even at once per row, it might be enough to skew the timing.
** Related: calling String.Format is expensive. Might not matter for this application.
* Profiling this shows that the most expensive method is Sphere.Intersect. I suspect it's just the math and the fact that you're calling it so much.
* You can optimize the Sphere.Intersect method a bit more. You can store a precalculated radiusSquared value. You can put off the call to Math.Sqrt by squaring both sides of the equation and still checking against 0. You only need to cal Sqrt when distance > 0.
* a bunch of foreach statements. In many cases, these can be transformed into for-loops by the JIT, but not always. Enumerator.MoveNext is showing up in the profile, so consider changing these.

Lastly, what is the CPU usage like during each version of the program? Could other versions be automatically parallelizing some of the loops? Seems like a long shot, but I don't know.

And yeah, I know it's an obvious plug, but I've written an entire book on .NET performance. See my signature. It can teach you a bunch of stuff like the above, but more importantly, how to measure and diagnose these problems.

In the end, .NET is really just x86/x64 code running on a processor just like anything else. To see such a wide disparity in running times, especially compared to javascript is a red flag that something major is wrong.


modified 4-Sep-14 12:23pm.

GeneralRe: Why .NET CLR so slow compared to JVM or Dart or V8 ? Call for help Pin
Antonino Porcino4-Sep-14 7:10
Antonino Porcino4-Sep-14 7:10 
QuestionLocalization based on namespace Pin
Moreno Airoldi27-Aug-14 23:18
Moreno Airoldi27-Aug-14 23:18 
AnswerRe: Localization based on namespace Pin
Bernhard Hiller28-Aug-14 21:10
Bernhard Hiller28-Aug-14 21:10 
GeneralRe: Localization based on namespace Pin
Moreno Airoldi1-Sep-14 2:35
Moreno Airoldi1-Sep-14 2:35 
AnswerRe: Localization based on namespace Pin
Eddy Vluggen29-Aug-14 7:56
professionalEddy Vluggen29-Aug-14 7:56 
GeneralRe: Localization based on namespace Pin
Moreno Airoldi1-Sep-14 2:51
Moreno Airoldi1-Sep-14 2:51 
AnswerRe: Localization based on namespace Pin
jschell29-Aug-14 8:00
jschell29-Aug-14 8:00 
GeneralRe: Localization based on namespace Pin
Eddy Vluggen29-Aug-14 11:55
professionalEddy Vluggen29-Aug-14 11:55 
GeneralRe: Localization based on namespace Pin
Moreno Airoldi1-Sep-14 2:55
Moreno Airoldi1-Sep-14 2:55 
QuestionHosting a small dot net app and SQL Server Express db Pin
MarkB12327-Aug-14 21:41
MarkB12327-Aug-14 21:41 
Question32 Bit app calling a 64 Bit .Net object - possible? Pin
Ed The C26-Aug-14 6:35
Ed The C26-Aug-14 6:35 
AnswerRe: 32 Bit app calling a 64 Bit .Net object - possible? Pin
Paulo Zemek26-Aug-14 6:48
mvaPaulo Zemek26-Aug-14 6:48 
QuestionNeed Salted MD5 technique for login Pin
demoninside921-Aug-14 19:22
demoninside921-Aug-14 19:22 
AnswerRe: Need Salted MD5 technique for login Pin
Bernhard Hiller21-Aug-14 21:21
Bernhard Hiller21-Aug-14 21:21 
AnswerRe: Need Salted MD5 technique for login Pin
Richard Deeming22-Aug-14 2:10
mveRichard Deeming22-Aug-14 2:10 
QuestionDropTiles ASP.NET MVC Pin
Bain McKay21-Aug-14 9:17
Bain McKay21-Aug-14 9:17 
AnswerRe: DropTiles ASP.NET MVC Pin
Eddy Vluggen22-Aug-14 6:57
professionalEddy Vluggen22-Aug-14 6:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.