TPIE

2362a60
execution_time_predictor.h
Go to the documentation of this file.
1 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
2 // vi:set ts=4 sts=4 sw=4 noet :
3 // Copyright 2008, The TPIE development team
4 //
5 // This file is part of TPIE.
6 //
7 // TPIE is free software: you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the
9 // Free Software Foundation, either version 3 of the License, or (at your
10 // option) any later version.
11 //
12 // TPIE is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with TPIE. If not, see <http://www.gnu.org/licenses/>
19 #include <tpie/portability.h>
20 
21 #include <boost/date_time/posix_time/posix_time.hpp>
22 #include <sstream>
23 #include <tpie/util.h>
24 #include <tpie/prime.h>
25 #ifndef __TPIE_EXECUTION_TIME_PREDICTOR_H__
26 #define __TPIE_EXECUTION_TIME_PREDICTOR_H__
27 
32 
33 namespace tpie {
34 
35 typedef uint64_t time_type;
36 
42 
48 
50 public:
51  inline unique_id_type & operator << (const std::type_info & type) {
52  ss << type.name() << ";"; return *this;
53  }
54 
55  template <typename T>
56  inline unique_id_type & operator<<(const T & x) {
57  ss << typeid(T).name() << ":" << x << ";"; return *this;
58  }
59 
60  inline std::string operator()() {return ss.str();}
61 private:
62  std::stringstream ss;
63 };
64 
65 
67 public:
68  execution_time_predictor(const std::string & id=std::string());
75  time_type estimate_execution_time(stream_size_type n, double & confidence);
76  void start_execution(stream_size_type n);
77  time_type end_execution();
78  std::string estimate_remaining_time(double progress);
79 
80  static void start_pause();
81  static void end_pause();
82  static void disable_time_storing();
83 
84  //Used by fractional_time_perdictor
85  //TPIE_OS_OFFSET m_aux1;
86  //double m_aux2;
87 private:
88  hash_type m_id;
89  boost::posix_time::ptime m_start_time;
90  time_type m_estimate;
91  double m_confidence;
92 
94  stream_size_type m_n;
95 
96  time_type m_pause_time_at_start;
97 
98 #ifndef TPIE_NDEBUG
99  std::string m_name;
100 #endif
101 
102  static time_type s_pause_time;
103  static boost::posix_time::ptime s_start_pause_time;
104  static bool s_store_times;
105 };
106 
107 } //namespace tpie
108 
109 #endif //__TPIE_EXECUTION_TIME_PREDICTOR_H__
110 
This file contains a few deprecated definitions for legacy code.
void init_execution_time_db()
Used by tpie_init to initialize the execution time database.
time_type estimate_execution_time(stream_size_type n, double &confidence)
Estimate execution time.
Miscellaneous utility functions.
Computations related to prime numbers.
void finish_execution_time_db()
Used by tpie_finish to deinitialize the execution time database.