Vaucanson  1.4.1
global_bencher.hh
1 // global_bencher.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2007 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 
17 #ifndef VCSN_MISC_GLOBAL_BENCHER_HH
18 # define VCSN_MISC_GLOBAL_BENCHER_HH
19 
20 /*-------------------.
21 | Use of a Bencher. |
22 `-------------------*/
23 
24 # ifdef GLOBAL_BENCHER
25 
26 # include <cbs/bench/bench.hh>
27 # include <cbs/bench/bench_internals.hh>
28 
29 # ifdef VAUCANSON
30 # include <vaucanson/misc/bencher.hh>
31 # else
32 # include "bencher.hh"
33 # endif
34 
35 # define BENCHER_DO(Iterations) \
36  for (unsigned i_ = 1; i_ <= (Iterations); \
37  ++i_, GLOBAL_BENCHER.push(bench::current_timer()), bench::restart())
38 
39 # define BENCHER_PRINT(Stream) \
40  Stream << GLOBAL_BENCHER << std::endl
41 
42 # define BENCHER_PLOT(Stream) \
43  GLOBAL_BENCHER.plot (Stream)
44 
45 # define BENCHER_SAVE_PLOT(Filename) \
46  do { \
47  std::ofstream o (Filename, \
48  std::ofstream::out | std::ofstream::trunc); \
49  BENCHER_PLOT(o); \
50  o.close(); \
51  } while (0)
52 
53 # else
54 
55 # define BENCHER_DO(Iterations) ((void) 0)
56 # define BENCHER_PRINT(Stream) ((void) 0)
57 # define BENCHER_PLOT(Stream) ((void) 0)
58 # define BENCHER_SAVE_PLOT(Filename) ((void) 0)
59 
60 # endif
61 
62 
63 #endif // ! VCSN_MISC_GLOBAL_BENCHER_HH