1.1 --- a/src/work/alpar/f_ed_ka_demo.cc Sun Feb 22 15:17:58 2004 +0000
1.2 +++ b/src/work/alpar/f_ed_ka_demo.cc Mon Feb 23 07:05:27 2004 +0000
1.3 @@ -23,26 +23,28 @@
1.4
1.5 Graph G;
1.6 NodeIt s, t;
1.7 + Timer ts;
1.8 Graph::DynEdgeMap<int> cap(G);
1.9 readDimacsMaxFlow(std::cin, G, s, t, cap);
1.10
1.11 + std::cout << "loading time: " << ts << std::endl;
1.12 + ts.reset();
1.13 std::cout << "edmonds karp demo..." << std::endl;
1.14 Graph::DynEdgeMap<int> flow(G); //0 flow
1.15
1.16 int ret;
1.17 - double pre_time=currTime();
1.18 - Timer ts;
1.19 + // double pre_time=currTime();
1.20
1.21 ret = maxFlow(G,flow,cap,s,t);
1.22 - double post_time=currTime();
1.23 - std::cout << "ellapsed time:" << ts << std::endl;
1.24 + // double post_time=currTime();
1.25 + std::cout << "running time: " << ts << std::endl;
1.26
1.27 //std::cout << "maximum flow: "<< std::endl;
1.28 //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
1.29 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
1.30 //}
1.31 //std::cout<<std::endl;
1.32 - std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl;
1.33 + // std::cout<<"elapsed time: " << post_time-pre_time << " sec"<< std::endl;
1.34 std::cout << "flow value: "<< ret << std::endl;
1.35
1.36 return 0;
2.1 --- a/src/work/marci/time_measure.h Sun Feb 22 15:17:58 2004 +0000
2.2 +++ b/src/work/marci/time_measure.h Mon Feb 23 07:05:27 2004 +0000
2.3 @@ -17,13 +17,23 @@
2.4 class TimeStamp
2.5 {
2.6 tms ts;
2.7 + double real_time;
2.8 +
2.9 public:
2.10
2.11 tms &getTms() {return ts;}
2.12 const tms &getTms() const {return ts;}
2.13 -
2.14 - void stamp() {times(&ts);}
2.15 - TimeStamp() { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0;}
2.16 + double getRealTime() const {return real_time;}
2.17 + void stamp()
2.18 + {
2.19 + timeval tv;
2.20 + times(&ts);
2.21 + gettimeofday(&tv, 0);real_time=tv.tv_sec+double(tv.tv_usec)/1e6;
2.22 + }
2.23 +
2.24 + TimeStamp()
2.25 + { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0; real_time=0;}
2.26 +
2.27 TimeStamp(void *) { stamp();}
2.28
2.29 TimeStamp &operator+=(const TimeStamp &b)
2.30 @@ -32,6 +42,7 @@
2.31 ts.tms_stime+=b.ts.tms_stime;
2.32 ts.tms_cutime+=b.ts.tms_cutime;
2.33 ts.tms_cstime+=b.ts.tms_cstime;
2.34 + real_time+=b.real_time;
2.35 return *this;
2.36 }
2.37 TimeStamp operator+(const TimeStamp &b) const
2.38 @@ -45,6 +56,7 @@
2.39 ts.tms_stime-=b.ts.tms_stime;
2.40 ts.tms_cutime-=b.ts.tms_cutime;
2.41 ts.tms_cstime-=b.ts.tms_cstime;
2.42 + real_time-=b.real_time;
2.43 return *this;
2.44 }
2.45 TimeStamp operator-(const TimeStamp &b) const
2.46 @@ -61,6 +73,26 @@
2.47
2.48 friend std::ostream& operator<<(std::ostream& os,const TimeStamp &t);
2.49
2.50 + double getUserTime() const
2.51 + {
2.52 + long cls = sysconf(_SC_CLK_TCK);
2.53 + return double(ts.tms_utime)/cls;
2.54 + }
2.55 + double getSystemTime() const
2.56 + {
2.57 + long cls = sysconf(_SC_CLK_TCK);
2.58 + return double(ts.tms_stime)/cls;
2.59 + }
2.60 + double getCUserTime() const
2.61 + {
2.62 + long cls = sysconf(_SC_CLK_TCK);
2.63 + return double(ts.tms_cutime)/cls;
2.64 + }
2.65 + double getCSystemTime() const
2.66 + {
2.67 + long cls = sysconf(_SC_CLK_TCK);
2.68 + return double(ts.tms_cstime)/cls;
2.69 + }
2.70 };
2.71
2.72 class Timer
2.73 @@ -82,10 +114,11 @@
2.74 inline std::ostream& operator<<(std::ostream& os,const TimeStamp &t)
2.75 {
2.76 long cls = sysconf(_SC_CLK_TCK);
2.77 - os << "[ u: " << double(t.getTms().tms_utime)/cls <<
2.78 + os << "u: " << double(t.getTms().tms_utime)/cls <<
2.79 "s, s: " << double(t.getTms().tms_stime)/cls <<
2.80 "s, cu: " << double(t.getTms().tms_cutime)/cls <<
2.81 - "s, cs: " << double(t.getTms().tms_cstime)/cls << "s ]";
2.82 + "s, cs: " << double(t.getTms().tms_cstime)/cls <<
2.83 + "s, real: " << t.getRealTime() << "s";
2.84 return os;
2.85 }
2.86