|
-
Dec 2nd, 2002, 10:43 PM
#1
Thread Starter
Frenzied Member
Bench testing a C program
Hello
I wondering is there anyway of bench testing a C program. Is there any bench testing software that can be used to test your c programs, as l want compare some programs l have written to find out which one executes fastest.
Many thanks in advance
-
Dec 2nd, 2002, 11:01 PM
#2
Monday Morning Lunatic
What compiler and OS are you using? Visual C++ has a profiler, and GCC has gprof for the same tool.
Under Unix, you can also use the 'time' command to see how long a program took to execute.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Dec 3rd, 2002, 03:48 AM
#3
Thread Starter
Frenzied Member
I am using window ME and the compilers l am using are Visual C++ 6 and borlands 4.5.
Can you give me any instructions on how to use the bench testing, in either of these compilers.
Many thanks in advance
-
Dec 3rd, 2002, 08:05 AM
#4
Monday Morning Lunatic
You can't really "bench test" a program. If you look up the profiler in the MSVC documentation, it tells you how to find which functions get called the most, and how long is spent in each function.
This allows you to intelligently choose which functions to optimise.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Dec 4th, 2002, 10:15 AM
#5
Frenzied Member
You can write a 'workbench' or instrumentation app.
Basically what you do:
Code:
Loop for each compiled .exe file
call GetTickCount - or another higher resolution timer
call CreateProcess to run the exe
call WaitForSingleObject using the process handle
call GetTickCount to find the elapsed time.
Display file name, elapsed time.
end loop
When you run this type of code make sure there isn't anything running in background.
-
Dec 4th, 2002, 10:32 AM
#6
Frenzied Member
As an addend:
Performance testing is what you normally call what you want, I believe.
Profiling, as Parksie mentioned, is a great way to find code bottlenecks.
Other kinds of testing are:
unit testing - a programmer verifying the correctness and completeness of code
QA - standardized testing for correctness, error handling, data input control & verification, data output control & verification.
This means you subject the program to all kinds of abuse, as well as planned stupidity on the part of the user. For example, Blizzard tested DiabloII in house, then released a thousand beta copies to avid 14 year olds. They found nearly a hundred problems in matter of a few days. Then they opened up Battle.net to similar testing and found a load more.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|