当前位置: 首页>>代码示例>>C++>>正文


C++ Timing::start方法代码示例

本文整理汇总了C++中Timing::start方法的典型用法代码示例。如果您正苦于以下问题:C++ Timing::start方法的具体用法?C++ Timing::start怎么用?C++ Timing::start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Timing的用法示例。


在下文中一共展示了Timing::start方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(){
    Timing timer;
#ifdef _DEBUG
    int size = 4;{
#else
    for(int size=1; size>0; size*=2){
#endif
    
        std::cout << "size: " << size << '\n';
        const int times = 10;
        Matrix a, b;
        a.resize(size);
        b.resize(size);
        a.randomize();
        b.randomize();

    
        timer.setDivisor(times);
    
   

        timer.start();
        for(int i=0; i<times; i++){
            Matrix c = MatrixMultiplication::recursive(a, b);
#ifdef _DEBUG
            c.print();
#endif
        }
        timer.end();
        timer.reportCPUtime();


        timer.start();
        for(int i=0; i<times; i++){
            Matrix c = MatrixMultiplication::strassen(a, b);
#ifdef _DEBUG
            c.print();
#endif
        }
        timer.end();
        timer.reportCPUtime();
    }

    return system("pause");
}
开发者ID:lizy14,项目名称:algorithm-assignments,代码行数:45,代码来源:Source.cpp

示例2: main

int main()
{
	/******************************* [ signal ] ******************************/
	Type a = 0;
	Type b = Ls-1;
	Vector<Type> t = linspace(a,b,Ls) / Type(Fs);
	Vector<Type> s = sin( Type(400*PI) * pow(t,Type(2.0)) );

	/******************************** [ widow ] ******************************/
	a = 0;
	b = Type(Lg-1);
	Type u = (Lg-1)/Type(2);
	Type r = Lg/Type(8);
	t = linspace(a,b,Lg);
	Vector<Type> g = gauss(t,u,r);
	g = g/norm(g);

	/********************************* [ WFT ] *******************************/
	Type runtime = 0;
	Timing cnt;
	cout << "Taking windowed Fourier transform." << endl;
	cnt.start();
    Matrix< complex<Type> > coefs = wft( s, g );
	cnt.stop();
	runtime = cnt.read();
	cout << "The running time = " << runtime << " (ms)" << endl << endl;

	/******************************** [ IWFT ] *******************************/
	cout << "Taking inverse windowed Fourier transform." << endl;
	cnt.start();
	Vector<Type> x = iwft( coefs, g );
	cnt.stop();
	runtime = cnt.read();
	cout << "The running time = " << runtime << " (ms)" << endl << endl;

	cout << "The relative error is : " << "norm(s-x) / norm(s) = "
		 << norm(s-x)/norm(s) << endl << endl;

	return 0;
}
开发者ID:Holdlen2DH,项目名称:tspl,代码行数:40,代码来源:wft_test.cpp

示例3: main

int main()
{

	/******************************* [ signal ] ******************************/
	Vector<double> t = linspace( 0.0, (Ls-1)/fs, Ls );
	Vector<double> st = sin( 200*PI*pow(t,2.0) );
	st = st-mean(st);

	/******************************** [ CWT ] ********************************/
	Matrix< complex<double> > coefs;
	CWT<double> wavelet("morlet");
	wavelet.setScales( fs, fs/Ls, fs/2 );
	Timing cnt;
	double runtime = 0.0;
	cout << "Taking continuous wavelet transform(Morlet)." << endl;
	cnt.start();
	coefs = wavelet.cwtC(st);
	cnt.stop();
	runtime = cnt.read();
	cout << "The running time = " << runtime << " (ms)" << endl << endl;

	/******************************** [ ICWT ] *******************************/
	cout << "Taking inverse continuous wavelet transform." << endl;
	cnt.start();
	Vector<double> xt = wavelet.icwtC(coefs);
	cnt.stop();
	runtime = cnt.read();
	cout << "The running time = " << runtime << " (ms)" << endl << endl;

	cout << "The relative error is : " << endl;
	cout << "norm(st-xt) / norm(st) = " << norm(st-xt)/norm(st) << endl;
	cout << endl << endl;


    /******************************* [ signal ] ******************************/
    Vector<float> tf = linspace( float(0.0), (Ls-1)/float(fs), Ls );
	Vector<float> stf = sin( float(200*PI) * pow(tf,float(2.0) ) );
	stf = stf-mean(stf);

	/******************************** [ CWT ] ********************************/
	CWT<float> waveletf("mexiHat");
	waveletf.setScales( float(fs), float(fs/Ls), float(fs/2), float(0.25) );
	runtime = 0.0;
	cout << "Taking continuous wavelet transform(Mexican Hat)." << endl;
	cnt.start();
	Matrix<float> coefsf = waveletf.cwtR(stf);
	cnt.stop();
	runtime = cnt.read();
	cout << "The running time = " << runtime << " (ms)" << endl << endl;

	/******************************** [ ICWT ] *******************************/
	cout << "Taking inverse continuous wavelet transform." << endl;
	cnt.start();
	Vector<float> xtf = waveletf.icwtR(coefsf);
	cnt.stop();
	runtime = cnt.read();
	cout << "The running time = " << runtime << " (ms)" << endl << endl;

	cout << "The relative error is : " << endl;
	cout << "norm(st-xt) / norm(st) = " << norm(stf-xtf)/norm(stf) << endl << endl;

	return 0;
}
开发者ID:Holdlen2DH,项目名称:tspl,代码行数:63,代码来源:cwt_test.cpp

示例4: now

 static inline Timing now() {
   Timing t;
   t.start();
   return t;
 }
开发者ID:PeterZs,项目名称:3D_Pose_Estimation_CVPR2016,代码行数:5,代码来源:timing.hpp

示例5: main

int main(int argc, char* argv[]){

    // Initialize MPI
    // Find out my identity in the default communicator
    MPI_Init(&argc, &argv);
    int rank;
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);

    //used to store the final results
    std::vector<result_t> finalResults;
    //init the k value
    int k = 0;

    if(argc > 1){
        try{
            k = atoi(argv[1]);
            if(k < 0){
                throw "just need to throw a random exception to catch`";
            }
        }
        catch(...){
            std::cerr<<"k must be a positive integer"<<std::endl;
            return 0;
        }

    }

    //init the custom openmpi datatype
    MPI_Datatype ResultMpiType;
    //wrapper function to set up the custom type
    createMPIResultStruct(&ResultMpiType);




    // Master
    if (rank == 0){
        // ++++++++++++++++++++++++++++++
        // Master process
        // ++++++++++++++++++++++++++++++

        // check the arugmumants
        if (argc < 2){
            std::cout << "Usage: " << argv[0] << " [k value] [directory path:default(/cluster)]" << std::endl;
            return 0;
        }

        std::string folderPath;

        //set the default for the folder to use
        if(argc == 2){
            folderPath = "/cluster";
        }
        else{
            folderPath = argv[2];
        }


        Directory dir;

        if(!dir.set_path(folderPath)){
            std::cerr<<"Directory either not found or not a directory"<<std::endl;
            return 0;
        }


        //test for a correct k value
        try{
            k = atoi(argv[1]);
            if(k < 0){
                throw "just need to throw a random exception to catch`";
            }
        }
        catch(...){
            std::cerr<<"k must be a positive integer"<<std::endl;
            return 0;
        }

        auto test = dir.get_files();
        searchVector_t searchVector;
        Timing wallClock;
        double timeResults[NUM_TIME_RESULTS];

        //initlize timing holder
        for(int i = 0; i < NUM_TIME_RESULTS; i++){
            timeResults[i] = 0;
        }

        wallClock.start();
        //get the first vector the first file in the the directory as the search vector
        if(!getFirstVector(test.at(0),&searchVector)){
            std::cerr << "Couldn't get the search vector" << std::endl;
            return 0;
        }
        std::cout << "Sending work to workers" << std::endl;
        sendWork(test,&ResultMpiType,k,&finalResults,searchVector.data,timeResults);



        //wait for the workers to finish to collect the results
//.........这里部分代码省略.........
开发者ID:samkreter,项目名称:Distributed-Vector-Distance-Calculator,代码行数:101,代码来源:main.cpp

示例6: doWork

int doWork(MPI_Datatype* ResultMpiType,const int k){

    int rank;
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    int MAX_RESULT_SIZE = k;

    char msg[MAX_MSG_SIZE];
    float cmpData[SEARCH_VECTOR_SIZE];
    double times[2];
    MPI_Status status;
    Timing parserTime;
    Timing searchTime;
    Timing workWallTime;

    workWallTime.start();
    std::chrono::duration<double> read_time_elapse;

    MPI_Recv(cmpData,
        SEARCH_VECTOR_SIZE,
        MPI_FLOAT,
        0,
        MPI_ANY_TAG,
        MPI_COMM_WORLD,
        &status);

    if(status.MPI_TAG != SEARCH_VECTOR){
        std::cout<< rank << " recieved terminate signal" << std::endl;
            return 0;
    }


    while (1) {
        // Receive a message from the master
        MPI_Recv(msg,           /* message buffer */
            MAX_MSG_SIZE,     /* buffer size */
            MPI_CHAR,       /* data item is an integer */
            0,              /* Receive from master */
            MPI_ANY_TAG,
                MPI_COMM_WORLD,     /* default communicator */
                &status);


        // Check if we have been terminated by the master
        // exit from the worker loop
        if (status.MPI_TAG == TERMINATE) {
            std::cout<< rank << " recieved terminate signal" << std::endl;
            return 0;
        }


        std::shared_ptr<MapString_t> nameMap(new MapString_t);
        std::vector<result_t> results;
        std::shared_ptr<std::vector<float>> dataVector(new std::vector<float>);
        Parser p(nameMap,dataVector);

        parserTime.start();
        if(!p.parse_file(msg,&read_time_elapse)){
            std::cerr<<"could not parse file: "<<msg<<std::endl;
            return 0;
        }
        parserTime.end();
        searchTime.start();
        int lineLength = p.get_line_length();
        int index = 0;
        for(auto& file : *nameMap){
            results.push_back(result_t());
            results.at(index).distance = findDist(lineLength,
                dataVector,file.second,cmpData);
            strcpy(results.at(index).fileName,file.first.c_str());
            index++;
        }


        std::sort(results.begin(),results.end(),resultPairSort);


        results.resize(MAX_RESULT_SIZE);

        searchTime.end();

        MPI_Send(results.data(),           /* message buffer */
             MAX_RESULT_SIZE,         /* buffer size */
             *ResultMpiType,              /* data item is an integer */
             0,                     /* destination process rank, the master */
             RESULTS,             /* user chosen message tag */
             MPI_COMM_WORLD);

        workWallTime.end();

        //add the times to an array to be sent to the master
        times[0] = parserTime.get_elapse();
        times[1] = searchTime.get_elapse();
        times[2] = workWallTime.get_elapse();

        //send out the timing results to be compiled
        MPI_Send(times,
            NUM_TIME_RESULTS,
            MPI_DOUBLE,
            0,
            TIMING,
//.........这里部分代码省略.........
开发者ID:samkreter,项目名称:Distributed-Vector-Distance-Calculator,代码行数:101,代码来源:main.cpp

示例7: main

void main(void)
{
	int i, k;
	Timing watch;
	Point3D mid, ext;

	float cubeHalfSide = 100.0f; 
	float minSphereRadius; 
	float minHalfBoxExtent; 
	float maxSphereRadius;  
	float maxHalfBoxExtent; 

	// Note: Change the value of 'testCase' in [0, 4] to vary 
	// the number of overlaps in the generated test data.
	int testCase = 0;

	switch (testCase) {
		case 0:
			minSphereRadius = 1.0f;
			minHalfBoxExtent = 1.0f;
			maxSphereRadius = 32.5f;
			maxHalfBoxExtent = 32.5f;
			break;
		case 1:
			minSphereRadius = 1.0f;
			minHalfBoxExtent = 1.0f;			
			maxSphereRadius = 55.0f;
			maxHalfBoxExtent = 55.0f;
			break;
		case 2:
			minSphereRadius = 1.0f;
			minHalfBoxExtent = 1.0f;
			maxSphereRadius = 77.5f;
			maxHalfBoxExtent = 77.5f;
			break;
		case 3:
			minSphereRadius = 13.5f;
			minHalfBoxExtent = 13.5f;
			maxSphereRadius = 85.0f;
			maxHalfBoxExtent = 85.0f;
			break;
		case 4:
			minSphereRadius = 28.0f;
			minHalfBoxExtent = 28.0f;
			maxSphereRadius = 99.0f;
			maxHalfBoxExtent = 99.0f;
			break;
		default:
			minSphereRadius = 1.0f;
			minHalfBoxExtent = 1.0f;
			maxSphereRadius = 10.0f;
			maxHalfBoxExtent = 10.0f;
	}

	for (i = 0; i < NUMBER_OF_BV_PAIRS; i++) {
		sphereArray[i].r = getRandomScalar(minSphereRadius, maxSphereRadius);
		
		sphereArray[i].c.x = getRandomScalar(-cubeHalfSide + sphereArray[i].r, cubeHalfSide - sphereArray[i].r);
		sphereArray[i].c.y = getRandomScalar(-cubeHalfSide + sphereArray[i].r, cubeHalfSide - sphereArray[i].r);
		sphereArray[i].c.z = getRandomScalar(-cubeHalfSide + sphereArray[i].r, cubeHalfSide - sphereArray[i].r);
		
		ext.x = getRandomScalar(minHalfBoxExtent, maxHalfBoxExtent);
		ext.y = getRandomScalar(minHalfBoxExtent, maxHalfBoxExtent);
		ext.z = getRandomScalar(minHalfBoxExtent, maxHalfBoxExtent);
		
		mid.x = getRandomScalar(-cubeHalfSide + ext.x, cubeHalfSide - ext.x);
		mid.y = getRandomScalar(-cubeHalfSide + ext.y, cubeHalfSide - ext.y);
		mid.z = getRandomScalar(-cubeHalfSide + ext.z, cubeHalfSide - ext.z);

		boxArray[i].min.x = mid.x - ext.x;
		boxArray[i].min.y = mid.y - ext.y;
		boxArray[i].min.z = mid.z - ext.z;
		boxArray[i].max.x = mid.x + ext.x;
		boxArray[i].max.y = mid.y + ext.y;
		boxArray[i].max.z = mid.z + ext.z;
	}

	/* ==== Method 1 ==== */
	noOverlaps[0] = 0;
	watch.start();
	for (k=0; k < REPETITIONS; k++) {		
		for (i = 0; i < NUMBER_OF_BV_PAIRS; i++) {
			noOverlaps[0] += overlapSphereAABB_Arvo(sphereArray[i], boxArray[i]);
		}
	}
	time[0] = watch.stop() / REPETITIONS;
	noOverlaps[0] /= REPETITIONS;
	printResult(algorithmName[0], noOverlaps[0], time[0]);

	/* ==== Method 2 ==== */
	noOverlaps[1] = 0;
	watch.start();
	for (k=0; k < REPETITIONS; k++) {		
		for (i = 0; i < NUMBER_OF_BV_PAIRS; i++) {
			noOverlaps[1] += overlapSphereAABB_QRI(sphereArray[i], boxArray[i]);
		}
	}
	time[1] = watch.stop() / REPETITIONS;
	noOverlaps[1] /= REPETITIONS;
	printResult(algorithmName[1], noOverlaps[1], time[1]);
//.........这里部分代码省略.........
开发者ID:erich666,项目名称:jgt-code,代码行数:101,代码来源:benchmarkOverlapSphereAABB.cpp


注:本文中的Timing::start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。