Vaucanson 1.4
global_bencher.hh
00001 // global_bencher.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_BENCHER_HH
00018 # define VCSN_MISC_GLOBAL_BENCHER_HH
00019 
00020 /*-------------------.
00021 | Use of a Bencher.  |
00022 `-------------------*/
00023 
00024 # ifdef GLOBAL_BENCHER
00025 
00026 #  include <cbs/bench/bench.hh>
00027 #  include <cbs/bench/bench_internals.hh>
00028 
00029 #  ifdef VAUCANSON
00030 #   include <vaucanson/misc/bencher.hh>
00031 #  else
00032 #   include "bencher.hh"
00033 #  endif
00034 
00035 #  define BENCHER_DO(Iterations)                                        \
00036   for (unsigned i_ = 1; i_ <= (Iterations);                             \
00037        ++i_, GLOBAL_BENCHER.push(bench::current_timer()), bench::restart())
00038 
00039 # define BENCHER_PRINT(Stream)                          \
00040   Stream << GLOBAL_BENCHER << std::endl
00041 
00042 # define BENCHER_PLOT(Stream)                           \
00043   GLOBAL_BENCHER.plot (Stream)
00044 
00045 # define BENCHER_SAVE_PLOT(Filename)                                    \
00046   do {                                                                  \
00047     std::ofstream o (Filename,                                          \
00048                      std::ofstream::out | std::ofstream::trunc);        \
00049     BENCHER_PLOT(o);                                                    \
00050     o.close();                                                          \
00051   } while (0)
00052 
00053 # else
00054 
00055 # define BENCHER_DO(Iterations)         ((void) 0)
00056 # define BENCHER_PRINT(Stream)          ((void) 0)
00057 # define BENCHER_PLOT(Stream)           ((void) 0)
00058 # define BENCHER_SAVE_PLOT(Filename)    ((void) 0)
00059 
00060 # endif
00061 
00062 
00063 #endif // ! VCSN_MISC_GLOBAL_BENCHER_HH