- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

# 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 #  ifdef VAUCANSON
    00026 #   include <vaucanson/misc/timer.hh>
    00027 #   define TIMER_SCOPED(Task)\
    00028              vcsn::misc::ScopedTimer stimer (GLOBAL_TIMER, Task)
    00029 #  else
    00030 #   include "timer.hh"
    00031 #   define TIMER_SCOPED(Task) misc::ScopedTimer stimer (GLOBAL_TIMER, Task)
    00032 #  endif
    00033 #  define TIMER_START()      GLOBAL_TIMER.start ()
    00034 #  define TIMER_PUSH(Task)   GLOBAL_TIMER.push (Task)
    00035 #  define TIMER_POP(Task)    GLOBAL_TIMER.pop (Task)
    00036 #  define TIMER_STOP()       GLOBAL_TIMER.stop ()
    00037 #  define TIMER_DUMP(Stream) GLOBAL_TIMER.dump (Stream)
    00038 #  define TIMER_TASK(Task)   GLOBAL_TIMER.task (Task)
    00039 #  define TIMER_PRINT(Stream)             GLOBAL_TIMER.print (Stream)
    00040 #  define TIMER_PRINT_VD(Stream, Vd)      GLOBAL_TIMER.print (Stream, Vd)
    00041 #  define TIMER_EXPORT_DOT(Stream)        GLOBAL_TIMER.export_dot (Stream)
    00042 #  define TIMER_EXPORT_DOT_VD(Stream, Vd) GLOBAL_TIMER.export_dot (Stream, Vd)
    00043 #  define TIMER_EXPORT_DOT_VD_CR(Stream, Vd, Cr)\
    00044             GLOBAL_TIMER.export_dot (Stream, Vd, Cr)
    00045 # else
    00046 #  define TIMER_START()      ((void) 0)
    00047 #  define TIMER_PUSH(Task)   ((void) 0)
    00048 #  define TIMER_POP(Task)    ((void) 0)
    00049 #  define TIMER_STOP()       ((void) 0)
    00050 #  define TIMER_DUMP(Stream) ((void) 0)
    00051 #  define TIMER_TASK(Task)   ((int)  0)
    00052 #  define TIMER_SCOPED(Task) ((void) 0)
    00053 #  define TIMER_PRINT(Stream)                   ((void) 0)
    00054 #  define TIMER_PRINT_VD(Stream, Vd)            ((void) 0)
    00055 #  define TIMER_EXPORT_DOT(Stream)              ((void) 0)
    00056 #  define TIMER_EXPORT_DOT_VD(Stream, Vd)       ((void) 0)
    00057 #  define TIMER_EXPORT_DOT_VD_CR(Stream, Vd, Cr)((void) 0)
    00058 # endif
    00059
    00060
    00061 /*-------------------.
    00062 | Use of a Bencher.  |
    00063 `-------------------*/
    00064
    00065 # ifdef GLOBAL_BENCHER
    00066 #  ifdef VAUCANSON
    00067 #   include <vaucanson/misc/bencher.hh>
    00068 #  else
    00069 #   include "bencher.hh"
    00070 #  endif
    00071
    00072 #  define BENCH_DO(Iterations)                                          \
    00073   for (unsigned i_ = 1; i_ <= (Iterations);                             \
    00074        ++i_, GLOBAL_BENCHER.push(GLOBAL_TIMER), (GLOBAL_TIMER).clear())
    00075
    00076 # define BENCH_PRINT(Stream)                            \
    00077   Stream << GLOBAL_BENCHER << std::endl
    00078
    00079 # define BENCH_PLOT(Stream)                             \
    00080   GLOBAL_BENCHER.plot (Stream)
    00081
    00082 # define BENCH_SAVE_PLOT(Filename)                                      \
    00083   do {                                                                  \
    00084     std::ofstream o (Filename,                                          \
    00085                      std::ofstream::out | std::ofstream::trunc);        \
    00086     BENCH_PLOT(o);                                                      \
    00087     o.close();                                                          \
    00088   } while (0)
    00089
    00090 # else
    00091
    00092 #  define BENCH_DO(Iterations)          ((void) 0)
    00093 # define BENCH_PRINT(Stream)            ((void) 0)
    00094 # define BENCH_PLOT(Stream)             ((void) 0)
    00095 # define BENCH_SAVE_PLOT(Filename)      ((void) 0)
    00096
    00097 # endif
    00098
    00099
    00100 #endif // ! VCSN_MISC_GLOBAL_TIMER_HH