gw, kiszedtem ami nem kell
authormarci
Wed, 14 Apr 2004 13:57:48 +0000
changeset 32358bc28afea63
parent 322 a42dacfd0e3e
child 324 c8b0ad782bda
gw, kiszedtem ami nem kell
src/work/marci/graph_wrapper.h
src/work/marci/time_measure.h
     1.1 --- a/src/work/marci/graph_wrapper.h	Wed Apr 14 13:30:05 2004 +0000
     1.2 +++ b/src/work/marci/graph_wrapper.h	Wed Apr 14 13:57:48 2004 +0000
     1.3 @@ -462,19 +462,27 @@
     1.4        return i;
     1.5      }
     1.6  
     1.7 -      
     1.8 -    Node aNode(const OutEdgeIt& e) const { return Node(graph->aNode(e.e)); }
     1.9 -    Node aNode(const InEdgeIt& e) const { return Node(graph->aNode(e.e)); }
    1.10 -    Node bNode(const OutEdgeIt& e) const { return Node(graph->bNode(e.e)); }
    1.11 -    Node bNode(const InEdgeIt& e) const { return Node(graph->bNode(e.e)); }
    1.12 -    
    1.13  //     template<typename I> I& next(I &i) const { 
    1.14  //       graph->next(i); 
    1.15  // //      while (graph->valid(i) && !filter_map-get(i)) { graph->next(i); }
    1.16  //       while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
    1.17  //       return i;
    1.18 -//     }
    1.19 -    
    1.20 +//     } 
    1.21 +
    1.22 +    Node aNode(const OutEdgeIt& e) const { return Node(graph->aNode(e.e)); }
    1.23 +    Node aNode(const InEdgeIt& e) const { return Node(graph->aNode(e.e)); }
    1.24 +    Node bNode(const OutEdgeIt& e) const { return Node(graph->bNode(e.e)); }
    1.25 +    Node bNode(const InEdgeIt& e) const { return Node(graph->bNode(e.e)); }
    1.26 +
    1.27 +    void hide(const Node& n) const { node_filter_map->set(n, false); }
    1.28 +    void hide(const Edge& e) const { edge_filter_map->set(e, false); }
    1.29 +
    1.30 +    void unHide(const Node& n) const { node_filter_map->set(n, true); }
    1.31 +    void unHide(const Edge& e) const { edge_filter_map->set(e, true); }
    1.32 +
    1.33 +    bool hidden(const Node& n) const { return (*node_filter_map)[n]; }
    1.34 +    bool hidden(const Edge& e) const { return (*edge_filter_map)[e]; }
    1.35 +
    1.36      template< typename It > It first() const { 
    1.37        It e; this->first(e); return e; }
    1.38      
     2.1 --- a/src/work/marci/time_measure.h	Wed Apr 14 13:30:05 2004 +0000
     2.2 +++ b/src/work/marci/time_measure.h	Wed Apr 14 13:57:48 2004 +0000
     2.3 @@ -8,123 +8,127 @@
     2.4  #include <iostream>
     2.5  #include <unistd.h>
     2.6  
     2.7 -double currTime() {
     2.8 -  timeval tv;
     2.9 -  //timezone tz;
    2.10 -  gettimeofday(&tv, 0);
    2.11 -  return double(tv.tv_sec)+double(tv.tv_usec)/1000000.0;
    2.12 -}
    2.13 +namespace hugo {
    2.14  
    2.15 -class TimeStamp
    2.16 -{
    2.17 -  tms ts;
    2.18 -  double real_time;
    2.19 +//   double currTime() {
    2.20 +//     timeval tv;
    2.21 +//     //timezone tz;
    2.22 +//     gettimeofday(&tv, 0);
    2.23 +//     return double(tv.tv_sec)+double(tv.tv_usec)/1000000.0;
    2.24 +//   }
    2.25 +
    2.26 +  class TimeStamp
    2.27 +  {
    2.28 +    tms ts;
    2.29 +    double real_time;
    2.30    
    2.31 -public:
    2.32 +  public:
    2.33  
    2.34 -  tms &getTms() {return ts;}
    2.35 -  const tms &getTms() const {return ts;}
    2.36 -  double getRealTime() const {return real_time;}
    2.37 -  void stamp()
    2.38 +    tms &getTms() {return ts;}
    2.39 +    const tms &getTms() const {return ts;}
    2.40 +    double getRealTime() const {return real_time;}
    2.41 +    void stamp()
    2.42 +    {
    2.43 +      timeval tv;
    2.44 +      times(&ts);
    2.45 +      gettimeofday(&tv, 0);real_time=tv.tv_sec+double(tv.tv_usec)/1e6;
    2.46 +    }
    2.47 +  
    2.48 +    TimeStamp()
    2.49 +    { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0; real_time=0;}
    2.50 +  
    2.51 +    TimeStamp(void *) { stamp();}
    2.52 +  
    2.53 +    TimeStamp &operator+=(const TimeStamp &b)
    2.54 +    {
    2.55 +      ts.tms_utime+=b.ts.tms_utime;
    2.56 +      ts.tms_stime+=b.ts.tms_stime;
    2.57 +      ts.tms_cutime+=b.ts.tms_cutime;
    2.58 +      ts.tms_cstime+=b.ts.tms_cstime;
    2.59 +      real_time+=b.real_time;
    2.60 +      return *this;
    2.61 +    }
    2.62 +    TimeStamp operator+(const TimeStamp &b) const
    2.63 +    {
    2.64 +      TimeStamp t(*this);
    2.65 +      return t+=b;
    2.66 +    }
    2.67 +    TimeStamp &operator-=(const TimeStamp &b)
    2.68 +    {
    2.69 +      ts.tms_utime-=b.ts.tms_utime;
    2.70 +      ts.tms_stime-=b.ts.tms_stime;
    2.71 +      ts.tms_cutime-=b.ts.tms_cutime;
    2.72 +      ts.tms_cstime-=b.ts.tms_cstime;
    2.73 +      real_time-=b.real_time;
    2.74 +      return *this;
    2.75 +    }
    2.76 +    TimeStamp operator-(const TimeStamp &b) const
    2.77 +    {
    2.78 +      TimeStamp t(*this);
    2.79 +      return t-=b;
    2.80 +    }
    2.81 +
    2.82 +    TimeStamp Ellapsed() const
    2.83 +    {
    2.84 +      TimeStamp t(NULL);
    2.85 +      return t-*this;
    2.86 +    }
    2.87 +  
    2.88 +    friend std::ostream& operator<<(std::ostream& os,const TimeStamp &t);
    2.89 +  
    2.90 +    double getUserTime() const
    2.91 +    {
    2.92 +      return double(ts.tms_utime)/sysconf(_SC_CLK_TCK);
    2.93 +    }
    2.94 +    double getSystemTime() const
    2.95 +    {
    2.96 +      return double(ts.tms_stime)/sysconf(_SC_CLK_TCK);
    2.97 +    }
    2.98 +    double getCUserTime() const
    2.99 +    {
   2.100 +      return double(ts.tms_cutime)/sysconf(_SC_CLK_TCK);
   2.101 +    }
   2.102 +    double getCSystemTime() const
   2.103 +    {
   2.104 +      return double(ts.tms_cstime)/sysconf(_SC_CLK_TCK);
   2.105 +    }
   2.106 +  };
   2.107 +
   2.108 +  class Timer
   2.109    {
   2.110 -    timeval tv;
   2.111 -    times(&ts);
   2.112 -    gettimeofday(&tv, 0);real_time=tv.tv_sec+double(tv.tv_usec)/1e6;
   2.113 -  }
   2.114 +    TimeStamp start_time;
   2.115 +
   2.116 +    void _reset() {start_time.stamp();}
   2.117    
   2.118 -  TimeStamp()
   2.119 -  { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0; real_time=0;}
   2.120 -  
   2.121 -  TimeStamp(void *) { stamp();}
   2.122 -  
   2.123 -  TimeStamp &operator+=(const TimeStamp &b)
   2.124 +  public: 
   2.125 +    Timer() {_reset();}
   2.126 +
   2.127 +    operator TimeStamp ()
   2.128 +    {
   2.129 +      TimeStamp t;
   2.130 +      t.stamp();
   2.131 +      return t-start_time;
   2.132 +    }
   2.133 +
   2.134 +    TimeStamp reset()
   2.135 +    {
   2.136 +      TimeStamp t(start_time);
   2.137 +      _reset();
   2.138 +      return start_time-t;
   2.139 +    }
   2.140 +  };
   2.141 +
   2.142 +  inline std::ostream& operator<<(std::ostream& os,const TimeStamp &t)
   2.143    {
   2.144 -    ts.tms_utime+=b.ts.tms_utime;
   2.145 -    ts.tms_stime+=b.ts.tms_stime;
   2.146 -    ts.tms_cutime+=b.ts.tms_cutime;
   2.147 -    ts.tms_cstime+=b.ts.tms_cstime;
   2.148 -    real_time+=b.real_time;
   2.149 -    return *this;
   2.150 -  }
   2.151 -  TimeStamp operator+(const TimeStamp &b) const
   2.152 -  {
   2.153 -    TimeStamp t(*this);
   2.154 -    return t+=b;
   2.155 -  }
   2.156 -  TimeStamp &operator-=(const TimeStamp &b)
   2.157 -  {
   2.158 -    ts.tms_utime-=b.ts.tms_utime;
   2.159 -    ts.tms_stime-=b.ts.tms_stime;
   2.160 -    ts.tms_cutime-=b.ts.tms_cutime;
   2.161 -    ts.tms_cstime-=b.ts.tms_cstime;
   2.162 -    real_time-=b.real_time;
   2.163 -    return *this;
   2.164 -  }
   2.165 -  TimeStamp operator-(const TimeStamp &b) const
   2.166 -  {
   2.167 -    TimeStamp t(*this);
   2.168 -    return t-=b;
   2.169 +    long cls = sysconf(_SC_CLK_TCK);
   2.170 +    os << "u: " << double(t.getTms().tms_utime)/cls <<
   2.171 +      "s, s: " << double(t.getTms().tms_stime)/cls <<
   2.172 +      "s, cu: " << double(t.getTms().tms_cutime)/cls <<
   2.173 +      "s, cs: " << double(t.getTms().tms_cstime)/cls <<
   2.174 +      "s, real: " << t.getRealTime() << "s";
   2.175 +    return os;
   2.176    }
   2.177  
   2.178 -  TimeStamp Ellapsed() const
   2.179 -  {
   2.180 -    TimeStamp t(NULL);
   2.181 -    return t-*this;
   2.182 -  }
   2.183 -  
   2.184 -  friend std::ostream& operator<<(std::ostream& os,const TimeStamp &t);
   2.185 -  
   2.186 -  double getUserTime() const
   2.187 -  {
   2.188 -    return double(ts.tms_utime)/sysconf(_SC_CLK_TCK);
   2.189 -  }
   2.190 -  double getSystemTime() const
   2.191 -  {
   2.192 -    return double(ts.tms_stime)/sysconf(_SC_CLK_TCK);
   2.193 -  }
   2.194 -  double getCUserTime() const
   2.195 -  {
   2.196 -    return double(ts.tms_cutime)/sysconf(_SC_CLK_TCK);
   2.197 -  }
   2.198 -  double getCSystemTime() const
   2.199 -  {
   2.200 -    return double(ts.tms_cstime)/sysconf(_SC_CLK_TCK);
   2.201 -  }
   2.202 -};
   2.203 -
   2.204 -class Timer
   2.205 -{
   2.206 -  TimeStamp start_time;
   2.207 -
   2.208 -  void _reset() {start_time.stamp();}
   2.209 -  
   2.210 -public: 
   2.211 -  Timer() {_reset();}
   2.212 -
   2.213 -  operator TimeStamp ()
   2.214 -  {
   2.215 -    TimeStamp t;
   2.216 -    t.stamp();
   2.217 -    return t-start_time;
   2.218 -  }
   2.219 -
   2.220 -  TimeStamp reset()
   2.221 -  {
   2.222 -    TimeStamp t(start_time);
   2.223 -    _reset();
   2.224 -    return start_time-t;
   2.225 -  }
   2.226 -};
   2.227 -
   2.228 -inline std::ostream& operator<<(std::ostream& os,const TimeStamp &t)
   2.229 -{
   2.230 -  long cls = sysconf(_SC_CLK_TCK);
   2.231 -  os << "u: " << double(t.getTms().tms_utime)/cls <<
   2.232 -    "s, s: " << double(t.getTms().tms_stime)/cls <<
   2.233 -    "s, cu: " << double(t.getTms().tms_cutime)/cls <<
   2.234 -    "s, cs: " << double(t.getTms().tms_cstime)/cls <<
   2.235 -    "s, real: " << t.getRealTime() << "s";
   2.236 -  return os;
   2.237 -}
   2.238 +} //namespace hugo
   2.239  
   2.240  #endif //HUGO_TIME_MEASURE_H