class OnlineTimer is used to test real-time decoding algorithms and evaluate how long the decoding of a particular utterance would take. More...
#include <online-timing.h>
Public Member Functions | |
OnlineTimer (const std::string &utterance_id) | |
void | SleepUntil (double cur_utterance_length) |
The call to SleepUntil(t) will sleep until cur_utterance_length seconds after this object was initialized, or return immediately if we've already passed that time. More... | |
void | WaitUntil (double cur_utterance_length) |
The call to WaitUntil(t) simulates the effect of sleeping until cur_utterance_length seconds after this object was initialized; but instead of actually sleeping, it increases a counter. More... | |
void | OutputStats (OnlineTimingStats *stats) |
This call, which should be made after decoding is done, writes the stats to the object that accumulates them. More... | |
double | Elapsed () |
Returns the simulated time elapsed in seconds since the timer was started; this equals waited_ plus the real time elapsed. More... | |
Private Attributes | |
std::string | utterance_id_ |
Timer | timer_ |
double | waited_ |
double | utterance_length_ |
class OnlineTimer is used to test real-time decoding algorithms and evaluate how long the decoding of a particular utterance would take.
The 'obvious' way to evaluate this would be to measure the wall-clock time, and if we're processing the data in chunks, to sleep() until a given chunk would become available in a real-time application– e.g. say we need to process a chunk that ends half a second into the utterance, we would sleep until half a second had elapsed since the start of the utterance. In this code we have the option to not actually sleep: we can simulate the effect of sleeping by just incrementing a variable that says how long we would have slept; and we add this to wall-clock times obtained from Timer::Elapsed(). The usage of this class will be something like as follows:
This assumes that the value provided to the last WaitUntil() call was the length of the utterance.
Definition at line 88 of file online-timing.h.
OnlineTimer | ( | const std::string & | utterance_id | ) |
Definition at line 62 of file online-timing.cc.
double Elapsed | ( | ) |
Returns the simulated time elapsed in seconds since the timer was started; this equals waited_ plus the real time elapsed.
Definition at line 92 of file online-timing.cc.
References Timer::Elapsed(), OnlineTimer::timer_, and OnlineTimer::waited_.
void OutputStats | ( | OnlineTimingStats * | stats | ) |
This call, which should be made after decoding is done, writes the stats to the object that accumulates them.
Definition at line 96 of file online-timing.cc.
References Timer::Elapsed(), KALDI_VLOG, KALDI_WARN, OnlineTimingStats::max_delay_, OnlineTimingStats::max_delay_utt_, OnlineTimingStats::num_utts_, OnlineTimer::timer_, OnlineTimingStats::total_audio_, OnlineTimingStats::total_time_taken_, OnlineTimingStats::total_time_waited_, OnlineTimer::utterance_id_, OnlineTimer::utterance_length_, and OnlineTimer::waited_.
Referenced by main().
void SleepUntil | ( | double | cur_utterance_length | ) |
The call to SleepUntil(t) will sleep until cur_utterance_length seconds after this object was initialized, or return immediately if we've already passed that time.
Definition at line 81 of file online-timing.cc.
References Timer::Elapsed(), KALDI_ASSERT, kaldi::Sleep(), OnlineTimer::timer_, OnlineTimer::utterance_length_, and OnlineTimer::waited_.
Referenced by main().
void WaitUntil | ( | double | cur_utterance_length | ) |
The call to WaitUntil(t) simulates the effect of sleeping until cur_utterance_length seconds after this object was initialized; but instead of actually sleeping, it increases a counter.
Definition at line 65 of file online-timing.cc.
References Timer::Elapsed(), OnlineTimer::timer_, OnlineTimer::utterance_length_, and OnlineTimer::waited_.
Referenced by main().
|
private |
Definition at line 112 of file online-timing.h.
Referenced by OnlineTimer::Elapsed(), OnlineTimer::OutputStats(), OnlineTimer::SleepUntil(), and OnlineTimer::WaitUntil().
|
private |
Definition at line 111 of file online-timing.h.
Referenced by OnlineTimer::OutputStats().
|
private |
Definition at line 115 of file online-timing.h.
Referenced by OnlineTimer::OutputStats(), OnlineTimer::SleepUntil(), and OnlineTimer::WaitUntil().
|
private |
Definition at line 114 of file online-timing.h.
Referenced by OnlineTimer::Elapsed(), OnlineTimer::OutputStats(), OnlineTimer::SleepUntil(), and OnlineTimer::WaitUntil().