0
|
1 |
/*
|
|
2 |
* $Id: counter.c,v 1.1.1.1 2008-04-28 17:32:53 mbroeker Exp $
|
|
3 |
* $Source: /development/c/demos/counter.c,v $
|
|
4 |
*/
|
|
5 |
|
|
6 |
#include <stdio.h>
|
|
7 |
#include <stdlib.h>
|
|
8 |
#include <time.h>
|
|
9 |
|
|
10 |
int main (int argc, char **argv)
|
|
11 |
{
|
|
12 |
time_t t;
|
|
13 |
struct tm *time_str;
|
|
14 |
int start, end;
|
|
15 |
|
|
16 |
if (argc != 2) {
|
|
17 |
printf ("Usage: %s \"<command>\"\n", argv[0]);
|
|
18 |
return EXIT_FAILURE;
|
|
19 |
}
|
|
20 |
|
|
21 |
time (&t);
|
|
22 |
time_str = gmtime (&t);
|
|
23 |
|
|
24 |
start = time_str->tm_hour * 60 * 60 + time_str->tm_min * 60 + time_str->tm_sec;
|
|
25 |
|
|
26 |
system (argv[1]);
|
|
27 |
|
|
28 |
time (&t);
|
|
29 |
time_str = gmtime (&t);
|
|
30 |
|
|
31 |
end = time_str->tm_hour * 60 * 60 + time_str->tm_min * 60 + time_str->tm_sec;
|
|
32 |
|
|
33 |
printf ("Command Execution Time: %8ds\n", end - start);
|
|
34 |
|
|
35 |
return EXIT_SUCCESS;
|
|
36 |
}
|