Thread: How to time a part of the code?

  1. #1
    Registered User
    Join Date
    May 2002

    How to time a part of the code?

    Could anyone tell me how do i measure the time taken by a part of my code(in seconds)
    I want to check the amount of time taken to call a function 1000 times

  2. #2
    Registered User billholm's Avatar
    Join Date
    Apr 2002


    If you have a C language book, you may want to look into the "time.h" header. There is a function there called clock() which is used to time C code and other processes.

    I have read a sample C code-timing in my book but I wasn't able to memorize the actual implementation.
    All men are created equal. But some are more equal than others.

    Visit me at

  3. #3
    Use a 'profiler'. Your compiler might support this option. Better compilers do.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. segmentation fault... first time with unix...
    By theMethod in forum C Programming
    Replies: 16
    Last Post: 09-30-2008, 02:01 AM
  2. Pthreads performance
    By C_ntua in forum C Programming
    Replies: 42
    Last Post: 06-17-2008, 11:29 AM
  3. Need help with time
    By Gong in forum C++ Programming
    Replies: 7
    Last Post: 01-11-2007, 02:43 PM
  4. linked list problem
    By kzar in forum C Programming
    Replies: 8
    Last Post: 02-05-2005, 04:16 PM
  5. how do u know when 2 stop spending time on one code?
    By Commander in forum A Brief History of
    Replies: 25
    Last Post: 07-26-2003, 09:54 AM