author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Fri, 27 Dec 2013 16:00:09 +0100 | |
changeset 167 | 7c6b221900bf |
parent 131 | b5ad49852adc |
permissions | -rw-r--r-- |
9
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
1 |
/** |
77 | 2 |
* counter.c |
9
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
3 |
* Copyright (C) 2008 Markus Broeker |
0 | 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; |
|
27
81a574d60c15
typo in min2time format string
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
9
diff
changeset
|
13 |
|
0 | 14 |
struct tm *time_str; |
27
81a574d60c15
typo in min2time format string
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
9
diff
changeset
|
15 |
|
0 | 16 |
int start, end; |
17 |
||
18 |
if (argc != 2) { |
|
19 |
printf ("Usage: %s \"<command>\"\n", argv[0]); |
|
20 |
return EXIT_FAILURE; |
|
21 |
} |
|
22 |
||
23 |
time (&t); |
|
24 |
time_str = gmtime (&t); |
|
25 |
||
26 |
start = time_str->tm_hour * 60 * 60 + time_str->tm_min * 60 + time_str->tm_sec; |
|
27 |
||
131
b5ad49852adc
check for the return values
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
77
diff
changeset
|
28 |
if (system (argv[1]) == -1) { |
b5ad49852adc
check for the return values
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
77
diff
changeset
|
29 |
return EXIT_FAILURE; |
b5ad49852adc
check for the return values
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
77
diff
changeset
|
30 |
} |
0 | 31 |
|
32 |
time (&t); |
|
33 |
time_str = gmtime (&t); |
|
34 |
||
35 |
end = time_str->tm_hour * 60 * 60 + time_str->tm_min * 60 + time_str->tm_sec; |
|
36 |
||
37 |
printf ("Command Execution Time: %8ds\n", end - start); |
|
38 |
||
39 |
return EXIT_SUCCESS; |
|
40 |
} |