Noob speed question
BlitzMax Forums/BlitzMax Beginners Area/Noob speed question
| ||
Sorry if this question is horribly pointless, but does anyone have a "Time command takes" list For example the speed of ^ compared to * The reason I ask, is that when I can see two solutions to whatever I’m trying to do, I’m often making arbitrary decisions on which to use. And although it won’t make my programming any better, at least I could try to "Visualize" what would take the longest. I know it’s a cross platform language, and each platform has a plethora of different possible speeds. But you know... if anyone has such a list I would still appreciate it. Thanks H&K |
| ||
I was going to use ^ a while ago but loads of people said that old-style optimisation makes no difference now. All you can really do is test it yourself by calling the same function 1000 times and timing it. |
| ||
I know I "could" test it myself, but could I do it correctly. Surly if would be better all round if someone of your superior ability (Did that work ;) |
| ||
* is faster compared to ^2. Above that ^ is faster :-) Most other things are thanks to GCC backlink already that high speed that they can't be inefficiently (I tried to use distance approxs to make that faster for example ... result: SQR is faster than those shl shr based approaches?!) The only thing you MUST do is used everything type based -> declare everything with :Type instead of using Int references because the later is 5-20 times slower. The general rule is: Log is slowest SQR second slowest Then ^ Then / * +- math ops on double / long are slowest, its faster on float and the fastest on int (lower types than that can only become slower as your CPU is 32bit as your OS and thus are normally packaged into 32bit numerics) |
| ||
Thaks for the general rule, but a question. The reference to types and ints Are you saying use Type NInt Field Number:Int Endtype Instead of using an Int. (Sorry if this is a stupid question) |
| ||
Using, for example, image:TImage=loadimage(blah) rather than image=loadimage(blah)is a lot quicker and is what, I believe, Dreamora is referring to. Also, use Local variables rather than global where possible. |