ITK/Examples/Utilities/TimeProbe

From KitwarePublic
< ITK‎ | Examples
Revision as of 15:21, 11 January 2011 by Daviddoria (talk | contribs) (Created page with "==TimeProbe.cxx== <source lang="cpp"> #include "itkTimeProbe.h" #include <iostream> #include <string> void LongFunction(); int main(int, char *[]) { itk::TimeProbe clock; ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

TimeProbe.cxx

<source lang="cpp">

  1. include "itkTimeProbe.h"
  1. include <iostream>
  2. include <string>

void LongFunction();

int main(int, char *[]) {

 itk::TimeProbe clock;
 
 clock.Start();
 LongFunction();
 clock.Stop();
 std::cout << "Mean: " << clock.GetMean() << std::endl;
 std::cout << "Total: " << clock.GetTotal() << std::endl;
 clock.Start();
 LongFunction();
 clock.Stop();
 std::cout << "Mean: " << clock.GetMean() << std::endl;
 std::cout << "Total: " << clock.GetTotal() << std::endl;
 return EXIT_SUCCESS;

}

void LongFunction() {

 for(int i = 0; i < 1e8; i++)
 {
   double a = 0;
 }

} </source>

CMakeLists.txt

<source lang="cmake"> cmake_minimum_required(VERSION 2.6)

PROJECT(TimeProbe)

FIND_PACKAGE(ITK REQUIRED) INCLUDE(${ITK_USE_FILE})

ADD_EXECUTABLE(TimeProbe TimeProbe.cxx) TARGET_LINK_LIBRARIES(TimeProbe ITKIO)

</source>