Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Libhdbpp Timescale
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
LOFAR2.0
Libhdbpp Timescale
Commits
62dfc031
Commit
62dfc031
authored
5 years ago
by
Stuart Mark James
Browse files
Options
Downloads
Patches
Plain Diff
Update build doc, added benchmark directory!
parent
5f94e79c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
benchmark/CMakeLists.txt
+25
-0
25 additions, 0 deletions
benchmark/CMakeLists.txt
benchmark/QueryBuilderTests.cpp
+162
-0
162 additions, 0 deletions
benchmark/QueryBuilderTests.cpp
doc/build.md
+21
-4
21 additions, 4 deletions
doc/build.md
with
208 additions
and
4 deletions
benchmark/CMakeLists.txt
0 → 100644
+
25
−
0
View file @
62dfc031
cmake_minimum_required
(
VERSION 3.6
)
project
(
benchmark-tests
)
set
(
CMAKE_VERBOSE_MAKEFILE ON
)
set
(
CMAKE_COLOR_MAKEFILE ON
)
set
(
BENCHMARK_SOURCES
${
CMAKE_CURRENT_SOURCE_DIR
}
/QueryBuilderTests.cpp
)
add_executable
(
benchmark-tests
${
BENCHMARK_SOURCES
}
)
target_compile_options
(
benchmark-tests PRIVATE -Wall -Wextra -g
)
target_link_libraries
(
benchmark-tests
PRIVATE libhdbpp_headers libhdbpp_timescale_shared_library TangoInterfaceLibrary benchmark gtest
)
target_include_directories
(
benchmark-tests
PRIVATE
${
CMAKE_SOURCE_DIR
}
/src
${
PROJECT_SOURCE_DIR
}
)
target_compile_definitions
(
benchmark-tests
PRIVATE -DDEBUG_ENABLED
)
set_target_properties
(
benchmark-tests
PROPERTIES
LINK_FLAGS
"-Wl,--no-undefined"
CXX_CLANG_TIDY
${
DO_CLANG_TIDY
}
CXX_STANDARD 14
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
benchmark/QueryBuilderTests.cpp
0 → 100644
+
162
−
0
View file @
62dfc031
/* Copyright (C) : 2014-2019
European Synchrotron Radiation Facility
BP 220, Grenoble 38043, FRANCE
This file is part of libhdb++timescale.
libhdb++timescale is free software: you can redistribute it and/or modify
it under the terms of the Lesser GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
libhdb++timescale is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser
GNU General Public License for more details.
You should have received a copy of the Lesser GNU General Public License
along with libhdb++timescale. If not, see <http://www.gnu.org/licenses/>. */
#include
"QueryBuilder.hpp"
#include
<benchmark/benchmark.h>
//=============================================================================
//=============================================================================
void
bmAllocateQueryBuilder
(
benchmark
::
State
&
state
)
{
// Test - Testing the time it takes to allocate a QueryBuilder, mainly for future test
// reference
hdbpp_internal
::
LogConfigurator
::
initLoggingMetrics
(
false
,
false
);
hdbpp_internal
::
LogConfigurator
::
setLoggingLevel
(
spdlog
::
level
::
err
);
for
(
auto
_
:
state
)
hdbpp_internal
::
pqxx_conn
::
QueryBuilder
query_builder
;
}
BENCHMARK
(
bmAllocateQueryBuilder
);
//=============================================================================
//=============================================================================
void
bmTraitsComparator
(
benchmark
::
State
&
state
)
{
// TEST - Test the AttributeTraits comparator used in the cache inside QueryBuilder,
// the test is against a full map with every possible tango traits combination
std
::
map
<
hdbpp_internal
::
AttributeTraits
,
std
::
string
>
trait_cache
;
vector
<
Tango
::
CmdArgType
>
types
{
Tango
::
DEV_DOUBLE
,
Tango
::
DEV_FLOAT
,
Tango
::
DEV_STRING
,
Tango
::
DEV_LONG
,
Tango
::
DEV_ULONG
,
Tango
::
DEV_LONG64
,
Tango
::
DEV_ULONG64
,
Tango
::
DEV_SHORT
,
Tango
::
DEV_USHORT
,
Tango
::
DEV_BOOLEAN
,
Tango
::
DEV_UCHAR
,
Tango
::
DEV_STATE
,
Tango
::
DEV_ENCODED
,
Tango
::
DEV_ENUM
};
vector
<
Tango
::
AttrWriteType
>
write_types
{
Tango
::
READ
,
Tango
::
WRITE
,
Tango
::
READ_WRITE
,
Tango
::
READ_WITH_WRITE
};
vector
<
Tango
::
AttrDataFormat
>
format_types
{
Tango
::
SCALAR
,
Tango
::
SPECTRUM
,
Tango
::
IMAGE
};
for
(
auto
&
type
:
types
)
{
for
(
auto
&
format
:
format_types
)
{
for
(
auto
&
write
:
write_types
)
{
// add to the cache for future hits
trait_cache
.
emplace
(
hdbpp_internal
::
AttributeTraits
{
write
,
format
,
type
},
to_string
(
write
)
+
to_string
(
format
)
+
to_string
(
type
));
}
}
}
hdbpp_internal
::
AttributeTraits
traits
{
Tango
::
READ
,
Tango
::
SCALAR
,
Tango
::
DEV_DOUBLE
};
for
(
auto
_
:
state
)
trait_cache
.
find
(
traits
);
}
BENCHMARK
(
bmTraitsComparator
);
//=============================================================================
//=============================================================================
static
void
writeTypeArgs
(
benchmark
::
internal
::
Benchmark
*
b
)
{
vector
<
Tango
::
AttrWriteType
>
write_types
{
Tango
::
READ
,
Tango
::
WRITE
,
Tango
::
READ_WRITE
,
Tango
::
READ_WITH_WRITE
};
for
(
auto
&
write_type
:
write_types
)
b
->
Args
({
static_cast
<
int
>
(
write_type
)});
}
//=============================================================================
//=============================================================================
template
<
typename
T
>
void
bmStoreDataEventQueryNoCache
(
benchmark
::
State
&
state
)
{
// TEST - Testing how long it takes to build an Insert Data Event query with
// an empty cache (this forces the full string to be built)
hdbpp_internal
::
LogConfigurator
::
initLoggingMetrics
(
false
,
false
);
hdbpp_internal
::
LogConfigurator
::
setLoggingLevel
(
spdlog
::
level
::
err
);
hdbpp_internal
::
AttributeTraits
traits
{
static_cast
<
Tango
::
AttrWriteType
>
(
state
.
range
(
0
)),
Tango
::
SCALAR
,
Tango
::
DEV_DOUBLE
};
for
(
auto
_
:
state
)
{
// define the builder here so its cache is always fresh
hdbpp_internal
::
pqxx_conn
::
QueryBuilder
query_builder
;
query_builder
.
storeDataEventQuery
<
T
>
(
traits
);
}
}
//=============================================================================
//=============================================================================
template
<
typename
T
>
void
bmStoreDataEventQueryCache
(
benchmark
::
State
&
state
)
{
// TEST - Testing the full lookup for an Insert Data QueryEvent query when the cache
// map is fully populated
hdbpp_internal
::
LogConfigurator
::
initLoggingMetrics
(
false
,
false
);
hdbpp_internal
::
LogConfigurator
::
setLoggingLevel
(
spdlog
::
level
::
err
);
hdbpp_internal
::
AttributeTraits
traits
{
static_cast
<
Tango
::
AttrWriteType
>
(
state
.
range
(
0
)),
Tango
::
SCALAR
,
Tango
::
DEV_DOUBLE
};
vector
<
Tango
::
CmdArgType
>
types
{
Tango
::
DEV_DOUBLE
,
Tango
::
DEV_FLOAT
,
Tango
::
DEV_STRING
,
Tango
::
DEV_LONG
,
Tango
::
DEV_ULONG
,
Tango
::
DEV_LONG64
,
Tango
::
DEV_ULONG64
,
Tango
::
DEV_SHORT
,
Tango
::
DEV_USHORT
,
Tango
::
DEV_BOOLEAN
,
Tango
::
DEV_UCHAR
,
Tango
::
DEV_STATE
,
Tango
::
DEV_ENCODED
,
Tango
::
DEV_ENUM
};
vector
<
Tango
::
AttrWriteType
>
write_types
{
Tango
::
READ
,
Tango
::
WRITE
,
Tango
::
READ_WRITE
,
Tango
::
READ_WITH_WRITE
};
vector
<
Tango
::
AttrDataFormat
>
format_types
{
Tango
::
SCALAR
,
Tango
::
SPECTRUM
,
Tango
::
IMAGE
};
hdbpp_internal
::
pqxx_conn
::
QueryBuilder
query_builder
;
for
(
auto
&
type
:
types
)
for
(
auto
&
format
:
format_types
)
for
(
auto
&
write
:
write_types
)
query_builder
.
storeDataEventQuery
<
T
>
(
hdbpp_internal
::
AttributeTraits
{
write
,
format
,
type
});
for
(
auto
_
:
state
)
query_builder
.
storeDataEventQuery
<
T
>
(
traits
);
}
BENCHMARK_TEMPLATE
(
bmStoreDataEventQueryNoCache
,
bool
)
->
Apply
(
writeTypeArgs
);
BENCHMARK_TEMPLATE
(
bmStoreDataEventQueryCache
,
bool
)
->
Apply
(
writeTypeArgs
);
BENCHMARK_MAIN
();
\ No newline at end of file
This diff is collapsed.
Click to expand it.
doc/build.md
+
21
−
4
View file @
62dfc031
...
...
@@ -65,18 +65,20 @@ The following is a list of common useful CMake flags and their use:
| Flag | Setting | Default | Description |
|------|-----|-----|-----|
|
HDBPP_TDB_
BUILD_TESTS | ON/OFF | OFF | Build unit tests |
|
HDBPP_TDB_BUILD_DEBUG_SYMBOLS | ON/OFF | OFF | Add additional debug systems to the library
|
|
HDBPP_TDB_
ENABLE_CLANG | ON/OFF | OFF | Clang code static analysis, readability, and cppcore guideline enforcement |
| BUILD
_UNIT
_TESTS | ON/OFF | OFF | Build unit tests |
|
BUILD_BENCHMARK_TESTS | ON/OFF | OFF | Build benchmark tests (Forces a Release build)
|
| ENABLE_CLANG | ON/OFF | OFF | Clang code static analysis, readability, and cppcore guideline enforcement |
## Running Tests
### Unit Tests
The project has extensive unit tests to ensure its functioning as expect. Build the project with testing enabled:
```
bash
mkdir
-p
build
cd
build
cmake
-D
HDBPP_TDB_
BUILD_TESTS
=
ON ..
cmake
-DBUILD
_UNIT
_TESTS
=
ON ..
make
```
...
...
@@ -103,3 +105,18 @@ To see more options for the unit-test command line binary:
```
bash
./bin/unit-tests
--help
```
### Benchmark Tests
These are a work in progress to explore future optimisation point. If built, they can be run as follows:
```
bash
mkdir
-p
build
cd
build
cmake
-DBUILD_BENCHMARK_TESTS
=
ON ..
make
```
```
bash
./benchmark/benchmark-tests
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment