Thread: display size and time

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    38

    display size and time

    How could I make a c program that loads a file, display the time it took to load the file and display the size of the program in bytes?

  2. #2
    Registered User
    Join Date
    Jan 2010
    Posts
    12
    put time fn before and after of your load file fn and calculate difference between them.so you get tiem to taken to load the file and use standard file structur to calculate the size of programm in gcc.

  3. #3
    Registered User
    Join Date
    Jul 2009
    Posts
    38
    i thought there is a function that can get time or something...gethrtime() ?????

  4. #4
    Registered User
    Join Date
    Jul 2009
    Posts
    38
    I managed to find the time, but I cant get my program to display "Your program size is ______ bytes". Any ideas?

    Thank in advance

  5. #5
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Quote Originally Posted by spikestar View Post
    I managed to find the time, but I cant get my program to display "Your program size is ______ bytes". Any ideas?
    What exactly do you mean? Do you want the size, in bytes, of the program itself, or of a particular file that it is loading?

    If you're reading a file using the standard C functions (fopen, fclose, fread, fwrite, fgets, etc.) then, when you're done, call ftell() (which tells you where you are in the file). If you're at the end (which you can be if you call fseek()), then it'll be the file's size. (with a few caveats for text files, where it is less helpful...)

    Alternatively, you can query the filesystem by calling stat().
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  6. #6
    Registered User
    Join Date
    Jul 2009
    Posts
    38
    I'm trying to find out what is the total memory allocated in bytes for the words being inserted.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adventures in labyrinth generation.
    By guesst in forum Game Programming
    Replies: 8
    Last Post: 10-12-2008, 01:30 PM
  2. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  3. Error with a vector
    By Tropicalia in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2006, 07:45 PM
  4. Trouble with DMA Segmentation Faults
    By firestorm717 in forum C Programming
    Replies: 2
    Last Post: 05-07-2006, 09:20 PM
  5. An exercise in optimization
    By Prelude in forum Contests Board
    Replies: 10
    Last Post: 04-29-2005, 03:06 PM