global_timer.hh

00001 // global_timer.hh: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 2007 The Vaucanson Group.
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // The complete GNU General Public Licence Notice can be found as the
00013 // `COPYING' file in the root directory.
00014 //
00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
00016 
00017 #ifndef VCSN_MISC_GLOBAL_TIMER_HH
00018 # define VCSN_MISC_GLOBAL_TIMER_HH
00019 
00020 /*-----------------.
00021 | Use of a Timer.  |
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 | Use of a Bencher.  |
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

Generated on Wed Jun 13 17:00:22 2007 for Vaucanson by  doxygen 1.5.1