For a particular program of c code, I'd like to measure:
execution time (most likely complete program execution time)
memory usage
CPU load
how can i get all above information in C ?
For a particular program of c code, I'd like to measure:
execution time (most likely complete program execution time)
memory usage
CPU load
how can i get all above information in C ?
You can write a simple code to measure the execution time of a particular code block using the standard C library for time/date manipulation (time.h): http://en.wikipedia.org/wiki/C_date_and_time_functions
Memory usage is practically impossible to measure accurately for a non-trivial program. Does your program use shared libraries? Well then, do you count the memory used by shared libraries as belonging exclusively to your program? What about child processes that your program fork()ed? Do you count them separately or together with the main process? All of these questions can be answered, but that means that what you measure depends on your specific choices.
In C, what you can do is to wrap around malloc() and free() use your wrapper to keep track of your memory allocations.
For CPU load, you need to interface with the OS. You cannot get that information from C.