General > Off Topic

This two codes do the same thing...

<< < (2/3) > >>

Numsgil:
Be careful throwing text operations in to a loop you're trying to time.  It can screw up the timings by adding a lot of noise (eg: cache threashing).

Your best bet is to get a proper profiler.  It can then tell you the exact line that's slowing down code.  I managed to get Darwinbots running in VTune years and years ago.  There might be another profiler you could use.  The trick is to generate the a PDB symbols file with the EXE.  There's an option to do it somewhere.

Botsareus:

--- Quote ---Be careful throwing text operations in to a loop you're trying to time.  It can screw up the timings by adding a lot of noise (eg: cache threashing).

--- End quote ---

Angdiff is only compared agenst AngComp (both strings are 7 letters long) and Angdiff2 is only compared agenst AngComp2 (both strings are 8 letters long) and all inputs are the same (seed is same).

I am not using threading and just running multiple exes at once. I managed to get windows to load them in different order and still my time difference is about 500 clicks (the first number before "Ang...")


--- Quote ---Your best bet is to get a proper profiler.

--- End quote ---

VTune is "Try it for 30 days free" and they make you register  :wacko:

How does a profiler work anyway? Does it tell you the milliseconds every line took to execute?

I am getting the feeling you can't tell whats slowing it down and where just by looking at the code segments I submitted. Should I send you the whole code so you can look when you have time? (It is very small and reasonably easily written, although both projects are named the same in different folders)

Can not find any other free vb6 Performance Analyzer programs.

thx for help

The only thing that can make my week better is if the problem is CPU specific  :P

Botsareus:
Numsgil has found me a free profiler. It totally worked! Now I just have figure out what the hell I am looking at.

Botsareus:
After running each module 3 times (6 total) results are:


--- Code: ---angnorm(ang1)
--- End code ---
got less processor hits then
--- Code: ---angle(Cos(ang1), Sin(ang1), 0, 0)
--- End code ---

And it turns out that
--- Code: ---AngDiff(angnor1(ang1), angnor2(ang2))
--- End code ---
got less processor hits then 
--- Code: ---angle_compare(ang1, ang2)
--- End code ---

So it is indeed faster to use AngDiff in all cases.

Some things I took away from this experience:

1.) Vb6 may have 'phantom code' running. This kind of code eats up CPU time but does not produce any output to the user. You need to do a lot of smart programming to make sure your program does not contain any 'phantom code'

2.) It is sometimes better to distribute your variables instead of using one-liners. It may slow down the program a little but it will make the program allot easier to debug.

3.) Writing text to screen or the window's caption slows down your code considerably. Also, due to inherent instability of CPU usage by the OS it will most likely produce completely un-time-able results.

4.) Funny thing I discovered in vb6. If two functions do exactly the same thing but are named differently, the compiler ignores the second function and automatically makes the compile pointer to point on the first function. I guess it was a way for them to save on the programs size when it is compiled.

Numsgil:
VB6 has some crazy things going on under the hood.  It was definitely an exercise in frustration trying to get anything in it to run efficiently.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version