Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection Comparison Progress Bar, main branch (2024.11.27.) #786

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,13 @@ if( TRACCC_SETUP_BENCHMARKS )
endif()

# Set up indicators.
set( _indicatorsDefault FALSE )
if( TRACCC_BUILD_EXAMPLES OR TRACCC_BUILD_IO )
set( _indicatorsDefault TRUE )
endif()
option( TRACCC_SETUP_INDICATORS
"Set up the indicators target(s) explicitly" ${TRACCC_BUILD_EXAMPLES} )
"Set up the indicators target(s) explicitly" ${_indicatorsDefault} )
unset( _indicatorsDefault )
option( TRACCC_USE_SYSTEM_INDICATORS
"Pick up an existing installation of indicators from the build environment"
${TRACCC_USE_SYSTEM_LIBS} )
Expand Down
9 changes: 6 additions & 3 deletions performance/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TRACCC library, part of the ACTS project (R&D line)
#
# (c) 2022-2023 CERN for the benefit of the ACTS project
# (c) 2022-2024 CERN for the benefit of the ACTS project
#
# Mozilla Public License Version 2.0

Expand Down Expand Up @@ -36,7 +36,7 @@ traccc_add_library( traccc_performance performance TYPE SHARED
"include/traccc/utils/ranges.hpp"
"include/traccc/utils/helpers.hpp"
"src/utils/helpers.hpp"
"src/utils/helpers.cpp"
"src/utils/helpers.cpp"
# Value/object comparison code.
"include/traccc/performance/details/is_same_angle.hpp"
"src/performance/details/is_same_angle.cpp"
Expand All @@ -53,6 +53,8 @@ traccc_add_library( traccc_performance performance TYPE SHARED
"include/traccc/performance/impl/comparator_factory.ipp"
"include/traccc/performance/impl/seed_comparator_factory.ipp"
"src/performance/details/comparator_factory.cpp"
"include/traccc/performance/details/comparison_progress.hpp"
"src/performance/details/comparison_progress.cpp"
# Collection/container comparison code.
"include/traccc/performance/collection_comparator.hpp"
"include/traccc/performance/impl/collection_comparator.ipp"
Expand All @@ -66,7 +68,8 @@ traccc_add_library( traccc_performance performance TYPE SHARED
"include/traccc/performance/throughput.hpp"
"src/performance/throughput.cpp" )
target_link_libraries( traccc_performance
PUBLIC traccc::core traccc::io covfie::core detray::test_utils )
PUBLIC traccc::core traccc::io covfie::core detray::test_utils
PRIVATE indicators::indicators )

# Use ROOT in traccc::performance, if requested.
if( TRACCC_USE_ROOT )
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// System include(s).
#include <iostream>
#include <memory>
#include <string_view>

namespace traccc::details {

/// Internal data used by @c comparison_progress
struct comparison_progress_data;

/// Class for tracking the progress of a comparison operation
///
/// It's really just a wrapper around the indicators::progress_bar class.
/// It's here to not expose a public dependency on the indicators library.
///
class comparison_progress {

public:
/// Constructor with the total number of steps
comparison_progress(std::size_t steps, std::ostream& out = std::cout,
std::string_view description = "Running comparison ");
/// Destructor
~comparison_progress();

/// Mark one step done with the progress
void tick();

private:
/// Opaque internal data
std::unique_ptr<comparison_progress_data> m_data;

}; // class comparison_progress

} // namespace traccc::details
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2022 CERN for the benefit of the ACTS project
* (c) 2022-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// Library include(s).
#include "traccc/performance/details/comparison_progress.hpp"
#include "traccc/performance/details/is_same_object.hpp"

// Project include(s).
Expand Down Expand Up @@ -52,6 +53,10 @@ void collection_comparator<TYPE>::operator()(
<< " (" << m_lhs_type << "), " << rhs_coll.size() << " ("
<< m_rhs_type << ")\n";

// Create a progress bar.
details::comparison_progress progress{
lhs_coll.size() * m_uncertainties.size(), m_out.get()};

// Calculate the agreements at various uncertainties.
std::vector<scalar> agreements;
agreements.reserve(m_uncertainties.size());
Expand All @@ -66,6 +71,7 @@ void collection_comparator<TYPE>::operator()(
obj, uncertainty)) != rhs_coll.end()) {
++matched;
}
progress.tick();
}
// Calculate the agreement value.
agreements.push_back(
Expand Down
44 changes: 44 additions & 0 deletions performance/src/performance/details/comparison_progress.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

// Local include(s).
#include "traccc/performance/details/comparison_progress.hpp"

// Indicators include(s).
#include <indicators/progress_bar.hpp>

namespace traccc::details {

struct comparison_progress_data {

/// Progress bar used internally
std::unique_ptr<indicators::ProgressBar> m_bar;

}; // struct comparison_progress_data

comparison_progress::comparison_progress(std::size_t steps, std::ostream& out,
std::string_view description)
: m_data(std::make_unique<comparison_progress_data>()) {

// Set up the progress bar.
m_data->m_bar = std::make_unique<indicators::ProgressBar>(
indicators::option::BarWidth{50},
indicators::option::PrefixText{description.data()},
indicators::option::ShowPercentage{true},
indicators::option::ShowRemainingTime{true},
indicators::option::MaxProgress{steps},
indicators::option::Stream{out});
}

comparison_progress::~comparison_progress() = default;

void comparison_progress::tick() {

m_data->m_bar->tick();
}

} // namespace traccc::details
Loading