-
Notifications
You must be signed in to change notification settings - Fork 0
/
Timer.cpp
101 lines (83 loc) · 1.99 KB
/
Timer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Timer.cpp
*
* Created on: Dec 15, 2016
* Author: onrust
*/
#include "Timer.h"
#include <iostream>
#include <iomanip>
namespace SLM {
Timer::Timer()
{
reset();
}
Timer::~Timer() {
// TODO Auto-generated destructor stub
}
std::chrono::duration<double> Timer::reset()
{
startTime = std::chrono::system_clock::now();
std::chrono::duration<double> oldInterval = interval;
interval = std::chrono::duration<double>::zero();
return oldInterval;
}
std::chrono::duration<double> Timer::getSplit()
{
return std::chrono::system_clock::now()-startTime;
}
std::chrono::duration<double> Timer::stop()
{
interval += std::chrono::system_clock::now()-startTime;
return interval;
}
void Timer::start()
{
startTime = std::chrono::system_clock::now();
}
ProgressTimer::ProgressTimer()
{
}
ProgressTimer::~ProgressTimer()
{
}
void ProgressTimer::disablePrinting()
{
doPrint = false;
}
std::string ProgressTimer::toString()
{
// *mout << std::fixed << "\r"
// << "\tPattern: " << std::setw(10) << counter
// << " (" << std::setw(4) << (oov*1.0/counter*100) << "% OOV) "
// << std::setw(8) << ((int) avgPerSecond) << "P/s"
// << " took " << elapsedSeconds.count() << " seconds";
// *mout << std::endl;
if(doPrint)
{
if(patterns < 10000 || patterns % 20000 == 0)
{
std::cout << "Pattern: " << std::setw(10) << patterns
<< "\tF" << files << ":S" << lines
<< "\tAvg: " << (patterns*1.0)/getSplit().count()
<< "P/s\tTook: " << getSplit().count()
<< " seconds"
// << std::flush;
<< std::endl;
}
}
return "hoi";
}
void ProgressTimer::nextPattern()
{
++patterns;
}
void ProgressTimer::nextLine()
{
++lines;
}
void ProgressTimer::nextFile()
{
++files;
}
} /* namespace SLM */