source: tags/ms_r16q2/PROBE_SET/ps_tools.cxx

Last change on this file was 6385, checked in by westram, 14 years ago
  • removed trailing whitespace
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.0 KB
Line 
1//  ==================================================================== //
2//                                                                       //
3//    File      : ps_tools.cxx                                           //
4//    Purpose   : remove duplicated code                                 //
5//                                                                       //
6//                                                                       //
7//  Coded by Ralf Westram (coder@reallysoft.de) in October 2004          //
8//  Copyright Department of Microbiology (Technical University Munich)   //
9//                                                                       //
10//  Visit our web site at: http://www.arb-home.de/                       //
11//                                                                       //
12//  ==================================================================== //
13
14#include "ps_tools.hxx"
15
16#include <cstdio>
17#include <cstdlib>
18#include <ctime>
19#include <sys/times.h>
20
21void PS_print_time_diff(const struct tms *_since, const char *_before, const char *_after) {
22    struct tms now;
23    times(&now);
24    if (_before) printf("%s", _before);
25    printf("time used : user (");
26
27    unsigned int minutes  = (now.tms_utime-_since->tms_utime)/CLOCKS_PER_SEC / 60;
28    unsigned int hours    = minutes / 60;
29    minutes              -= hours * 60;
30    if (hours > 0) printf("%uh ", hours);
31    if (minutes > 0) printf("%um ", minutes);
32    printf("%.3fs) system (", (float)(now.tms_utime-_since->tms_utime)/CLOCKS_PER_SEC-(hours*3600)-(minutes*60));
33    minutes               = (now.tms_stime-_since->tms_stime)/CLOCKS_PER_SEC / 60;
34    hours                 = minutes / 60;
35    minutes              -= hours * 60;
36    if (hours > 0) printf("%uh ", hours);
37    if (minutes > 0) printf("%um ", minutes);
38    printf("%.3fs)",   (float)(now.tms_stime-_since->tms_stime)/CLOCKS_PER_SEC-(hours*3600)-(minutes*60));
39
40    if (_after) {
41        printf("%s", _after);
42    }
43    else {
44        printf("\n");
45    }
46    fflush(stdout);
47}
48
49
50
Note: See TracBrowser for help on using the repository browser.