23#ifndef STOPWATCH_IMPL_H
24#define STOPWATCH_IMPL_H
34template < StopwatchGranularity detailed_timer, StopwatchParallelism threaded_timer >
38 if constexpr ( enable_timer )
40 if constexpr ( use_timer_array )
54 walltime_timer_.start();
55 cputime_timer_.start();
61template < StopwatchGranularity detailed_timer, StopwatchParallelism threaded_timer >
65 if constexpr ( enable_timer )
67 if constexpr ( use_timer_array )
77 walltime_timer_.stop();
78 cputime_timer_.stop();
84template < StopwatchGranularity detailed_timer, StopwatchParallelism threaded_timer >
88 if constexpr ( enable_timer )
90 if constexpr ( use_timer_array )
97 bool is_running_ =
false;
100 is_running_ = walltime_timer_.is_running_();
108template < StopwatchGranularity detailed_timer, StopwatchParallelism threaded_timer >
112 if constexpr ( enable_timer )
114 if constexpr ( use_timer_array )
124 elapsed = walltime_timer_.elapsed( timeunit );
132template < StopwatchGranularity detailed_timer, StopwatchParallelism threaded_timer >
136 std::ostream& os )
const
138 if constexpr ( enable_timer )
140 if constexpr ( use_timer_array )
149 walltime_timer_.print( msg, timeunit, os );
155template < StopwatchGranularity detailed_timer, StopwatchParallelism threaded_timer >
158 const std::string& walltime_name,
159 const std::string& cputime_name )
const
161 if constexpr ( enable_timer )
164 if constexpr ( use_timer_array )
166 std::vector< double > wall_times( walltime_timer_.size() );
167 std::transform( walltime_timer_.begin(),
168 walltime_timer_.end(),
171 d[ walltime_name ] = wall_times;
173 std::vector< double > cpu_times( cputime_timer_.size() );
174 std::transform( cputime_timer_.begin(),
175 cputime_timer_.end(),
178 d[ cputime_name ] = cpu_times;
182 d[ walltime_name ] = walltime_timer_.elapsed();
183 d[ cputime_name ] = cputime_timer_.elapsed();
188template < StopwatchGranularity detailed_timer, StopwatchParallelism threaded_timer >
192 if constexpr ( enable_timer )
195 if constexpr ( use_timer_array )
198 walltime_timer_.resize( num_threads );
199 cputime_timer_.resize( num_threads );
200 for (
size_t i = 0; i < num_threads; ++i )
202 walltime_timer_[ i ].reset();
203 cputime_timer_[ i ].reset();
208 walltime_timer_.reset();
209 cputime_timer_.reset();
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
void reset()
Definition stopwatch_impl.h:190
double elapsed(timers::timeunit_t timeunit=timers::timeunit_t::SECONDS) const
Definition stopwatch_impl.h:110
void stop()
Definition stopwatch_impl.h:63
void print(const std::string &msg="", timers::timeunit_t timeunit=timers::timeunit_t::SECONDS, std::ostream &os=std::cout) const
Definition stopwatch_impl.h:134
void get_status(Dictionary &d, const std::string &walltime_name, const std::string &cputime_name) const
Definition stopwatch_impl.h:157
bool is_running_() const
Definition stopwatch_impl.h:86
void start()
Definition stopwatch_impl.h:36
void assert_thread_parallel() const
Fails if NEST is not in thread-parallel section.
Definition vp_manager.h:200
void assert_single_threaded() const
Fails if NEST is in thread-parallel section.
Definition vp_manager.h:192
size_t get_num_threads() const
Get number of threads.
Definition vp_manager.h:186
size_t get_thread_id() const
Gets ID of local thread.
Definition vp_manager.h:176
This class represents a single timer which measures the execution time of a single thread for a given...
Definition stopwatch.h:114
VPManager vp_manager
Definition kernel_manager.h:234
timeunit_t
Definition stopwatch.h:99
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
KernelManager & kernel()
Definition kernel_manager.h:311