Real-Time API Revision2025.2-0
Loading...
Searching...
No Matches
Time stamp via TSC utility routines.
Collaboration diagram for Time stamp via TSC utility routines.:

Functions

int getCpuTicks ()
int ccurTSC_printf (const char *fmt,...)
int ccurTSC_fprintf (FILE *fp, const char *fmt,...)

Detailed Description

This API is used by program running on the Real-Time host to print messages prefixed with a TSC time stamp.
The time stamp is consistent across all processes running under SimWB.

Function Documentation

◆ getCpuTicks()

int getCpuTicks ( )

Get the speed of the system so we can convert TSC ticks to micro seconds.
Warning: this function is non deterministic since it reads the /proc file system to get the CPU speed. Use the macro _rdtsc() defined in tscutils.h to get the TSC count.
To time a secion of code you would use:

int cputicks = getCpuTicks();
unsigned long long t1;
t1 = _rdtsc();
.
.
Your code here
.
.
t2 = _rdtsc();
usec = (t2-t1)/cputicks; // usec will be the time elapsed in micro seconds
int getCpuTicks()
Definition tscutils.c:121
Returns
System speed in MHz.

◆ ccurTSC_printf()

int ccurTSC_printf ( const char * fmt,
... )

Print to stderr a la printf and prefix with a TSC time stamp

Parameters
fmtString with format specifier.
Returns
The length of the string that was printed.

◆ ccurTSC_fprintf()

int ccurTSC_fprintf ( FILE * fp,
const char * fmt,
... )

Print to file pointer fp a la printf and prefix with a TSC time stamp

Parameters
fpFILE pointer. The file must have been open with a 'C' fp = fopen(filename,"w") prior to this call
fmtString with format specifier.
Returns
The length of the string that was printed.