testTic.cpp 1.93 KB
Newer Older
1
// ===================================================================================
2 3 4 5 6 7 8 9 10 11 12 13 14
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Bérenger Bramas, Matthias Messner
// olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// This software is a computer program whose purpose is to compute the FMM.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.  
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info". 
// "http://www.gnu.org/licenses".
15
// ===================================================================================
berenger-bramas's avatar
berenger-bramas committed
16
#include <iostream>
17
#include "../../Src/Utils/FTic.hpp"
berenger-bramas's avatar
berenger-bramas committed
18

19
#include <cstdlib>
berenger-bramas's avatar
berenger-bramas committed
20 21 22 23 24 25 26
#include <unistd.h>

/**
* Here we show an example of using FTic
*/

int main(){
27 28 29 30 31
    ///////////////////////What we do/////////////////////////////
    std::cout << ">> This executable is useless to execute.\n";
    std::cout << ">> It is only interesting to wath the code to understand\n";
    std::cout << ">> how to use FTic time counter.\n";
    //////////////////////////////////////////////////////////////
berenger-bramas's avatar
berenger-bramas committed
32
    {
berenger-bramas's avatar
berenger-bramas committed
33 34 35 36 37 38
	FTic counter;	
	counter.tic();
	usleep(1500000);
	//Sleep(1500); //on windows
	counter.tac();
	std::cout << counter.elapsed() << " (s)\n";
berenger-bramas's avatar
berenger-bramas committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
    }
    {
        FTic counter;
        usleep(1500000);
        //Sleep(1500); //on windows
        std::cout << counter.tacAndElapsed() << " (s)\n";
    }
    {
        FTic counter;
        usleep(1500000);
        //Sleep(1500); //on windows
        counter.tac();
        counter.tic();
        usleep(1500000);
        //Sleep(1500); //on windows
        std::cout << counter.tacAndElapsed() << " (s)\n";
        std::cout << counter.cumulated() << " (s)\n";
    }
    return 0;
berenger-bramas's avatar
berenger-bramas committed
58 59
}