SIMulation Workbench Documentation SIMulation Workbench Documentation

Time stamp via TSC utility routines.
[SimWB RT functions]

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

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
Returns:
System speed in MHz.
int ccurTSC_printf ( const char *  fmt,
  ... 
)

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

Parameters:
fmt String with format specifier.
Returns:
The length of the string that was printed.
int ccurTSC_fprintf ( FILE *  fp,
const char *  fmt,
  ... 
)

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

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