Changeset 118:38e16c594a4f in lemon-0.x for src
- Timestamp:
- 02/23/04 08:05:27 (21 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@153
- Location:
- src/work
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/alpar/f_ed_ka_demo.cc
r117 r118 24 24 Graph G; 25 25 NodeIt s, t; 26 Timer ts; 26 27 Graph::DynEdgeMap<int> cap(G); 27 28 readDimacsMaxFlow(std::cin, G, s, t, cap); 28 29 30 std::cout << "loading time: " << ts << std::endl; 31 ts.reset(); 29 32 std::cout << "edmonds karp demo..." << std::endl; 30 33 Graph::DynEdgeMap<int> flow(G); //0 flow 31 34 32 35 int ret; 33 double pre_time=currTime(); 34 Timer ts; 36 // double pre_time=currTime(); 35 37 36 38 ret = maxFlow(G,flow,cap,s,t); 37 double post_time=currTime();38 std::cout << " ellapsed time:" << ts << std::endl;39 // double post_time=currTime(); 40 std::cout << "running time: " << ts << std::endl; 39 41 40 42 //std::cout << "maximum flow: "<< std::endl; … … 43 45 //} 44 46 //std::cout<<std::endl; 45 std::cout <<"elapsed time: " << post_time-pre_time << " sec"<< std::endl;47 // std::cout<<"elapsed time: " << post_time-pre_time << " sec"<< std::endl; 46 48 std::cout << "flow value: "<< ret << std::endl; 47 49 -
src/work/marci/time_measure.h
r117 r118 18 18 { 19 19 tms ts; 20 double real_time; 21 20 22 public: 21 23 22 24 tms &getTms() {return ts;} 23 25 const tms &getTms() const {return ts;} 24 25 void stamp() {times(&ts);} 26 TimeStamp() { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0;} 26 double getRealTime() const {return real_time;} 27 void stamp() 28 { 29 timeval tv; 30 times(&ts); 31 gettimeofday(&tv, 0);real_time=tv.tv_sec+double(tv.tv_usec)/1e6; 32 } 33 34 TimeStamp() 35 { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0; real_time=0;} 36 27 37 TimeStamp(void *) { stamp();} 28 38 … … 33 43 ts.tms_cutime+=b.ts.tms_cutime; 34 44 ts.tms_cstime+=b.ts.tms_cstime; 45 real_time+=b.real_time; 35 46 return *this; 36 47 } … … 46 57 ts.tms_cutime-=b.ts.tms_cutime; 47 58 ts.tms_cstime-=b.ts.tms_cstime; 59 real_time-=b.real_time; 48 60 return *this; 49 61 } … … 62 74 friend std::ostream& operator<<(std::ostream& os,const TimeStamp &t); 63 75 76 double getUserTime() const 77 { 78 long cls = sysconf(_SC_CLK_TCK); 79 return double(ts.tms_utime)/cls; 80 } 81 double getSystemTime() const 82 { 83 long cls = sysconf(_SC_CLK_TCK); 84 return double(ts.tms_stime)/cls; 85 } 86 double getCUserTime() const 87 { 88 long cls = sysconf(_SC_CLK_TCK); 89 return double(ts.tms_cutime)/cls; 90 } 91 double getCSystemTime() const 92 { 93 long cls = sysconf(_SC_CLK_TCK); 94 return double(ts.tms_cstime)/cls; 95 } 64 96 }; 65 97 … … 83 115 { 84 116 long cls = sysconf(_SC_CLK_TCK); 85 os << " [u: " << double(t.getTms().tms_utime)/cls <<117 os << "u: " << double(t.getTms().tms_utime)/cls << 86 118 "s, s: " << double(t.getTms().tms_stime)/cls << 87 119 "s, cu: " << double(t.getTms().tms_cutime)/cls << 88 "s, cs: " << double(t.getTms().tms_cstime)/cls << "s ]"; 120 "s, cs: " << double(t.getTms().tms_cstime)/cls << 121 "s, real: " << t.getRealTime() << "s"; 89 122 return os; 90 123 }
Note: See TracChangeset
for help on using the changeset viewer.