00001 /*****************************************************************************/ 00002 /* */ 00003 /* XrdMonTimer.cc */ 00004 /* */ 00005 /* (c) 2005 by the Board of Trustees of the Leland Stanford, Jr., University */ 00006 /* All Rights Reserved */ 00007 /* Produced by Jacek Becla for Stanford University under contract */ 00008 /* DE-AC02-76SF00515 with the Department of Energy */ 00009 /*****************************************************************************/ 00010 00011 // $Id: XrdMonTimer.cc 22437 2008-03-04 14:35:16Z rdm $ 00012 00013 #include "XrdMon/XrdMonTimer.hh" 00014 #include <stdio.h> 00015 using std::cout; 00016 using std::endl; 00017 00018 void 00019 XrdMonTimer::printAll() const 00020 { 00021 cout << "Counter:\n"; 00022 printOne(_tbeg, " Beg: "); 00023 cout << " Elapsed: " << _elapsed << endl; 00024 cout << "---------" << endl; 00025 } 00026 00027 void 00028 XrdMonTimer::printOne(const timeval& t, 00029 const char* prefix) const 00030 { 00031 if ( 0 != prefix ) { 00032 cout << prefix; 00033 } 00034 00035 char buf[128]; 00036 // sprintf(buf, "%lu.%03lu", t.tv_sec, t.tv_usec/100); 00037 sprintf(buf, "%.3f", convert2Double(t)); 00038 00039 cout << buf << endl; 00040 } 00041 00042 void 00043 XrdMonTimer::printElapsed(const char* str) 00044 { 00045 cout << str << ": " << calcElapsed() << endl; 00046 } 00047