Version: SMASH-1.5
smash::TimeStampCounter Class Reference

#include <tsc.h>

A low-overhead timer for benchmarking small regions of code.

This is usually unused in SMASH, because it should only be temporarily used when benchmarking.

Definition at line 40 of file tsc.h.

Collaboration diagram for smash::TimeStampCounter:
[legend]

Classes

union  Data
 Union that stores cycles,. More...
 

Public Member Functions

void start ()
 Start the counter. More...
 
void stop ()
 Stop the counter. More...
 
uint64_t cycles () const
 

Private Attributes

Data m_start
 Stores start of benchmarking. More...
 
Data m_end
 Stores end of benchmarking. More...
 

Member Function Documentation

◆ start()

void smash::TimeStampCounter::start ( )
inline

Start the counter.

Definition at line 65 of file tsc.h.

65  {
66 #ifdef VC_IMPL_MIC
67  asm volatile("xor %%eax,%%eax\n\tcpuid\n\trdtsc"
68  : "=a"(m_start.b[0]), "=d"(m_start.b[1])::"ebx", "ecx");
69 #elif defined _MSC_VER
70  unsigned int tmp;
71  m_start.a = __rdtscp(&tmp);
72 #else
73  asm volatile("rdtscp" : "=a"(m_start.b[0]), "=d"(m_start.b[1])::"ecx");
74 #endif
75 }
Data m_start
Stores start of benchmarking.
Definition: tsc.h:60
unsigned int b[2]
Or two 32-bit integers.
Definition: tsc.h:57
uint64_t a
Either one 64-bit integer.
Definition: tsc.h:55

◆ stop()

void smash::TimeStampCounter::stop ( )
inline

Stop the counter.

Definition at line 77 of file tsc.h.

77  {
78 #ifdef VC_IMPL_MIC
79  asm volatile("xor %%eax,%%eax\n\tcpuid\n\trdtsc"
80  : "=a"(m_end.b[0]), "=d"(m_end.b[1])::"ebx", "ecx");
81 #elif defined _MSC_VER
82  unsigned int tmp;
83  m_end.a = __rdtscp(&tmp);
84 #else
85  asm volatile("rdtscp" : "=a"(m_end.b[0]), "=d"(m_end.b[1])::"ecx");
86 #endif
87 }
Data m_end
Stores end of benchmarking.
Definition: tsc.h:62
unsigned int b[2]
Or two 32-bit integers.
Definition: tsc.h:57
uint64_t a
Either one 64-bit integer.
Definition: tsc.h:55

◆ cycles()

uint64_t smash::TimeStampCounter::cycles ( ) const
inline
Returns
Number of counted CPU cycles.

Definition at line 89 of file tsc.h.

89 { return m_end.a - m_start.a; }
Data m_start
Stores start of benchmarking.
Definition: tsc.h:60
Data m_end
Stores end of benchmarking.
Definition: tsc.h:62
uint64_t a
Either one 64-bit integer.
Definition: tsc.h:55
Here is the caller graph for this function:

Member Data Documentation

◆ m_start

Data smash::TimeStampCounter::m_start
private

Stores start of benchmarking.

Definition at line 60 of file tsc.h.

◆ m_end

Data smash::TimeStampCounter::m_end
private

Stores end of benchmarking.

Definition at line 62 of file tsc.h.


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