Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F64769289
bm_logging.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, May 29, 07:57
Size
1 KB
Mime Type
text/x-c
Expires
Fri, May 31, 07:57 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17955576
Attached To
rSPECMICP SpecMiCP / ReactMiCP
bm_logging.cpp
View Options
// this file is a micro-benchmark of the logging capacity
//
// right now, this is mainly a test of the data_container.
// It uses the google/benchmark framework
#include <benchmark/benchmark.h>
#include "../src/utils/log.hpp"
#include <iostream>
#include <fstream>
using
namespace
specmicp
;
static
void
InitLogger
(
benchmark
::
State
&
state
)
{
while
(
state
.
KeepRunning
())
{
std
::
ofstream
stream
(
"/dev/null"
);
specmicp
::
init_logger
(
&
stream
,
specmicp
::
logger
::
Info
);
}
}
BENCHMARK
(
InitLogger
);
static
void
DebugMessage
(
benchmark
::
State
&
state
)
{
std
::
ofstream
stream
(
"/dev/null"
);
specmicp
::
init_logger
(
&
stream
,
specmicp
::
logger
::
Info
);
while
(
state
.
KeepRunning
())
{
DEBUG
<<
"debug message"
;
}
}
// Register the function as a benchmark
BENCHMARK
(
DebugMessage
);
static
void
DisregardedWarningMessage
(
benchmark
::
State
&
state
)
{
std
::
ofstream
stream
(
"/dev/null"
);
specmicp
::
init_logger
(
&
stream
,
specmicp
::
logger
::
Error
);
while
(
state
.
KeepRunning
())
{
WARNING
<<
"warning message"
;
}
}
// Register the function as a benchmark
BENCHMARK
(
DisregardedWarningMessage
);
static
void
WarningMessage
(
benchmark
::
State
&
state
)
{
std
::
ofstream
stream
(
"/dev/null"
);
specmicp
::
init_logger
(
&
stream
,
specmicp
::
logger
::
Info
);
while
(
state
.
KeepRunning
())
{
WARNING
<<
"warning message"
;
}
}
// Register the function as a benchmark
BENCHMARK
(
WarningMessage
);
static
void
ErrorMessage
(
benchmark
::
State
&
state
)
{
std
::
ofstream
stream
(
"/dev/null"
);
specmicp
::
init_logger
(
&
stream
,
specmicp
::
logger
::
Info
);
while
(
state
.
KeepRunning
())
{
WARNING
<<
"error message"
;
}
}
// Register the function as a benchmark
BENCHMARK
(
ErrorMessage
);
BENCHMARK_MAIN
();
Event Timeline
Log In to Comment