Thread: testing your program/functions

  1. #1
    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
    Ireland
    Posts
    8,446
    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.
    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
    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
    Ireland
    Posts
    8,446
    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.
    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
    Ireland
    Posts
    8,446
    My excellent math skills impress me everytime.

    300 x 400 = 120,000
    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
    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, 09: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, 06: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, 01:47 AM