00001 #include "DetectorDescription/RegressionTest/src/ddstats.h"
00002 #include "DetectorDescription/Core/interface/DDCompactView.h"
00003 #include "DetectorDescription/Core/interface/DDMaterial.h"
00004 #include "DetectorDescription/Core/interface/DDSolid.h"
00005 #include "DetectorDescription/Core/interface/DDTransform.h"
00006 #include "DetectorDescription/Core/interface/DDExpandedView.h"
00007 void ddstats(std::ostream & os)
00008 {
00009
00010 os << "DDD in memory stats:" << std::endl
00011 << "====================" << std::endl << std::endl;
00012 DDCompactView cpv;
00013
00014
00015
00016
00017 int noEdges(0);
00018 int noNodes(0);
00019 int noExpNodes(1);
00020
00021
00022 int noLog(0), noPos(0), noSol(0), noMat(0), noRot(0);
00023 noPos = noEdges;
00024
00025
00026 int noCLog(0), noCSol(0), noCMat(0), noCRot(0);
00027
00028 int noSolidP(0);
00029
00030
00031 const graph_type & g = cpv.graph();
00032
00033 DDExpandedView exv(cpv);
00034 while (exv.next()) ++noExpNodes;
00035
00036
00037 graph_type::const_adj_iterator it = g.begin();
00038 for(; it != g.end(); ++it) {
00039 ++noNodes;
00040 noEdges += it->size();
00041 }
00042
00043 typedef DDLogicalPart::StoreT::value_type lpst_type;
00044 lpst_type & lpst = DDLogicalPart::StoreT::instance();
00045 lpst_type::iterator lpstit = lpst.begin();
00046 for(; lpstit != lpst.end(); ++lpstit) {
00047 noCLog += lpstit->first.name().size();
00048 ++noLog;
00049 }
00050
00051 typedef DDMaterial::StoreT::value_type mast_type;
00052 mast_type & mast = DDMaterial::StoreT::instance();
00053 mast_type::iterator mastit = mast.begin();
00054 for(; mastit != mast.end(); ++mastit) {
00055 noCMat += mastit->first.name().size();
00056 ++noMat;
00057 }
00058
00059 typedef DDSolid::StoreT::value_type sost_type;
00060 sost_type & sost = DDSolid::StoreT::instance();
00061 sost_type::iterator sostit = sost.begin();
00062 for(; sostit != sost.end(); ++sostit) {
00063 noCSol += sostit->first.name().size();
00064 DDSolid s(sostit->first);
00065 noSolidP += s.parameters().size();
00066 ++noSol;
00067 }
00068
00069 typedef DDRotation::StoreT::value_type rost_type;
00070 rost_type & rost = DDRotation::StoreT::instance();
00071 rost_type::iterator rostit = rost.begin();
00072 for(; rostit != rost.end(); ++rostit) {
00073 noCRot += rostit->first.name().size();
00074 ++noRot;
00075 }
00076
00077
00078 std::cout << "sizeof(void*)=" << sizeof(void*) << std::endl;
00079 std::cout << "sizeof(DDLogicalPart)="<<sizeof(DDLogicalPart)<<std::endl;
00080 std::cout << "sizeof(DDTranslation)="<< sizeof(DDTranslation)<<std::endl;
00081 std::cout << "sizeof(DDRotationMatrix)=" << sizeof(DDRotationMatrix)<<std::endl;
00082 int store = 4*sizeof(void*);
00083 int byRot = noRot * (sizeof(DDRotationMatrix) + store);
00084 int bySol = noSolidP * sizeof(double) + noSol*store;
00085 int byMat = noMat * (5*sizeof(double) + store);
00086 int byPos = noEdges * (sizeof(DDTranslation) + sizeof(DDRotation) + sizeof(int));
00087 int byNam = noCLog + noCSol + noCMat + noCRot;
00088 int byLog = noLog * (sizeof(DDMaterial) + sizeof(DDSolid) + store);
00089 int byGra = (noEdges + noNodes)*store;
00090 int bytes = byRot + bySol + byMat + byPos + byNam + byLog + byGra;
00091 bytes += noNodes*sizeof(DDLogicalPart) + noEdges*sizeof(DDPosData*);
00092 double mb = 1024.*1024.;
00093
00094 os << "noNodes=" << noNodes << std::endl
00095 << "noEdges=" << noEdges << std::endl
00096 << "noExNod=" << noExpNodes << std::endl << std::endl;
00097 os << "noLog=" << noLog << std::endl
00098 << "noSol=" << noSol << " noSolidP=" << noSolidP << std::endl
00099 << "noMat=" << noMat << std::endl
00100 << "noRot=" << noRot << std::endl << std::endl;
00101 os << "noCLog=" << noCLog << std::endl
00102 << "noCSol=" << noCSol << std::endl
00103 << "noCMat=" << noCMat << std::endl
00104 << "noCRot=" << noCRot << std::endl
00105 << " --------" << std::endl
00106 << " " << byNam
00107 << " chars used for naming." << std::endl << std::endl;
00108 os << "byLog = " << byLog/mb << " logicalparts " << std::endl
00109 << "byNam = " << byNam/mb << " string for names " << std::endl
00110 << "byRot = " << byRot/mb << " rotations " << std::endl
00111 << "bySol = " << bySol/mb << " solids " << std::endl
00112 << "byMat = " << byMat/mb << " materials " << std::endl
00113 << "byPos = " << byPos/mb << " posparts " << std::endl
00114 << "byGra = " << byGra/mb << " graph-struct " << std::endl
00115 << "-----------------------" << std::endl
00116 << "OVERALL: " << bytes / mb << " MByte" << std::endl;
00117
00118 }