00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 #ifndef VCSN_MISC_GLOBAL_TIMER_HH
00018 # define VCSN_MISC_GLOBAL_TIMER_HH
00019 
00020 
00021 
00022 
00023 
00024 # ifdef GLOBAL_TIMER
00025 #  include <vaucanson/misc/timer.hh>
00026 #  define TIMER_START()      GLOBAL_TIMER.start ()
00027 #  define TIMER_PUSH(Task)   GLOBAL_TIMER.push (Task)
00028 #  define TIMER_POP(Task)    GLOBAL_TIMER.pop (Task)
00029 #  define TIMER_STOP()       GLOBAL_TIMER.stop ()
00030 #  define TIMER_SCOPED(Task) vcsn::misc::ScopedTimer stimer (GLOBAL_TIMER, Task)
00031 #  define TIMER_PRINT(Stream) Stream << GLOBAL_TIMER << std::endl
00032 # else
00033 #  define TIMER_START()      ((void) 0)
00034 #  define TIMER_PUSH(Task)   ((void) 0)
00035 #  define TIMER_POP(Task)    ((void) 0)
00036 #  define TIMER_STOP()       ((void) 0)
00037 #  define TIMER_SCOPED(Task) ((void) 0)
00038 #  define TIMER_PRINT(Stream) ((void) 0)
00039 # endif
00040 
00041 
00042 
00043 
00044 
00045 
00046 # ifdef GLOBAL_BENCHER
00047 #  include <vaucanson/misc/bencher.hh>
00048 
00049 #  define BENCH_DO(Iterations)                                          \
00050   for (unsigned i_ = 1; i_ <= (Iterations);                             \
00051        ++i_, GLOBAL_BENCHER.push(GLOBAL_TIMER), (GLOBAL_TIMER).clear())
00052 
00053 # define BENCH_PRINT(Stream)                            \
00054   Stream << GLOBAL_BENCHER << std::endl
00055 
00056 # define BENCH_PLOT(Stream)                             \
00057   GLOBAL_BENCHER.plot (Stream)
00058 
00059 # define BENCH_SAVE_PLOT(Filename)                                      \
00060   do {                                                                  \
00061     if (Filename != "")                                                 \
00062     {                                                                   \
00063       std::ofstream o (args.plot_output_filename.c_str(),               \
00064                        std::ofstream::out | std::ofstream::trunc);      \
00065       BENCH_PLOT(o);                                                    \
00066       o.close();                                                        \
00067     }                                                                   \
00068   } while (0)
00069 
00070 # else
00071 
00072 #  define BENCH_DO(Iterations)          ((void) 0)
00073 # define BENCH_PRINT(Stream)            ((void) 0)
00074 # define BENCH_PLOT(Stream)             ((void) 0)
00075 # define BENCH_SAVE_PLOT(Filename)      ((void) 0)
00076 
00077 # endif
00078 
00079 
00080 #endif // ! VCSN_MISC_GLOBAL_TIMER_HH