Home World Forum
Stars! AutoHost web forums

Jump to Stars! AutoHost


 
 
Home » Stars! Clones, Extensions, Modding » FreeStars » Efficient Algorithm for Scanning planets/fleets/etc.
Re: Efficient Algorithm for Scanning planets/fleets/etc. Fri, 09 February 2007 16:49 Go to previous messageGo to previous message
sirgwain is currently offline sirgwain

 
Senior Chief Petty Officer

Messages: 86
Registered: March 2004
Location: Tucson
Kotk wrote on Fri, 09 February 2007 15:42

C++ compilers tend to optimize the code like you posted entirely out so i somewhat modified it to give any usage to the variables there... and also to measure the time directly in code. Somehow i get here different results than you. Maybe i just know C# not well enough and do something wrong with it. Other possibilities are that you run not "C++" but "managed C++" or that you run "Debug" version of C++. On that case your computer seems about 4 times better than mine. Very Happy



Well I'm confused. I must have run into some compiler optimization thing. If I take out the:

         Console.WriteLine("{0};{1};{2};{3}", span, d1, d2, d3);

statement it runs lickety split, but if I do anything with those d1,d2,d3 values (like pass them to a function), it takes 2400 ms. How very strange. I've never messed around with compilers so I don't know much about how they optimize.

Quote:


C++ runs bit less than 4 times quicker but not much.
Both examples were compiled with very same Visual Studio 2005 Professional.


Apparently it does!

Off subject of the C# computation speed issue, I figured out what a major flaw in my algorithm was. I was computing the scan range of every component for every check (because it changes based on the race's electronics values for JOATs). If I cache that out it takes .02 seconds to calculate the scanners using a more efficient mark-as-scanned algorithm.

Anyway, thanks for the code postings. They were educational. Smile

Report message to a moderator

 
Read Message icon5.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: New stars! server clone proposal
Next Topic: 3D tool
Goto Forum:
  


Current Time: Mon Apr 29 04:38:05 EDT 2024