Results 1 to 6 of 6

Thread: Bench testing a C program

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    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
    steve

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331
    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
    steve

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  5. #5
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    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.

  6. #6
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    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
  •  



Click Here to Expand Forum to Full Width