Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Gaudi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Show more breadcrumbs
Gaudi
Gaudi
Commits
d8a61fef
Commit
d8a61fef
authored
3 years ago
by
Daniel Charles Craik
Committed by
Sebastien Ponce
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Test for Monitoring::Hub::Entity::mergeAndReset
parent
82b26efb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1278
Better (and working) implementation of non mergeable objects in Sinks
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GaudiKernel/tests/src/CounterHistosUnitTest.cpp
+45
-1
45 additions, 1 deletion
GaudiKernel/tests/src/CounterHistosUnitTest.cpp
with
45 additions
and
1 deletion
GaudiKernel/tests/src/CounterHistosUnitTest.cpp
+
45
−
1
View file @
d8a61fef
...
@@ -24,8 +24,17 @@ struct ServiceLocator {
...
@@ -24,8 +24,17 @@ struct ServiceLocator {
MonitoringHub
m_monitHub
{};
MonitoringHub
m_monitHub
{};
};
};
struct
Algo
{
struct
Algo
{
ServiceLocator
*
serviceLocator
()
{
return
new
S
erviceLocator
;
}
ServiceLocator
*
serviceLocator
()
{
return
&
m_s
erviceLocator
;
}
std
::
string
name
()
{
return
""
;
}
std
::
string
name
()
{
return
""
;
}
ServiceLocator
m_serviceLocator
{};
};
struct
HistSink
:
public
Gaudi
::
Monitoring
::
Hub
::
Sink
{
virtual
void
registerEntity
(
Gaudi
::
Monitoring
::
Hub
::
Entity
ent
)
override
{
m_entities
.
push_back
(
ent
);
}
virtual
void
removeEntity
(
Gaudi
::
Monitoring
::
Hub
::
Entity
const
&
ent
)
override
{
auto
it
=
std
::
find
(
begin
(
m_entities
),
end
(
m_entities
),
ent
);
if
(
it
!=
m_entities
.
end
())
m_entities
.
erase
(
it
);
}
std
::
deque
<
Gaudi
::
Monitoring
::
Hub
::
Entity
>
m_entities
;
};
};
BOOST_AUTO_TEST_CASE
(
test_counter_histos
,
*
boost
::
unit_test
::
tolerance
(
1e-14
)
)
{
BOOST_AUTO_TEST_CASE
(
test_counter_histos
,
*
boost
::
unit_test
::
tolerance
(
1e-14
)
)
{
...
@@ -109,6 +118,41 @@ BOOST_AUTO_TEST_CASE( test_custom_axis ) {
...
@@ -109,6 +118,41 @@ BOOST_AUTO_TEST_CASE( test_custom_axis ) {
BOOST_TEST
(
j
[
"axis"
][
0
][
"labels"
]
==
expected_labels
);
BOOST_TEST
(
j
[
"axis"
][
0
][
"labels"
]
==
expected_labels
);
}
}
BOOST_AUTO_TEST_CASE
(
test_histos_merge_reset
,
*
boost
::
unit_test
::
tolerance
(
1e-14
)
)
{
using
namespace
Gaudi
::
Accumulators
;
Algo
algo
;
HistSink
histSink
;
algo
.
serviceLocator
()
->
monitoringHub
().
addSink
(
&
histSink
);
Histogram
<
1
,
atomicity
::
full
,
float
>
hist1
(
&
algo
,
"TestHist1"
,
"Test histogram 1"
,
Axis
<
float
>
{
10
,
0.
,
10.
});
Histogram
<
1
,
atomicity
::
full
,
float
>
hist2
(
&
algo
,
"TestHist2"
,
"Test histogram 2"
,
Axis
<
float
>
{
10
,
0.
,
10.
});
// test all combinations of entities made (a) as part of the Histogram's constructor and (b) separately
auto
ent1a
=
histSink
.
m_entities
[
0
];
auto
ent2a
=
histSink
.
m_entities
[
1
];
Gaudi
::
Monitoring
::
Hub
::
Entity
ent1b
(
""
,
"TestHist1"
,
std
::
string
(
"histogram:Histogram:"
)
+
typeid
(
float
).
name
(),
hist1
);
Gaudi
::
Monitoring
::
Hub
::
Entity
ent2b
(
""
,
"TestHist2"
,
std
::
string
(
"histogram:Histogram:"
)
+
typeid
(
float
).
name
(),
hist2
);
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
hist1
[
i
]
+=
i
;
hist2
[
i
]
+=
2
*
i
;
}
ent1a
.
mergeAndReset
(
ent2a
);
BOOST_TEST
(
hist1
.
toJSON
().
at
(
"nEntries"
).
get
<
unsigned
long
>
()
==
135
);
BOOST_TEST
(
hist2
.
toJSON
().
at
(
"nEntries"
).
get
<
unsigned
long
>
()
==
0
);
ent2b
.
mergeAndReset
(
ent1b
);
BOOST_TEST
(
hist1
.
toJSON
().
at
(
"nEntries"
).
get
<
unsigned
long
>
()
==
0
);
BOOST_TEST
(
hist2
.
toJSON
().
at
(
"nEntries"
).
get
<
unsigned
long
>
()
==
135
);
ent1a
.
mergeAndReset
(
ent2b
);
BOOST_TEST
(
hist1
.
toJSON
().
at
(
"nEntries"
).
get
<
unsigned
long
>
()
==
135
);
BOOST_TEST
(
hist2
.
toJSON
().
at
(
"nEntries"
).
get
<
unsigned
long
>
()
==
0
);
ent2b
.
mergeAndReset
(
ent1a
);
BOOST_TEST
(
hist1
.
toJSON
().
at
(
"nEntries"
).
get
<
unsigned
long
>
()
==
0
);
BOOST_TEST
(
hist2
.
toJSON
().
at
(
"nEntries"
).
get
<
unsigned
long
>
()
==
135
);
}
BOOST_AUTO_TEST_CASE
(
test_2d_histos
,
*
boost
::
unit_test
::
tolerance
(
1e-14
)
)
{
BOOST_AUTO_TEST_CASE
(
test_2d_histos
,
*
boost
::
unit_test
::
tolerance
(
1e-14
)
)
{
using
namespace
Gaudi
::
Accumulators
;
using
namespace
Gaudi
::
Accumulators
;
Algo
algo
;
Algo
algo
;
...
...
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