forked from SergiusTheBest/plog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cpp
46 lines (34 loc) · 1.1 KB
/
Main.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
//
// Performance - measures time per a log call.
//
#include <plog/Log.h>
#include <plog/Init.h>
#include <plog/Initializers/RollingFileInitializer.h>
#include <plog/Formatters/TxtFormatter.h>
#include <plog/Appenders/ConsoleAppender.h>
enum
{
Console = 1
};
int main()
{
// Initialize the logger that will be measured.
plog::init(plog::debug, "Performance.txt");
// Initialize the logger for printing info messages.
static plog::ConsoleAppender<plog::TxtFormatter> consoleAppender;
plog::init<Console>(plog::debug, &consoleAppender);
PLOGI_(Console) << "Test started";
plog::util::Time startTime;
plog::util::ftime(&startTime);
const int kCount = 50000;
// Performance measure loop.
for (int i = 0; i < kCount; ++i)
{
PLOGD << "Hello log!";
}
plog::util::Time finishTime;
plog::util::ftime(&finishTime);
time_t timeDiff = (finishTime.millitm - startTime.millitm) + (finishTime.time - startTime.time) * 1000;
PLOGI_(Console) << "Test finished: " << static_cast<double>(timeDiff) * 1000 / kCount << " microsec per call";
return 0;
}