src/benchmark/bench_tools.h
changeset 732 33cbc0635e92
parent 711 b6c56353832c
child 742 235fd36336b7
equal deleted inserted replaced
0:a6b674874084 1:2398c139396c
     1 // -*- mode:C++ -*-
     1 // -*- mode:C++ -*-
     2 #ifndef HUGO_BENCH_TEST_H
     2 #ifndef HUGO_BENCH_TEST_H
     3 #define HUGO_BENCH_TEST_H
     3 #define HUGO_BENCH_TEST_H
     4 
     4 
     5 #include<vector>
     5 #include<vector>
       
     6 #include<iostream>
       
     7 
       
     8 #include<hugo/time_measure.h>
     6 
     9 
     7 ///An experimental typedef factory
    10 ///An experimental typedef factory
     8 #define GRAPH_TYPEDEF_FACTORY(Graph) \
    11 #define GRAPH_TYPEDEF_FACTORY(Graph) \
     9    typedef typename Graph::   Node      Node;\
    12    typedef typename Graph::   Node      Node;\
    10    typedef typename Graph::   NodeIt    NodeIn;\
    13    typedef typename Graph::   NodeIt    NodeIn;\
    21    typedef Graph:: InEdgeIt  InEdgeIt;\
    24    typedef Graph:: InEdgeIt  InEdgeIt;\
    22    typedef Graph::OutEdgeIt OutEdgeIt;
    25    typedef Graph::OutEdgeIt OutEdgeIt;
    23  
    26  
    24 
    27 
    25 ///A primitive primtest
    28 ///A primitive primtest
       
    29 
       
    30 ///\bug 2 is not a prime according to this function!
    26 bool isPrim(int n)
    31 bool isPrim(int n)
    27 {
    32 {
    28   if(n%2) {
    33   if(n%2) {
    29     for(int k=3;n/k>=k;k+=2)
    34     for(int k=3;n/k>=k;k+=2)
    30       if(!(n%k)) return false;
    35       if(!(n%k)) return false;
    67 	return n;
    72 	return n;
    68       }
    73       }
    69     }
    74     }
    70 };
    75 };
    71 
    76 
       
    77 inline void PrintTime(char *ID,hugo::Timer &T) 
       
    78 {
       
    79   hugo::TimeStamp S(T);
       
    80   std::cout << ID << ' ' << S.getUserTime() << ' '
       
    81 	    << S.getSystemTime() << ' ' << S.getRealTime() << std::endl;
       
    82 }
       
    83 
       
    84   
    72 
    85 
    73 #endif
    86 #endif