testing your program/functions

This is a discussion on testing your program/functions within the C++ Programming forums, part of the General Programming Boards category; How do you test preformance of your program/functions? I just use GetTickCount().. Are there better ways to do that? When ...

  1. #1
    l2u
    l2u is offline
    Registered User
    Join Date
    May 2006
    Posts
    630

    testing your program/functions

    How do you test preformance of your program/functions?

    I just use GetTickCount().. Are there better ways to do that?
    When to know your program/function works good?

    I've just done function for searching variables in text (using boost::spirit), and if I call it with about 400 variables 400 times (about 300 chars long text) it takes about 9500 miliseconds (which sounds a lot)..

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,487
    The best method to learn about your functions performance is to learn about the Big-O notation. It will help you determine if some algorithm can be faster by changing the way it was coded.

    I'd wager though that if parsing 300 characters takes you 9 and an half seconds, something is seriously wrong.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    If you're under Linux, the time utilitity is invaluable.
    Code:
    time a.exe
    Callou collei we'll code the way
    Of prime numbers and pings!

  4. #4
    l2u
    l2u is offline
    Registered User
    Join Date
    May 2006
    Posts
    630
    Well... Its complicated process, each text needs to be preparsed before it can be completed.. And also it tooks that time if program does it 400 times.. Does still sound bad?

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,487
    I have no idea what "complicated process" means on that case. Still 400 times 300 is 12,000 chars. You are taking 9500 milisesonds to process 12,000 chars. That's probably slow... but again it all depends on exactly what you are doing?

    What you must probably do is never being happy with the results. Look at your algorithm and see where you can improve it... or share it with us and many here will probably see places that could be make faster.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #6
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,487
    My excellent math skills impress me everytime.

    300 x 400 = 120,000
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  7. #7
    l2u
    l2u is offline
    Registered User
    Join Date
    May 2006
    Posts
    630
    Thats what we all do (hehe)..

    Well.. Actually I can have a text file with some variables/macros that can be defined in program. You can also use some static macro functions like $RANDOM_NUMBER, etc..

    Now I have first to parse user's macros in case they contain a macro (if they are set to be static), then save static macros and process the input text using boost::spirit with them..

    (I have to do the same action 2 or more times)..

    Simple example:
    I define a macro:
    SOME_MACRO = "$RANDOM_NUM(400,1000) is my favorite $DYN_MACRO" - static
    DYN_MACRO = "num 1", "num 2", "num 3", etc.

    and input text is:
    Here is some text $SOME_MACRO and non-static macro $DYN_MACRO $DATE

    will output:
    Here is some text 601 is my favorite num 2 17. Dec

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL: Depth Testing, Matrixes, ect.?
    By Zeusbwr in forum Game Programming
    Replies: 8
    Last Post: 12-08-2004, 08:37 AM
  2. C++ bit testing
    By Vicious in forum C++ Programming
    Replies: 3
    Last Post: 09-19-2004, 11:44 AM
  3. Blending and Depth Testing
    By Thunderco in forum Game Programming
    Replies: 2
    Last Post: 03-08-2004, 05:37 PM
  4. about testing a program
    By Abdi in forum C Programming
    Replies: 1
    Last Post: 06-09-2002, 12:51 AM
  5. program for Radiation Testing
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 02-07-2002, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21