Thread: how to calculate system time

  1. #1
    Registered User
    Join Date
    Oct 2010

    how to calculate system time

    PHP Code:
        double wall_time;
    struct rusage ru_startru_end;
    getrusage(RUSAGE_SELF, &ru_start);
    mergesort(args[i], sizeof(original)/sizeof(*original), sizeof(*original),my_cmp); /*my program that need to be measued*/
    getrusage(RUSAGE_SELF, &ru_end);
    sys_time ru_end.ru_stime.tv_sec ru_start.ru_stime.tv_sec;
    sys_time += (ru_end.ru_stime.tv_usec ru_start.ru_stime.tv_usec)/1000000.0;
    im tying to the system time my program uses, but all i get is 0, what should i do?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Does it print 0, even when it's obviously taking a lot longer?

    How big is the array you're sorting?

    Returns success / fail (you don't check)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Time for a new system....again
    By VirtualAce in forum Tech Board
    Replies: 6
    Last Post: 06-18-2007, 06:48 AM
  2. Sending an email in C program
    By Moony in forum C Programming
    Replies: 28
    Last Post: 10-19-2006, 10:42 AM
  3. Read and set\change system time
    By Hexxx in forum C++ Programming
    Replies: 9
    Last Post: 01-02-2006, 07:11 AM
  4. The Timing is incorret
    By Drew in forum C++ Programming
    Replies: 5
    Last Post: 08-28-2003, 04:57 PM
  5. Passing system time to a function
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 02-14-2002, 01:56 PM