// // $Id: CftTimerTest_t.cpp,v 1.7 2000/12/05 16:52:20 hobbs Exp $ // // File: CftTimerTest_t.cpp // Purpose: // Created: 28-JUL-1999 Harry Melanson // // $Revision: 1.7 $ // // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// // Include files #include #include #include #include "ZMtools/ZMtimer.h" #include "d0om/d0_Ref.hpp" #include "rcp/RCPManager.hpp" #include "rcp/RCP.hpp" #include "cft_util/CFTDetector.hpp" #include "cft_geometry/base/CftBaseGeometry.hpp" #include "cft_geometry/base/CftGeometer.hpp" #include "cft_geometry/channel/CftChannelGeometry.hpp" #include "cft_geometry/channel/CftChannelDoublet.hpp" using namespace std; using namespace edm; using namespace dgs; //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// int main() { //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// CftGeometer* cft_gm; // Base Geometer CftChannelGeometry* cft_channel; // Channel Geometry ZMcpuTimer timer; // A timer //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// // // Build the CFT base and channel geometries // try { //- - - - - - - - - - - - - - - - - - - - - - - - -// // // Build default base geometry using RCP // timer.start(); RCPManager* rcpman = RCPManager::instance(); RCP rcp_base = rcpman->extract("cft_geometry","CftBaseGeometry"); d0_Ref cft_base = CftBaseGeometry::build_default(&rcp_base); d0_Ref cft_base_const; cft_base_const = D0_CONST_REFCONV((CftBaseGeometry)) (cft_base); cft_gm = CftGeometer::get_instance(); cft_gm->refresh(cft_base_const); // Pass a const version to the Geometer //- - - - - - - - - - - - - - - - - - - - - - - - -// // // Build default channel geometry using RCP // RCP rcp_channel = rcpman->extract("cft_geometry","CftChannelGeometry"); cft_channel = CftChannelGeometry::get_instance(); cft_channel->absRefresh(&rcp_channel); timer.stop(); //- - - - - - - - - - - - - - - - - - - - - - - - -// } catch(runtime_error mistake) { cerr << "ERROR: " << mistake.what() << endl; return(1); } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// // cout << "Time to build CFT base, channel geometry = " // << timer.mean() // << " CPU seconds" // << endl; timer.reset(); //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// // Now do timing tests for access to channel geometry // CftChannelDoublet* doublet; ZMcpuTimer timer1; ZMcpuTimer timer2; ZMcpuTimer timer3; ZMcpuTimer timer4; ZMcpuTimer timer5; ZMcpuTimer timer6; ZMcpuTimer timer7; ZMcpuTimer timer8; ZMcpuTimer timer9; ZMcpuTimer timer10; ZMcpuTimer timer11; ZMcpuTimer timer12; //===========================================================// // Perform timing tests on methods using doublet CFTX1 int ntests = 1000000; doublet = cft_channel->get_doublet(CFTX1); timer1.start(); for (int counter = 0; counter < ntests; ++counter){ int nf = doublet->nfibers(); } timer1.stop(); timer2.start(); for (int counter = 0; counter < ntests; ++counter){ double dpdz = doublet->dphidz(); } timer2.stop(); timer3.start(); for (int counter = 0; counter < ntests; ++counter){ double rad = doublet->get_fiber_radius(); } timer3.stop(); timer4.start(); for (int counter = 0; counter < ntests; ++counter){ double pit = doublet->get_fiber_pitch(); } timer4.stop(); timer5.start(); for (int counter = 0; counter < ntests; ++counter){ double r = doublet->get_r(1.0,0.0); } timer5.stop(); timer6.start(); for (int counter = 0; counter < ntests; ++counter){ double phi = doublet->get_phi(1.0,0.0); } timer6.stop(); timer7.start(); for (int counter = 0; counter < ntests; ++counter){ double r = doublet->get_fiber_r(1,0.0); } timer7.stop(); timer11.start(); for (int counter = 0; counter < ntests; ++counter){ double phi = doublet->get_fiber_r_approx(1,0.0); } timer11.stop(); timer12.start(); for (int counter = 0; counter < ntests; ++counter){ double phi = doublet->get_fiber_r_ideal(1,0.0); } timer12.stop(); timer8.start(); for (int counter = 0; counter < ntests; ++counter){ double phi = doublet->get_fiber_phi(1,0.0); } timer8.stop(); timer9.start(); for (int counter = 0; counter < ntests; ++counter){ double phi = doublet->get_fiber_phi_approx(1,0.0); } timer9.stop(); timer10.start(); for (int counter = 0; counter < ntests; ++counter){ double phi = doublet->get_fiber_phi_ideal(1,0.0); } timer10.stop(); //- - - - - - - - - - - - - - - - - - - - - - - - -// // Require the times be "reasonable" /* assert ( (timer1.sum()/ntests)*1000000.0 <= 0.2 ); assert ( (timer2.sum()/ntests)*1000000.0 <= 0.3 ); assert ( (timer3.sum()/ntests)*1000000.0 <= 0.3 ); assert ( (timer4.sum()/ntests)*1000000.0 <= 1.0 ); assert ( (timer5.sum()/ntests)*1000000.0 <= 100.0 ); assert ( (timer6.sum()/ntests)*1000000.0 <= 100.0 ); assert ( (timer7.sum()/ntests)*1000000.0 <= 50.0 ); assert ( (timer11.sum()/ntests)*1000000.0 <= 4.0 ); assert ( (timer12.sum()/ntests)*1000000.0 <= 3.0 ); assert ( (timer8.sum()/ntests)*1000000.0 <= 50.0 ); assert ( (timer9.sum()/ntests)*1000000.0 <= 4.0 ); assert ( (timer10.sum()/ntests)*1000000.0 <= 2.5 ); */ //- - - - - - - - - - - - - - - - - - - - - - - - -// cout << "Mean time for nfibers() = " << (timer1.sum()/ntests)*1000000.0 << " microsec" << endl; cout << "Mean time for dphidz() = " << (timer2.sum()/ntests)*1000000.0 << " microsec" << endl; cout << "Mean time for get_fiber_radius() = " << (timer3.sum()/ntests)*1000000.0 << " microsec" << endl; cout << "Mean time for get_fiber_pitch() = " << (timer4.sum()/ntests)*1000000.0 << " microsec" << endl; cout << "Mean time for get_r() = " << (timer5.sum()/ntests)*1000000.0 << " microsec" << endl; cout << "Mean time for get_phi() = " << (timer6.sum()/ntests)*1000000.0 << " microsec" << endl; cout << "Mean time for get_fiber_r() = " << (timer7.sum()/ntests)*1000000.0 << " microsec" << endl; cout << "Mean time for get_fiber_r_approx() = " << (timer11.sum()/ntests)*1000000.0 << " microsec" << endl; cout << "Mean time for get_fiber_r_ideal() = " << (timer12.sum()/ntests)*1000000.0 << " microsec" << endl; cout << "Mean time for get_fiber_phi() = " << (timer8.sum()/ntests)*1000000.0 << " microsec" << endl; cout << "Mean time for get_fiber_phi_approx() = " << (timer9.sum()/ntests)*1000000.0 << " microsec" << endl; cout << "Mean time for get_fiber_phi_ideal() = " << (timer10.sum()/ntests)*1000000.0 << " microsec" << endl; //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// cout << "Cft geometry timer tests completed successfully" << endl; return(0); }