I need function that can get time for less than a second

This is a discussion on I need function that can get time for less than a second within the C Programming forums, part of the General Programming Boards category; I have to make a runtime analysis of quicksort and selection sort. For this, i need to determine the average ...

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

    Question I need function that can get time for less than a second

    I have to make a runtime analysis of quicksort and selection sort. For this, i need to determine the average runtime of sorting 100 integers. I tried using clock() and time() but i think these return time in seconds. The program however takes less than a second so the value returned is 0. what else can I use?

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    If you're allowed to include windows.h, you can use GetTickCount(), which returns the number of milliseconds since windows started.
    Run it two times and calculate the differemce.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  2. Sending an email in C program
    By Moony in forum C Programming
    Replies: 28
    Last Post: 10-19-2006, 11:42 AM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Replies: 5
    Last Post: 02-08-2003, 07:42 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 02:27 PM

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