Lucciefr
Lua code caving, injection and exploration framework
Functions
timing.c File Reference

Timer / timestamp functions. More...

#include "timing.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>

Functions

double get_elapsed (void)
 return elapsed time in seconds (with a "high-resolution" fractional part!)
 
double get_elapsed_ms (void)
 return elapsed time in milliseconds (= 1000.0 * get_elapsed())
 
double get_timestamp (void)
 return high-resolution timestamp in seconds since the Epoch (1970-01-01 00:00:00 UTC) More...
 
size_t format_timestamp (char *buffer, size_t len, const char *format, double timestamp, bool local)
 convert timestamp to string with a given format More...
 

Detailed Description

Timer / timestamp functions.

For Windows, these are based on QueryPerformanceCounter. see MSDN: Acquiring high-resolution time stamps

Function Documentation

size_t format_timestamp ( char *  buffer,
size_t  len,
const char *  format,
double  timestamp,
bool  local 
)

convert timestamp to string with a given format

This function uses strftime() internally and accepts the same format specifiers, with one exception: A ".qqq" substring will get replaced with the milliseconds part of timestamp. The letter 'q' was chosen on purpose, because it's not a valid strftime() conversion specification.

double get_timestamp ( void  )
inline

return high-resolution timestamp in seconds since the Epoch (1970-01-01 00:00:00 UTC)

Note
There's no "timezone" / localtime() involved here, you'd have to adjust for that yourself. (This is desired, so our timestamps are UTC-based and not affected by local time zone or daylight savings transitions!)