Changeset 323:58bc28afea63 in lemon-0.x for src/work
- Timestamp:
- 04/14/04 15:57:48 (21 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@441
- Location:
- src/work/marci
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/marci/graph_wrapper.h
r318 r323 463 463 } 464 464 465 465 // template<typename I> I& next(I &i) const { 466 // graph->next(i); 467 // // while (graph->valid(i) && !filter_map-get(i)) { graph->next(i); } 468 // while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); } 469 // return i; 470 // } 471 466 472 Node aNode(const OutEdgeIt& e) const { return Node(graph->aNode(e.e)); } 467 473 Node aNode(const InEdgeIt& e) const { return Node(graph->aNode(e.e)); } 468 474 Node bNode(const OutEdgeIt& e) const { return Node(graph->bNode(e.e)); } 469 475 Node bNode(const InEdgeIt& e) const { return Node(graph->bNode(e.e)); } 470 471 // template<typename I> I& next(I &i) const { 472 // graph->next(i); 473 // // while (graph->valid(i) && !filter_map-get(i)) { graph->next(i); } 474 // while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); } 475 // return i; 476 // } 477 476 477 void hide(const Node& n) const { node_filter_map->set(n, false); } 478 void hide(const Edge& e) const { edge_filter_map->set(e, false); } 479 480 void unHide(const Node& n) const { node_filter_map->set(n, true); } 481 void unHide(const Edge& e) const { edge_filter_map->set(e, true); } 482 483 bool hidden(const Node& n) const { return (*node_filter_map)[n]; } 484 bool hidden(const Edge& e) const { return (*edge_filter_map)[e]; } 485 478 486 template< typename It > It first() const { 479 487 It e; this->first(e); return e; } -
src/work/marci/time_measure.h
r259 r323 9 9 #include <unistd.h> 10 10 11 double currTime() { 12 timeval tv; 13 //timezone tz; 14 gettimeofday(&tv, 0); 15 return double(tv.tv_sec)+double(tv.tv_usec)/1000000.0; 16 } 11 namespace hugo { 17 12 18 class TimeStamp 19 { 20 tms ts; 21 double real_time; 13 // double currTime() { 14 // timeval tv; 15 // //timezone tz; 16 // gettimeofday(&tv, 0); 17 // return double(tv.tv_sec)+double(tv.tv_usec)/1000000.0; 18 // } 19 20 class TimeStamp 21 { 22 tms ts; 23 double real_time; 22 24 23 public:25 public: 24 26 25 tms &getTms() {return ts;} 26 const tms &getTms() const {return ts;} 27 double getRealTime() const {return real_time;} 28 void stamp() 27 tms &getTms() {return ts;} 28 const tms &getTms() const {return ts;} 29 double getRealTime() const {return real_time;} 30 void stamp() 31 { 32 timeval tv; 33 times(&ts); 34 gettimeofday(&tv, 0);real_time=tv.tv_sec+double(tv.tv_usec)/1e6; 35 } 36 37 TimeStamp() 38 { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0; real_time=0;} 39 40 TimeStamp(void *) { stamp();} 41 42 TimeStamp &operator+=(const TimeStamp &b) 43 { 44 ts.tms_utime+=b.ts.tms_utime; 45 ts.tms_stime+=b.ts.tms_stime; 46 ts.tms_cutime+=b.ts.tms_cutime; 47 ts.tms_cstime+=b.ts.tms_cstime; 48 real_time+=b.real_time; 49 return *this; 50 } 51 TimeStamp operator+(const TimeStamp &b) const 52 { 53 TimeStamp t(*this); 54 return t+=b; 55 } 56 TimeStamp &operator-=(const TimeStamp &b) 57 { 58 ts.tms_utime-=b.ts.tms_utime; 59 ts.tms_stime-=b.ts.tms_stime; 60 ts.tms_cutime-=b.ts.tms_cutime; 61 ts.tms_cstime-=b.ts.tms_cstime; 62 real_time-=b.real_time; 63 return *this; 64 } 65 TimeStamp operator-(const TimeStamp &b) const 66 { 67 TimeStamp t(*this); 68 return t-=b; 69 } 70 71 TimeStamp Ellapsed() const 72 { 73 TimeStamp t(NULL); 74 return t-*this; 75 } 76 77 friend std::ostream& operator<<(std::ostream& os,const TimeStamp &t); 78 79 double getUserTime() const 80 { 81 return double(ts.tms_utime)/sysconf(_SC_CLK_TCK); 82 } 83 double getSystemTime() const 84 { 85 return double(ts.tms_stime)/sysconf(_SC_CLK_TCK); 86 } 87 double getCUserTime() const 88 { 89 return double(ts.tms_cutime)/sysconf(_SC_CLK_TCK); 90 } 91 double getCSystemTime() const 92 { 93 return double(ts.tms_cstime)/sysconf(_SC_CLK_TCK); 94 } 95 }; 96 97 class Timer 29 98 { 30 timeval tv; 31 times(&ts); 32 gettimeofday(&tv, 0);real_time=tv.tv_sec+double(tv.tv_usec)/1e6; 33 } 99 TimeStamp start_time; 100 101 void _reset() {start_time.stamp();} 34 102 35 TimeStamp() 36 { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0; real_time=0;} 37 38 TimeStamp(void *) { stamp();} 39 40 TimeStamp &operator+=(const TimeStamp &b) 103 public: 104 Timer() {_reset();} 105 106 operator TimeStamp () 107 { 108 TimeStamp t; 109 t.stamp(); 110 return t-start_time; 111 } 112 113 TimeStamp reset() 114 { 115 TimeStamp t(start_time); 116 _reset(); 117 return start_time-t; 118 } 119 }; 120 121 inline std::ostream& operator<<(std::ostream& os,const TimeStamp &t) 41 122 { 42 ts.tms_utime+=b.ts.tms_utime; 43 ts.tms_stime+=b.ts.tms_stime; 44 ts.tms_cutime+=b.ts.tms_cutime; 45 ts.tms_cstime+=b.ts.tms_cstime; 46 real_time+=b.real_time; 47 return *this; 48 } 49 TimeStamp operator+(const TimeStamp &b) const 50 { 51 TimeStamp t(*this); 52 return t+=b; 53 } 54 TimeStamp &operator-=(const TimeStamp &b) 55 { 56 ts.tms_utime-=b.ts.tms_utime; 57 ts.tms_stime-=b.ts.tms_stime; 58 ts.tms_cutime-=b.ts.tms_cutime; 59 ts.tms_cstime-=b.ts.tms_cstime; 60 real_time-=b.real_time; 61 return *this; 62 } 63 TimeStamp operator-(const TimeStamp &b) const 64 { 65 TimeStamp t(*this); 66 return t-=b; 123 long cls = sysconf(_SC_CLK_TCK); 124 os << "u: " << double(t.getTms().tms_utime)/cls << 125 "s, s: " << double(t.getTms().tms_stime)/cls << 126 "s, cu: " << double(t.getTms().tms_cutime)/cls << 127 "s, cs: " << double(t.getTms().tms_cstime)/cls << 128 "s, real: " << t.getRealTime() << "s"; 129 return os; 67 130 } 68 131 69 TimeStamp Ellapsed() const 70 { 71 TimeStamp t(NULL); 72 return t-*this; 73 } 74 75 friend std::ostream& operator<<(std::ostream& os,const TimeStamp &t); 76 77 double getUserTime() const 78 { 79 return double(ts.tms_utime)/sysconf(_SC_CLK_TCK); 80 } 81 double getSystemTime() const 82 { 83 return double(ts.tms_stime)/sysconf(_SC_CLK_TCK); 84 } 85 double getCUserTime() const 86 { 87 return double(ts.tms_cutime)/sysconf(_SC_CLK_TCK); 88 } 89 double getCSystemTime() const 90 { 91 return double(ts.tms_cstime)/sysconf(_SC_CLK_TCK); 92 } 93 }; 94 95 class Timer 96 { 97 TimeStamp start_time; 98 99 void _reset() {start_time.stamp();} 100 101 public: 102 Timer() {_reset();} 103 104 operator TimeStamp () 105 { 106 TimeStamp t; 107 t.stamp(); 108 return t-start_time; 109 } 110 111 TimeStamp reset() 112 { 113 TimeStamp t(start_time); 114 _reset(); 115 return start_time-t; 116 } 117 }; 118 119 inline std::ostream& operator<<(std::ostream& os,const TimeStamp &t) 120 { 121 long cls = sysconf(_SC_CLK_TCK); 122 os << "u: " << double(t.getTms().tms_utime)/cls << 123 "s, s: " << double(t.getTms().tms_stime)/cls << 124 "s, cu: " << double(t.getTms().tms_cutime)/cls << 125 "s, cs: " << double(t.getTms().tms_cstime)/cls << 126 "s, real: " << t.getRealTime() << "s"; 127 return os; 128 } 132 } //namespace hugo 129 133 130 134 #endif //HUGO_TIME_MEASURE_H
Note: See TracChangeset
for help on using the changeset viewer.