File indexing completed on 2023-05-05 02:47:27
0001 #include "DataFormats/Provenance/interface/ProductResolverIndexHelper.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include "FWCore/Utilities/interface/TypeID.h"
0004 #include "FWCore/Utilities/interface/CPUTimer.h"
0005 #include "DataFormats/Provenance/interface/EventID.h"
0006 #include "FWCore/Utilities/interface/EDMException.h"
0007 #include "FWCore/Utilities/interface/ProductKindOfType.h"
0008
0009 #include "TClass.h"
0010
0011 #include <iostream>
0012 #include <iomanip>
0013 #include <string>
0014 #include <fstream>
0015 #include <istream>
0016 #include <vector>
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052 using namespace edm;
0053
0054 namespace edmtestlookup {
0055
0056 class Names {
0057 public:
0058 std::string className;
0059 std::string label;
0060 std::string instance;
0061 std::string process;
0062 TypeID typeID;
0063 };
0064 }
0065
0066 using namespace edmtestlookup;
0067
0068 int main() {
0069
0070 std::string line1;
0071 std::string line2;
0072 std::string line3;
0073 std::string line4;
0074
0075 Names names;
0076 std::vector<Names> vNames;
0077
0078 std::ifstream myfile("log3");
0079 if (myfile.is_open()) {
0080 while (myfile.good()) {
0081 getline(myfile, line1);
0082 if (!myfile.good())
0083 break;
0084 getline(myfile, line2);
0085 if (!myfile.good())
0086 break;
0087 getline(myfile, line3);
0088 if (!myfile.good())
0089 break;
0090 getline(myfile, line4);
0091 if (!myfile.good())
0092 break;
0093
0094 std::istringstream ss1(line1);
0095 std::istringstream ss2(line2);
0096 std::istringstream ss3(line3);
0097 std::istringstream ss4(line4);
0098
0099 std::string word;
0100
0101 word = ss1.str();
0102 names.className = word.substr(19);
0103 ss2 >> word >> names.label;
0104 ss3 >> word >> names.instance;
0105 ss4 >> word >> names.process;
0106
0107
0108
0109
0110
0111
0112 vNames.push_back(names);
0113 }
0114 myfile.close();
0115 } else {
0116 std::cout << "ERROR: could not open file log3\n";
0117 }
0118
0119 std::cout << "vNames.size = " << vNames.size() << "\n";
0120
0121 edm::CPUTimer timer;
0122
0123 timer.start();
0124 edm::ProductResolverIndexHelper phih;
0125 timer.stop();
0126
0127 std::vector<unsigned int> savedIndexes;
0128
0129 for (auto& n : vNames) {
0130
0131
0132
0133
0134 TClass* clss = TClass::GetClass(n.className.c_str());
0135
0136 if (n.className == "bool") {
0137 n.typeID = TypeID(typeid(bool));
0138 } else if (n.className == "double") {
0139 n.typeID = TypeID(typeid(double));
0140 } else {
0141 n.typeID = TypeID(*clss->GetTypeInfo());
0142 }
0143
0144 timer.start();
0145 phih.insert(n.typeID, n.label.c_str(), n.instance.c_str(), n.process.c_str());
0146 timer.stop();
0147 }
0148 std::cout << "Filling Time: real " << timer.realTime() << " cpu " << timer.cpuTime() << std::endl;
0149 timer.reset();
0150
0151 timer.start();
0152 phih.setFrozen();
0153 timer.stop();
0154 std::cout << "Freezing Time: real " << timer.realTime() << " cpu " << timer.cpuTime() << std::endl;
0155 timer.reset();
0156
0157
0158
0159 timer.start();
0160
0161 unsigned sum = 0;
0162
0163 for (unsigned j = 0; j < 100; ++j) {
0164 for (auto& n : vNames) {
0165 unsigned temp = 1;
0166
0167 temp = phih.index(PRODUCT_TYPE, n.typeID, n.label.c_str(), n.instance.c_str(), n.process.c_str());
0168
0169 sum += temp;
0170 }
0171 }
0172 timer.stop();
0173
0174 std::cout << "index loop time = real " << timer.realTime() << " cpu " << timer.cpuTime() << std::endl;
0175 return sum;
0176 }