add debug_timer_elapsed()
This commit is contained in:
@@ -21,6 +21,9 @@
|
|||||||
#include <br.h>
|
#include <br.h>
|
||||||
#include <bits.h>
|
#include <bits.h>
|
||||||
|
|
||||||
|
#define NANOSEC 1000000000 /* nano sec in sec */
|
||||||
|
#define MILLISEC 1000000 /* milli sec in sec */
|
||||||
|
|
||||||
#define _printf __attribute__ ((format (printf, 6, 7)))
|
#define _printf __attribute__ ((format (printf, 6, 7)))
|
||||||
|
|
||||||
#ifdef DEBUG_DEBUG
|
#ifdef DEBUG_DEBUG
|
||||||
@@ -29,6 +32,7 @@ void debug_init(uint level, FILE *stream, bool flush);
|
|||||||
void debug_level_set(uint level);
|
void debug_level_set(uint level);
|
||||||
uint debug_level_get(void);
|
uint debug_level_get(void);
|
||||||
void debug_stream_set(FILE *stream);
|
void debug_stream_set(FILE *stream);
|
||||||
|
long long debug_timer_elapsed(void);
|
||||||
void debug_flush_set(bool flush);
|
void debug_flush_set(bool flush);
|
||||||
void _printf debug(uint level, bool timestamp,
|
void _printf debug(uint level, bool timestamp,
|
||||||
uint indent, const char *src,
|
uint indent, const char *src,
|
||||||
@@ -41,6 +45,7 @@ static inline void debug_init(__unused uint level,
|
|||||||
static inline void debug_level_set(__unused uint level) {}
|
static inline void debug_level_set(__unused uint level) {}
|
||||||
static inline uint debug_level_get(void) {return 0;}
|
static inline uint debug_level_get(void) {return 0;}
|
||||||
static inline void debug_stream_set(__unused FILE *stream) {}
|
static inline void debug_stream_set(__unused FILE *stream) {}
|
||||||
|
static inline long long debug_timer_elapsed(void) {return 0LL};
|
||||||
static inline void debug_flush_set(__unused bool level) {}
|
static inline void debug_flush_set(__unused bool level) {}
|
||||||
static inline void _printf debug(__unused uint level, __unused bool timestamp,
|
static inline void _printf debug(__unused uint level, __unused bool timestamp,
|
||||||
__unused uint indent, __unused const char *src,
|
__unused uint indent, __unused const char *src,
|
||||||
|
@@ -22,9 +22,6 @@
|
|||||||
#include "bits.h"
|
#include "bits.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#define NANOSEC 1000000000 /* nano sec in sec */
|
|
||||||
#define MILLISEC 1000000 /* milli sec in sec */
|
|
||||||
|
|
||||||
static long long timer_start; /* in nanosecond */
|
static long long timer_start; /* in nanosecond */
|
||||||
static uint debug_level = 0;
|
static uint debug_level = 0;
|
||||||
static bool debug_flush = false;
|
static bool debug_flush = false;
|
||||||
@@ -83,7 +80,7 @@ void debug_init(uint level, FILE *_stream, bool flush)
|
|||||||
log(0, "timer started.\n");
|
log(0, "timer started.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static long long timer_elapsed()
|
long long debug_timer_elapsed(void)
|
||||||
{
|
{
|
||||||
struct timespec timer;
|
struct timespec timer;
|
||||||
|
|
||||||
@@ -111,7 +108,7 @@ void debug(uint level, bool timestamp, uint indent, const char *src,
|
|||||||
fprintf(stream, "%*s", 2*(indent-1), "");
|
fprintf(stream, "%*s", 2*(indent-1), "");
|
||||||
|
|
||||||
if (timestamp) {
|
if (timestamp) {
|
||||||
long long diff = timer_elapsed();
|
long long diff = debug_timer_elapsed();
|
||||||
fprintf(stream, "%lld.%03lld ", diff/NANOSEC, (diff/1000000)%1000);
|
fprintf(stream, "%lld.%03lld ", diff/NANOSEC, (diff/1000000)%1000);
|
||||||
fprintf(stream, "%010lld ", diff);
|
fprintf(stream, "%010lld ", diff);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user