IMP  2.1.1
The Integrative Modeling Platform
base/statistics.h
Go to the documentation of this file.
1 /**
2  * \file IMP/base/statistics.h
3  * \brief Manage statistics on IMP runs.
4  *
5  * Copyright 2007-2012 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPBASE_STATISTICS_H
10 #define IMPBASE_STATISTICS_H
11 
12 #include <IMP/base/base_config.h>
13 #include "file.h"
14 #include "internal/static.h"
15 #include <string>
16 #include <boost/timer.hpp>
17 
18 IMPBASE_BEGIN_NAMESPACE
19 
20 /** Reset all the statistics for IMP. */
21 IMPBASEEXPORT void clear_statistics();
22 
23 /** Show all captured timings. */
24 IMPBASEEXPORT void show_timings(TextOutput out);
25 
26 /** Time an operation and save the timings.*/
27 class Timer : public RAII {
28  boost::timer timer_;
29  std::string key_;
30 
31  public:
32  Timer(const Object *object, std::string operation) {
33  key_ = object->get_name() + "::" + operation;
34  }
35  Timer(std::string operation) { key_ = operation; }
36  ~Timer() {
37  internal::timings[key_].total_time += timer_.elapsed();
38  ++internal::timings[key_].calls;
39  }
40 };
41 
42 IMPBASE_END_NAMESPACE
43 
44 #endif /* IMPBASE_STATISTICS_H */
void show_timings(TextOutput out)
Common base class for heavy weight IMP objects.
void clear_statistics()
Handling of file input/output.