\hypertarget{TMR_8h}{
\section{TMR.h File Reference}
\label{TMR_8h}\index{TMR.h@{TMR.h}}
}
Provides a set of timing macros.  


{\tt \#include $<$IPBS/PTS.h$>$}\par
\subsection*{Classes}
\begin{CompactItemize}
\item 
struct \hyperlink{struct__TMR__usecs__nsecs}{\_\-TMR\_\-usecs\_\-nsecs}
\begin{CompactList}\small\item\em Structure to hold the time in terms of two integers, one giving the number of micro-seconds, the other the number of milliseconds. \item\end{CompactList}\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\hypertarget{TMR_8h_993d7806a3b7782ff4e980090b4084f3}{
\#define \hyperlink{TMR_8h_993d7806a3b7782ff4e980090b4084f3}{TMR\_\-GET}()~PTS\_\-GETS()}
\label{TMR_8h_993d7806a3b7782ff4e980090b4084f3}

\begin{CompactList}\small\item\em Macro to get the processor time. \item\end{CompactList}\item 
\#define \hyperlink{TMR_8h_49fe4e1b2fa852d1527dbf7238be2a1a}{TMR\_\-TO\_\-NSECS}(\_\-ticks)~PTS\_\-PTUS\_\-TO\_\-NSECS(\_\-ticks)
\begin{CompactList}\small\item\em Convert a time processor time ticks to nanoseconds. \item\end{CompactList}\item 
\#define \hyperlink{TMR_8h_ec5331063c0af0f50122cfd74a9348be}{TMR\_\-DELTA}(\_\-beg, \_\-end)~PTS\_\-DELTAS(\_\-beg, \_\-end)
\begin{CompactList}\small\item\em Subtracts two times in ticks, returning the result in ticks. \item\end{CompactList}\item 
\#define \hyperlink{TMR_8h_ac2d2d48ceba55c9ff0af8322f48a62a}{TMR\_\-DELTA\_\-IN\_\-NSECS}(\_\-beg, \_\-end)~PTS\_\-DELTAS\_\-IN\_\-NSECS(\_\-beg, \_\-end)
\begin{CompactList}\small\item\em Subtracts two times in tickss, returning the result in nanoseconds. \item\end{CompactList}\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{TMR_8h_92b3fb94130d0b46fc2eb9dc7e3613e6}{
typedef unsigned int \hyperlink{TMR_8h_92b3fb94130d0b46fc2eb9dc7e3613e6}{TMR\_\-tick}}
\label{TMR_8h_92b3fb94130d0b46fc2eb9dc7e3613e6}

\begin{CompactList}\small\item\em The type of an elapsed unit of time. \item\end{CompactList}\item 
typedef struct \hyperlink{struct__TMR__usecs__nsecs}{\_\-TMR\_\-usecs\_\-nsecs} \hyperlink{TMR_8h_c010388d43ebd21be825b333fa73fb1c}{TMR\_\-usecs\_\-nsecs}
\begin{CompactList}\small\item\em Typedef for struct {\em \hyperlink{struct__TMR__usecs__nsecs}{\_\-TMR\_\-usecs\_\-nsecs}\/}. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
unsigned int \hyperlink{TMR_8h_9b4988b816b11598b4a31911aa0c4674}{TMR\_\-ticks\_\-to\_\-nsecs} (\hyperlink{TMR_8h_92b3fb94130d0b46fc2eb9dc7e3613e6}{TMR\_\-tick} ticks)
\begin{CompactList}\small\item\em Convert a number of ticks to nanoseconds. \item\end{CompactList}\item 
\hyperlink{struct__TMR__usecs__nsecs}{TMR\_\-usecs\_\-nsecs} \hyperlink{TMR_8h_0c948a71c49fe2020e6b261cf7b08963}{TMR\_\-ticks\_\-to\_\-usecs\_\-nsecs} (\hyperlink{TMR_8h_92b3fb94130d0b46fc2eb9dc7e3613e6}{TMR\_\-tick} ticks)
\begin{CompactList}\small\item\em Convert a number of ticks useconds.nanoseconds. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Provides a set of timing macros. 

\begin{Desc}
\item[Author:]JJRussell - \href{mailto:russell@slac.stanford.edu}{\tt russell@slac.stanford.edu}\end{Desc}


\footnotesize\begin{verbatim}
   CVS $Id: TMR.h,v 1.2 2011/03/25 21:15:03 saxton Exp $

\end{verbatim}
\normalsize


\begin{Desc}
\item[SYNPOSIS]This implements a facility to time accurately short duration events. The implementation is platform dependent, seeking to use the highest resolution clock that is available. The facility provides a uniform and consistent compile time interface. Note that this is not the same as a uniform and consistent run time interface. In particular the timer units may vary platform to platform. However, TMR\_\-get always returns an unsigned int, independent of the actual resolution.\end{Desc}
Finally, to keep the overhead low, consistent with timing short duration events, certain compromises where made. In general, do not use this facility to time events $>$ 4 secs. The normal system clocks should be used instead.

\begin{Desc}
\item[USAGE]

\begin{Code}\begin{verbatim}    TMR_tick     beg;
    TMR_tick     end;
    TMR_tick elapsed;
  
    beg     = TMR_GET();
    .
    eventToTime ();
    .
    end     = TMR_GET();
    elapsed = end - beg;
  
    printf ("Begin   Time: %8d ticks\n", beg);
    printf ("End     Time: %8d ticks\n", end);
    printf ("Elasped Time: %8d ticks\n", elapsed);
    printf ("Elasped Time: %8d"ticks\n", TMR_TO_NSECS (elapsed);
\end{verbatim}
\end{Code}

 \end{Desc}


\subsection{Define Documentation}
\hypertarget{TMR_8h_ec5331063c0af0f50122cfd74a9348be}{
\index{TMR.h@{TMR.h}!TMR\_\-DELTA@{TMR\_\-DELTA}}
\index{TMR\_\-DELTA@{TMR\_\-DELTA}!TMR.h@{TMR.h}}
\subsubsection[{TMR\_\-DELTA}]{\setlength{\rightskip}{0pt plus 5cm}\#define TMR\_\-DELTA(\_\-beg, \/  \_\-end)~PTS\_\-DELTAS(\_\-beg, \_\-end)}}
\label{TMR_8h_ec5331063c0af0f50122cfd74a9348be}


Subtracts two times in ticks, returning the result in ticks. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-beg}]The beginning time in processor timer ticks \item[{\em \_\-end}]The ending time in processor timer ticks \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The difference is processor timer ticks\end{Desc}
For many processor's, this is just a subtraction.two 32 or 64 bit integer. However, on some platforms, the time is returned in a structure and the subtraction is not quite as trivial. If this were C++, one would have overloaded the '-' operator, \hypertarget{TMR_8h_ac2d2d48ceba55c9ff0af8322f48a62a}{
\index{TMR.h@{TMR.h}!TMR\_\-DELTA\_\-IN\_\-NSECS@{TMR\_\-DELTA\_\-IN\_\-NSECS}}
\index{TMR\_\-DELTA\_\-IN\_\-NSECS@{TMR\_\-DELTA\_\-IN\_\-NSECS}!TMR.h@{TMR.h}}
\subsubsection[{TMR\_\-DELTA\_\-IN\_\-NSECS}]{\setlength{\rightskip}{0pt plus 5cm}\#define TMR\_\-DELTA\_\-IN\_\-NSECS(\_\-beg, \/  \_\-end)~PTS\_\-DELTAS\_\-IN\_\-NSECS(\_\-beg, \_\-end)}}
\label{TMR_8h_ac2d2d48ceba55c9ff0af8322f48a62a}


Subtracts two times in tickss, returning the result in nanoseconds. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-beg}]The beginning time in processor timer ticks \item[{\em \_\-end}]The ending time in processor timer ticks \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The difference is nanoseconds \end{Desc}
\hypertarget{TMR_8h_49fe4e1b2fa852d1527dbf7238be2a1a}{
\index{TMR.h@{TMR.h}!TMR\_\-TO\_\-NSECS@{TMR\_\-TO\_\-NSECS}}
\index{TMR\_\-TO\_\-NSECS@{TMR\_\-TO\_\-NSECS}!TMR.h@{TMR.h}}
\subsubsection[{TMR\_\-TO\_\-NSECS}]{\setlength{\rightskip}{0pt plus 5cm}\#define TMR\_\-TO\_\-NSECS(\_\-ticks)~PTS\_\-PTUS\_\-TO\_\-NSECS(\_\-ticks)}}
\label{TMR_8h_49fe4e1b2fa852d1527dbf7238be2a1a}


Convert a time processor time ticks to nanoseconds. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-ticks}]The value to convert \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The converted value \end{Desc}


Referenced by TMR\_\-ticks\_\-to\_\-nsecs(), and TMR\_\-ticks\_\-to\_\-usecs\_\-nsecs().

\subsection{Typedef Documentation}
\hypertarget{TMR_8h_c010388d43ebd21be825b333fa73fb1c}{
\index{TMR.h@{TMR.h}!TMR\_\-usecs\_\-nsecs@{TMR\_\-usecs\_\-nsecs}}
\index{TMR\_\-usecs\_\-nsecs@{TMR\_\-usecs\_\-nsecs}!TMR.h@{TMR.h}}
\subsubsection[{TMR\_\-usecs\_\-nsecs}]{\setlength{\rightskip}{0pt plus 5cm}{\bf TMR\_\-usecs\_\-nsecs}}}
\label{TMR_8h_c010388d43ebd21be825b333fa73fb1c}


Typedef for struct {\em \hyperlink{struct__TMR__usecs__nsecs}{\_\-TMR\_\-usecs\_\-nsecs}\/}. 

\begin{Desc}
\item[Usage]This should be used for display purposes only. \end{Desc}


\subsection{Function Documentation}
\hypertarget{TMR_8h_9b4988b816b11598b4a31911aa0c4674}{
\index{TMR.h@{TMR.h}!TMR\_\-ticks\_\-to\_\-nsecs@{TMR\_\-ticks\_\-to\_\-nsecs}}
\index{TMR\_\-ticks\_\-to\_\-nsecs@{TMR\_\-ticks\_\-to\_\-nsecs}!TMR.h@{TMR.h}}
\subsubsection[{TMR\_\-ticks\_\-to\_\-nsecs}]{\setlength{\rightskip}{0pt plus 5cm}unsigned int TMR\_\-ticks\_\-to\_\-nsecs ({\bf TMR\_\-tick} {\em ticks})}}
\label{TMR_8h_9b4988b816b11598b4a31911aa0c4674}


Convert a number of ticks to nanoseconds. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ticks}]The number of ticks to convert to nanoseconds \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The number of equivalent nanoseconds \end{Desc}


References TMR\_\-TO\_\-NSECS.\hypertarget{TMR_8h_0c948a71c49fe2020e6b261cf7b08963}{
\index{TMR.h@{TMR.h}!TMR\_\-ticks\_\-to\_\-usecs\_\-nsecs@{TMR\_\-ticks\_\-to\_\-usecs\_\-nsecs}}
\index{TMR\_\-ticks\_\-to\_\-usecs\_\-nsecs@{TMR\_\-ticks\_\-to\_\-usecs\_\-nsecs}!TMR.h@{TMR.h}}
\subsubsection[{TMR\_\-ticks\_\-to\_\-usecs\_\-nsecs}]{\setlength{\rightskip}{0pt plus 5cm}{\bf TMR\_\-usecs\_\-nsecs} TMR\_\-ticks\_\-to\_\-usecs\_\-nsecs ({\bf TMR\_\-tick} {\em ticks})}}
\label{TMR_8h_0c948a71c49fe2020e6b261cf7b08963}


Convert a number of ticks useconds.nanoseconds. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ticks}]The number of ticks to convert \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The number of equivalent useconds, nanoseconds \end{Desc}


References \_\-TMR\_\-usecs\_\-nsecs::nsecs, TMR\_\-TO\_\-NSECS, and \_\-TMR\_\-usecs\_\-nsecs::usecs.