timer-test.cc
Go to the documentation of this file.
1 // base/timer-test.cc
2 
3 // Copyright 2009-2011 Microsoft Corporation
4 // 2014 Johns Hopkins University (author: Daniel Povey)
5 
6 // See ../../COPYING for clarification regarding multiple authors
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 
12 // http://www.apache.org/licenses/LICENSE-2.0
13 
14 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 // MERCHANTABLITY OR NON-INFRINGEMENT.
18 // See the Apache 2 License for the specific language governing permissions and
19 // limitations under the License.
20 
21 #include "base/timer.h"
22 #include "base/kaldi-common.h"
23 #include "base/kaldi-utils.h"
24 
25 
26 namespace kaldi {
27 
28 void TimerTest() {
29  float time_secs = 0.025 * (rand() % 10);
30  std::cout << "target is " << time_secs << "\n";
31  Timer timer;
32  Sleep(time_secs);
33  BaseFloat f = timer.Elapsed();
34  std::cout << "time is " << f << std::endl;
35  if (fabs(time_secs - f) > 0.05)
36  KALDI_ERR << "Timer fail: waited " << f << " seconds instead of "
37  << time_secs << " secs.";
38 }
39 }
40 
41 
42 int main() {
43  for (int i = 0; i < 4; i++)
45 }
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
void Sleep(float seconds)
Definition: kaldi-utils.cc:45
float BaseFloat
Definition: kaldi-types.h:29
#define KALDI_ERR
Definition: kaldi-error.h:147
void TimerTest()
Definition: timer-test.cc:28
double Elapsed() const
Returns time in seconds.
Definition: timer.h:74
int main()
Definition: timer-test.cc:42