Performance counter for measuring CPU cycles.  
 More...
#include <TNL/PerformanceCounters.h>
 | 
| 
  | PerformanceCounters () | 
|   | Constructor with no parameters. 
  | 
| unsigned long long int  | getCPUCycles () const | 
|   | Returns the number of CPU cycles (machine cycles) elapsed on this timer.  
  | 
| 
void  | reset () | 
|   | Reset counters. 
  | 
| void  | start () | 
|   | Starts counters.  
  | 
| 
void  | stop () | 
|   | Stops (pauses) the counters but do not set them to zeros. 
  | 
| bool  | writeLog (Logger &logger, int logLevel=0) const | 
|   | Writes a record into the logger.  
  | 
Performance counter for measuring CPU cycles. 
The counter can be paused by calling stop and start methods and reset by calling reset.
- Example
 #include <iostream>
#include <chrono>
#include <thread>
 
#include <TNL/PerformanceCounters.h>
 
int
main()
{
   const int milliseconds = 0.5e3;
   performanceCounters.
start();
 
   performanceCounters.
stop();
 
 
   performanceCounters.
reset();
 
}
  
- Output
 Elapsed CPU cycles: 1803151898
CPU cycles after reset: 0
  
 
◆ getCPUCycles()
  
  
      
        
          | unsigned long long int TNL::PerformanceCounters::getCPUCycles  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
inlinenodiscard   | 
  
 
Returns the number of CPU cycles (machine cycles) elapsed on this timer. 
CPU cycles are counted by adding the number of CPU cycles between start and stop methods together. 
 
 
◆ start()
  
  
      
        
          | void TNL::PerformanceCounters::start  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
inline   | 
  
 
Starts counters. 
This method can be used also after using the stop method. The counters then continue the measuring. 
 
 
◆ writeLog()
  
  
      
        
          | bool TNL::PerformanceCounters::writeLog  | 
          ( | 
          Logger & |           logger,  | 
         
        
           | 
           | 
          int |           logLevel = 0 ) const | 
         
       
   | 
  
inline   | 
  
 
Writes a record into the logger. 
- Parameters
 - 
  
    | logger | Name of Logger object.  | 
    | logLevel | A non-negative integer recording the log record indent. | 
  
   
- Example
 #include <iostream>
#include <chrono>
#include <thread>
 
#include <TNL/Timer.h>
#include <TNL/Logger.h>
 
int
main()
{
   const int milliseconds = 0.5e3;
   time.start();
   time.stop();
 
   time.writeLog( logger, 0 );
}
Creates calculations log in the form of a table.
Definition Logger.h:15
 
Class for real time, CPU time and CPU cycles measuring.
Definition Timer.h:25
 
  
- Output
 | Real time:                             0.500774 |
| CPU time:                               2.3e-05 |
  
 
 
The documentation for this struct was generated from the following files:
- src/TNL/PerformanceCounters.h
 
- src/TNL/PerformanceCounters.hpp