Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-01-27 19:58:03


The following patch adds a maximum number of iterations to the do-while loops
in regex_timer.cpp that have the terminating condition:
  (tim < t.elapsed_min() * 1000) || (tim < 1)

This condition is apparently not ever becoming false when the nightly
regression tests are running, and the processes are being killed after ~25
minutes of running.

With approval I'll commit this patch to CVS.

        Doug

Index: regex_timer.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/regex/example/timer/regex_timer.cpp,v
retrieving revision 1.5
diff -c -3 -p -r1.5 regex_timer.cpp
*** regex_timer.cpp 2001/12/26 11:21:24 1.5
--- regex_timer.cpp 2002/01/28 00:51:32
*************** int main(int argc, char**argv)
*** 188,193 ****
--- 188,194 ----
           regex_search(s2, sm, ex);
  
           // measure time interval for reg_expression<char>
+ int trials = 30;
           do{
              iters *= (tim > 0.001) ? (1.1/tim) : 100;
              t.restart();
*************** int main(int argc, char**argv)
*** 196,202 ****
                 result = regex_search(s2, sm, ex);
              }
              tim = t.elapsed();
! }while((tim < t.elapsed_min() * 1000) || (tim < 1));
  
           cout << "regex time: " << (tim * 1000000 / iters) << "us" << endl;
           if(result)
--- 197,203 ----
                 result = regex_search(s2, sm, ex);
              }
              tim = t.elapsed();
! }while(((tim < t.elapsed_min() * 1000) || (tim < 1)) && trials--);
  
           cout << "regex time: " << (tim * 1000000 / iters) << "us" << endl;
           if(result)
*************** int main(int argc, char**argv)
*** 258,263 ****
--- 259,265 ----
           // measure time interval for reg_expression<char> using a deque
           iters = 10;
           tim = 1.1;
+ trials = 30;
           // cache load:
           regex_search(ds.begin(), ds.end(), dm, ex);
           do{
*************** int main(int argc, char**argv)
*** 268,274 ****
                 result = regex_search(ds.begin(), ds.end(), dm, ex);
              }
              tim = t.elapsed();
! }while((tim < t.elapsed_min() * 1000) || (tim < 1));
           cout << "regex time (search over std::deque<char>): " << (tim *
1000000 / iters) << "us" << endl;
  
           if(result)
--- 270,276 ----
                 result = regex_search(ds.begin(), ds.end(), dm, ex);
              }
              tim = t.elapsed();
! }while(((tim < t.elapsed_min() * 1000) || (tim < 1)) && trials--);
           cout << "regex time (search over std::deque<char>): " << (tim *
1000000 / iters) << "us" << endl;
  
           if(result)
*************** int main(int argc, char**argv)
*** 295,300 ****
--- 297,303 ----
           // measure time interval for POSIX matcher:
           iters = 10;
           tim = 1.1;
+ trials = 30;
           // cache load:
           regexec(&r, s2.c_str(), nsubs, matches.get(), 0);
           do{
*************** int main(int argc, char**argv)
*** 302,311 ****
              t.restart();
              for(i = 0; i < iters; ++i)
              {
                 result = regexec(&r, s2.c_str(), nsubs, matches.get(), 0);
              }
              tim = t.elapsed();
! }while((tim < t.elapsed_min() * 1000) || (tim < 1));
           cout << "POSIX regexec time: " << (tim * 1000000 / iters) << "us"
<< endl;
  
           if(result == 0)
--- 305,315 ----
              t.restart();
              for(i = 0; i < iters; ++i)
              {
+ std::cerr << "Iteration #" << i << "/" << iters << std::endl;
                 result = regexec(&r, s2.c_str(), nsubs, matches.get(), 0);
              }
              tim = t.elapsed();
! }while(((tim < t.elapsed_min() * 1000) || (tim < 1)) && trials--);
           cout << "POSIX regexec time: " << (tim * 1000000 / iters) << "us"
<< endl;
  
           if(result == 0)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk