How to time a part of the code?

This is a discussion on How to time a part of the code? within the C Programming forums, part of the General Programming Boards category; hi Could anyone tell me how do i measure the time taken by a part of my code(in seconds) I ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    1

    How to time a part of the code?

    hi
    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
    Thanks
    Gautam

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

    Lightbulb

    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 http://www.angelfire.com/my/billholm

  3. #3
    *
    Guest
    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, 01:43 PM
  4. linked list problem
    By kzar in forum C Programming
    Replies: 8
    Last Post: 02-05-2005, 03:16 PM
  5. how do u know when 2 stop spending time on one code?
    By Commander in forum A Brief History of Cprogramming.com
    Replies: 25
    Last Post: 07-26-2003, 09:54 AM

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