Berkeley SfM
Public Types | Public Member Functions | Private Attributes | List of all members
bsfm::util::Timer Class Reference

#include <timer.h>

Public Types

typedef std::chrono::high_resolution_clock Clock
 

Public Member Functions

 Timer ()
 
 ~Timer ()
 
double Tic ()
 
double Ptic (const std::string &prefix=std::string())
 
double Toc ()
 
double Ptoc (const std::string &prefix=std::string())
 

Private Attributes

Clock::time_point start_
 

Detailed Description

Definition at line 56 of file timer.h.

Member Typedef Documentation

typedef std::chrono::high_resolution_clock bsfm::util::Timer::Clock

Definition at line 58 of file timer.h.

Constructor & Destructor Documentation

bsfm::util::Timer::Timer ( )

Definition at line 45 of file timer.cpp.

45  {
46  Tic();
47 }
double Tic()
Definition: timer.cpp:52
bsfm::util::Timer::~Timer ( )

Definition at line 49 of file timer.cpp.

49 {}

Member Function Documentation

double bsfm::util::Timer::Ptic ( const std::string &  prefix = std::string())

Definition at line 59 of file timer.cpp.

59  {
60  start_ = Clock::now();
61 
62  if (!prefix.empty()) {
63  fputs(prefix.c_str(), stdout);
64  printf(": ");
65  }
66 
67  double start_double =
68  duration_cast<nanoseconds>(start_.time_since_epoch()).count() * 1e-9;
69  printf("Begin: %lf (s)\n", start_double);
70  return start_double;
71 }
Clock::time_point start_
Definition: timer.h:77
double bsfm::util::Timer::Ptoc ( const std::string &  prefix = std::string())

Definition at line 79 of file timer.cpp.

79  {
80  if (!prefix.empty()) {
81  fputs(prefix.c_str(), stdout);
82  printf(": ");
83  }
84 
85  Clock::duration elapsed = Clock::now() - start_;
86  double elapsed_double = duration_cast<nanoseconds>(elapsed).count() * 1e-9;
87 
88  printf("Elapsed: %lf (s)\n", elapsed_double);
89  return elapsed_double;
90 }
Clock::time_point start_
Definition: timer.h:77
double bsfm::util::Timer::Tic ( )

Definition at line 52 of file timer.cpp.

52  {
53  start_ = Clock::now();
54  double start_double =
55  duration_cast<nanoseconds>(start_.time_since_epoch()).count() * 1e-9;
56  return start_double;
57 }
Clock::time_point start_
Definition: timer.h:77
double bsfm::util::Timer::Toc ( )

Definition at line 73 of file timer.cpp.

73  {
74  Clock::duration elapsed = Clock::now() - start_;
75  double elapsed_double = duration_cast<nanoseconds>(elapsed).count() * 1e-9;
76  return elapsed_double;
77 }
Clock::time_point start_
Definition: timer.h:77

Member Data Documentation

Clock::time_point bsfm::util::Timer::start_
private

Definition at line 77 of file timer.h.


The documentation for this class was generated from the following files: