![]() |
|
#1
|
|||
|
|||
Question on SPEEDI apologize in advance if this comes up frequently.
I am writing a program that will sum all permutations of a set of numbers to see if any of them add up to a specific target. It is strictly a number cruncher, and no fancy GUI is needed. I originally did it with visual basic (because it is what I'm most familiar with) while running windows XP. Needless to say it is slow as hell, and it takes the program over an hour to do this for a set of 20 numbers. I was hoping to use it for sets of up to 100. I'm thinking of porting the code to C and, for the first time ever, scrapping XP and converting a pentium4 laptop I have to linux, a project the computer geek in me has wanted to do for years. Before I start this task though, can someone give me advice or insight on how much extra speed this will give me? Is it worth it? It seems like using the simplest operating system on a fast machine using a fast programming language will speed things up quite a bit. Will it be enough speed to rationalize the work involved? Thanks in advance. |
|
#2
|
|||
|
|||
Re: Question on SPEEDQuote:
Typically such algorithms like calculating permutations run in a loop and therefore once the MSIL is compiled to machine code it will run in processor with maximum possible speed. The next question might be : Perhaps C is compiled to more "tight" machine code than VB which may be more "loose" and "wastefull" especially if such things as carbage collectors etc. are internally linked in the JIT compiler. Whatever the answer to that question might be I would say that if speed optimization becomes the big issue then with both VB and C there is the possibility to use assembly for maximal speed gains. Before going headfirst into assembly I would however recommend to mathematically and computationally optimize the algorithm as much as possible. Instead of "brute force" try to make it smarter. If possible. Even if VB may be as quick to run in this case as the C solution there are other reasons which may make C more appealing. VB depends on .NET with huge libraries and runtime JIT engine in order to execute. In many cases this is unnecessary clutter and hog for resources like memory and disk space and indeed is also slower when a lot of memory management and usage of OS resources is involved. Also for almost any platform there exists a C compiler which can target that platform while VB applications can be only created for those platforms having .NET runtime (or some compatible like mono). Finally the question if it is worth your while it really ultimately depends on you. If the goal was just simply solve one problem once then, well you did it already. If you want to optimize a function which you created and you think you probably won't be needing much low level programming in the future then you can opt for either mathematical improvements of your algorithm or you could also study languages like Python or Java. Which are both o-o but without the frustration factors inbuilt into VB syntax. However if you want to learn the ability to write low level code and maybe just have fun in low level understanding then it may definitively be worthwhile to learn C. And if developing for embedded systems C is still a commonly enough used language despite that in many visions it has been predicted that C language will face extinction as c++ or some other o-o language will completely replace it. Last edited by seprich : 10-Mar-2008 at 17:36.
|
|
#3
|
|||
|
|||
Re: Question on SPEEDHey, thanks for the well thought response. That is interesting, I guess I'm dating myself. I always thought VB was a relatively slow language. I thought that's why most games, etc, are programmed in C or it's big brother. But then, I haven't messed around with programming much since the 90's. Maybe VB has caught up.
Also, I thought All programming languages were translated into machine code at runtime. Isn't that what compiling a program is, essentially? I don't know about assembly. LOL. I already know C and VB. I don't know if I want to teach myself a new language, especially that one. |
|
#4
|
||||
|
||||
Re: Question on SPEEDQuote:
Well, this is more complicated than a simple no or yes. VB can still be ineffective to use for games. Programming is not just about your code it is also about resources you use. VB is designed "lego" approach in mind where the typical financial analyst drags-and-drops his applications together from ready-on-the-shelve graphical widget components. Such components can hardly be very efficient for games or similarly performance critical purpose. Programming something that goes against the design ideology of VB is maybe possible but lots of trouble. Quote:
Quote:
Quote:
Are you at liberty of showing the permutative algorithm you are using? Preferrably written in pseudo code rather than VB. |
|
#5
|
|||
|
|||
Re: Question on SPEEDYou can embedded assembly inside C code to improve speed and processing time.
|
Recent GIDBlog
US Elections and the ?Voter?s Responsibility? by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Basic ways to speed up your website | Rifat | Web Design Forum | 11 | 28-Feb-2007 02:15 |
| Question about locking surfaces to directly access pixels, SDL. | george89 | C++ Forum | 0 | 18-Jun-2006 22:16 |
| Check up your speed | JuliusV | Computer Hardware Forum | 0 | 01-Mar-2006 04:29 |
| OT: nth power square root math question | earachefl | C++ Forum | 1 | 18-Feb-2006 08:45 |
| question of practice | magiccreative | C++ Forum | 1 | 06-Feb-2004 08:17 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The