ATLAS Offline Software
Loading...
Searching...
No Matches
testMETHash.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5//Author: Russell Smith
6//Email : rsmith@cern.ch
7//Date : April 2016
8
9// Make sure that asserts work:
10#undef NDEBUG
11
12// System include(s):
13#include <cassert>
14#include <ctime>
15#include <utility>
16
17// Local include(s):
21
22
23static const std::map<int, std::string> metStringsMap = {
24 {0, "RefEle"},
25 {1, "RefGamma"},
26 {2, "RefJet"},
27 {3, "RefTau"},
28 {4, "Muons"},
29 {5, "SoftTrk"},
30 {6, "Final"},
31};
32
34 //std::cout << __PRETTY_FUNCTION__ << std::endl;
35 for(size_t j = 0; j < 10000; ++j){
36 for(size_t i = 0; i < cont.size(); ++i ){
37 xAOD::MissingET * met = *(cont.find(metStringsMap.at(i)));
38 assert(met);
39 }
40 }
41 return 0;
42}
43
45 //std::cout << __PRETTY_FUNCTION__ << std::endl;
46 for(size_t j = 0; j < 10000; ++j){
47 for(size_t i = 0; i < cont.size(); ++i ){
48 // xAOD::MissingET * met = *(cont.findByHash(metStringsMap.at(i)));
49 // assert(met);
50 }
51 }
52 return 0;
53}
54
55double calcMean(std::vector<double> & times){
56 //std::cout << __PRETTY_FUNCTION__ << std::endl;
57 double sum = 0;
58 for (auto i : times ){
59 //std::cout << sum << std::endl;
60 sum += i;
61 }
62
63 return sum/static_cast<double>(times.size());
64}
65
66int main(){std::cout << __PRETTY_FUNCTION__ << std::endl;
67
68 std::pair<xAOD::MissingETContainer, xAOD::MissingETAuxContainer> cont;
69 cont.first.setStore(& cont.second);
70
71 std::vector<double> stringComparisonTimes;
72 std::vector<double> hashComparisonTimes;
73
74 for(size_t i = 0; i < 1000; ++i){
75 for(size_t j = 0; j < 7; ++j){
77 cont.first.push_back(met);
78 }
79
80 clock_t begin = clock();
82 clock_t end = clock();
83
84 cont.first.clear();
85
86 clock_t begin2 = clock();
87 testHashComparisonVersion(cont.first);
88 clock_t end2 = clock();
89
90 cont.first.clear();
91
92 double stringTime = double(end - begin );
93 double hashTime = double(end2 - begin2);
94 // std::cout << "stringTime : " << stringTime << std::endl;
95 // std::cout << "hashTime : " << hashTime << std::endl;
96 stringComparisonTimes.push_back(stringTime);
97 hashComparisonTimes .push_back(hashTime);
98 }
99
100 std::cout << "Avg time to run testStringComparisonVersion : " << calcMean(stringComparisonTimes)/CLOCKS_PER_SEC << std::endl;
101 std::cout << "Avg time to run testHashComparisonVersion : " << calcMean(hashComparisonTimes )/CLOCKS_PER_SEC << std::endl;
102
103 return 0;
104 }
size_type size() const noexcept
Returns the number of elements in the collection.
const_iterator find(const std::string &name) const
Find non-modifiable MET object by name.
MissingET_v1 MissingET
Version control by type defintion.
static const std::map< int, std::string > metStringsMap
int testStringComparisonVersion(xAOD::MissingETContainer &cont)
int testHashComparisonVersion(xAOD::MissingETContainer &cont)
int main()
double calcMean(std::vector< double > &times)