Skip to content
Snippets Groups Projects
Commit 90b17ad2 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

CLIDComps: add handle performance test

parent 23f49af0
Branches run2-patches
No related tags found
No related merge requests found
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
# Declare the package name:
atlas_subdir( CLIDComps )
......@@ -28,6 +28,12 @@ atlas_add_test( ClassIDSvc_test
LINK_LIBRARIES AthenaKernel GaudiKernel TestTools
ENVIRONMENT "JOBOPTSEARCHPATH=${CMAKE_CURRENT_SOURCE_DIR}/share" )
atlas_add_test( Handle_test
SOURCES test/Handle_test.cxx
LINK_LIBRARIES AthenaKernel GaudiKernel StoreGateLib TestTools
ENVIRONMENT "JOBOPTSEARCHPATH=${CMAKE_CURRENT_SOURCE_DIR}/share"
POST_EXEC_SCRIPT nopost.sh )
atlas_add_test( clid
SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/test/clid_unittest.py
LOG_IGNORE_PATTERN "Ran 3 tests in" )
......
// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
#include <chrono>
#include <iostream>
#include <thread>
#include <vector>
#include <GaudiKernel/DataObjID.h>
#include "AthenaKernel/CLASS_DEF.h"
#include "StoreGate/ReadHandle.h"
#include "TestTools/initGaudi.h"
class Foo {};
CLASS_DEF(Foo, 8101, 0)
void run(int threadId) {
std::cout << "Thread " << threadId << " started." << std::endl;
for (int i = 0; i < 1000000; ++i) {
SG::ReadHandle<Foo> rh;
//rh.fullKey().className();
}
std::cout << "Thread " << threadId << " finished." << std::endl;
}
int main() {
ISvcLocator* pSvcLoc(0);
if (!Athena_test::initGaudi("ClassIDSvc_test.txt", pSvcLoc)) {
std::cerr << "ClassIDSvc_test can not be run" << std::endl;
return 1;
}
const int numThreads = 8;
std::vector<std::thread> threads;
auto start = std::chrono::high_resolution_clock::now();
for (int i = 0; i < numThreads; ++i) {
threads.emplace_back(run, i); // Pass thread ID to the function
}
for (auto& thread : threads) {
thread.join(); // Wait for all threads to finish
}
auto stop = std::chrono::high_resolution_clock::now();
std::cout << "All threads have finished in "
<< std::chrono::duration_cast<std::chrono::milliseconds>(stop-start).count()
<< " ms" << std::endl;
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment