summaryrefslogtreecommitdiffstats
path: root/src/H5trace.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2020-08-15 00:16:11 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2020-08-15 00:16:11 (GMT)
commit62c296f1eb69255c5140a675270b11b5b265a220 (patch)
tree704a648065d1b20586457843958606b1ff37bb0f /src/H5trace.c
parent5a61eb24af840b45105f71da4ea4edc7062e24d9 (diff)
downloadhdf5-62c296f1eb69255c5140a675270b11b5b265a220.zip
hdf5-62c296f1eb69255c5140a675270b11b5b265a220.tar.gz
hdf5-62c296f1eb69255c5140a675270b11b5b265a220.tar.bz2
Brings monotonic timer changes from develop
Diffstat (limited to 'src/H5trace.c')
-rw-r--r--src/H5trace.c81
1 files changed, 50 insertions, 31 deletions
diff --git a/src/H5trace.c b/src/H5trace.c
index 93ff681..cf14565 100644
--- a/src/H5trace.c
+++ b/src/H5trace.c
@@ -15,7 +15,7 @@
*
* Created: H5trace.c
* Aug 21 2006
- * Quincey Koziol <koziol@hdfgroup.org>
+ * Quincey Koziol
*
* Purpose: Internal code for tracing API calls
*
@@ -125,8 +125,11 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
hssize_t i;
void *vp = NULL;
FILE *out = H5_debug_g.trace;
- H5_timer_t event_time;
- static H5_timer_t first_time = {0.0F, 0.0F, 0.0F};
+ static hbool_t is_first_invocation = TRUE;
+ H5_timer_t function_timer;
+ H5_timevals_t function_times;
+ static H5_timer_t running_timer;
+ H5_timevals_t running_times;
static int current_depth = 0;
static int last_call_depth = 0;
@@ -152,13 +155,18 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
} /* end else */
} /* end if */
- /* Get time for event */
- if(H5_DBL_ABS_EQUAL(first_time.etime, (double)0.0f))
- H5_timer_begin(&first_time);
- if(H5_debug_g.ttimes)
- H5_timer_begin(&event_time);
- else
- HDmemset(&event_time, 0, sizeof event_time);
+ /* Get time for event if the trace times flag is set */
+ if(is_first_invocation && H5_debug_g.ttimes) {
+ /* start the library-wide timer */
+ is_first_invocation = FALSE;
+ H5_timer_init(&running_timer);
+ H5_timer_start(&running_timer);
+ } /* end if */
+ if(H5_debug_g.ttimes) {
+ /* start the timer for this function */
+ H5_timer_init(&function_timer);
+ H5_timer_start(&function_timer);
+ } /* end if */
/* Print the first part of the line. This is the indication of the
* nesting depth followed by the function name and either start of
@@ -174,7 +182,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
if(H5_debug_g.ttimes) {
char tmp[320];
- HDsprintf(tmp, "%.6f", event_time.etime-first_time.etime);
+ H5_timer_get_times(function_timer, &function_times);
+ H5_timer_get_times(running_timer, &running_times);
+ HDsprintf(tmp, "%.6f", (function_times.elapsed - running_times.elapsed));
HDfprintf(out, " %*s ", (int)HDstrlen(tmp), "");
} /* end if */
for(i = 0; i < current_depth; i++)
@@ -189,8 +199,11 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
else {
if(current_depth>last_call_depth)
HDfputs(" = <delayed>\n", out);
- if(H5_debug_g.ttimes)
- HDfprintf(out, "@%.6f ", event_time.etime - first_time.etime);
+ if(H5_debug_g.ttimes) {
+ H5_timer_get_times(function_timer, &function_times);
+ H5_timer_get_times(running_timer, &running_times);
+ HDfprintf(out, "@%.6f ", (function_times.elapsed - running_times.elapsed));
+ } /* end if */
for(i = 0; i < current_depth; i++)
HDfputc('+', out);
HDfprintf(out, "%*s%s(", 2*current_depth, "", func);
@@ -296,7 +309,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'a':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -749,7 +762,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
break;
default:
- HDfprintf (out, "BADTYPE(D%c)", type[1]);
+ HDfprintf(out, "BADTYPE(D%c)", type[1]);
goto error;
} /* end switch */
break;
@@ -1095,7 +1108,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 's':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -1172,7 +1185,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
break;
default:
- HDfprintf (out, "BADTYPE(H%c)", type[1]);
+ HDfprintf(out, "BADTYPE(H%c)", type[1]);
goto error;
} /* end switch */
break;
@@ -1356,7 +1369,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
break;
case H5I_NTYPES:
- HDfprintf (out, "%ld (ntypes - error)", (long)obj);
+ HDfprintf(out, "%ld (ntypes - error)", (long)obj);
break;
default:
@@ -1460,7 +1473,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
else {
int is = HDva_arg(ap, int);
- HDfprintf (out, "%d", is);
+ HDfprintf(out, "%d", is);
asize[argno] = is;
} /* end else */
break;
@@ -1576,7 +1589,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
break;
default:
- HDfprintf (out, "BADTYPE(I%c)", type[1]);
+ HDfprintf(out, "BADTYPE(I%c)", type[1]);
goto error;
} /* end switch */
break;
@@ -1586,7 +1599,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'l':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -1730,7 +1743,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
else {
off_t offset = HDva_arg(ap, off_t);
- HDfprintf (out, "%ld", (long)offset);
+ HDfprintf(out, "%ld", (long)offset);
} /* end else */
break;
@@ -2394,7 +2407,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
break;
default:
- HDfprintf (out, "BADTYPE(T%c)", type[1]);
+ HDfprintf(out, "BADTYPE(T%c)", type[1]);
goto error;
} /* end switch */
break;
@@ -2410,9 +2423,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
htri_t tri_var = HDva_arg (ap, htri_t);
if(tri_var>0)
- HDfprintf (out, "TRUE");
+ HDfprintf(out, "TRUE");
else if(!tri_var)
- HDfprintf (out, "FALSE");
+ HDfprintf(out, "FALSE");
else
HDfprintf(out, "FAIL(%d)", (int)tri_var);
} /* end else */
@@ -2469,7 +2482,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
break;
default:
- HDfprintf (out, "BADTYPE(U%c)", type[1]);
+ HDfprintf(out, "BADTYPE(U%c)", type[1]);
goto error;
} /* end switch */
break;
@@ -2650,9 +2663,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
} /* end for */
/* Display event time for return */
- if(returning && H5_debug_g.ttimes)
- HDfprintf(out, " @%.6f [dt=%.6f]", (event_time.etime - first_time.etime),
- (event_time.etime - *returning));
+ if(returning && H5_debug_g.ttimes) {
+ H5_timer_get_times(function_timer, &function_times);
+ H5_timer_get_times(running_timer, &running_times);
+ HDfprintf(out, " @%.6f [dt=%.6f]", (function_times.elapsed - running_times.elapsed),
+ (function_times.elapsed - *returning));
+ } /* end if */
error:
HDva_end(ap);
@@ -2660,10 +2676,13 @@ error:
HDfprintf(out, ";\n");
else {
last_call_depth = current_depth++;
- HDfprintf (out, ")");
+ HDfprintf(out, ")");
} /* end else */
HDfflush(out);
- return event_time.etime;
+ if(H5_debug_g.ttimes)
+ return function_times.elapsed;
+ else
+ return 0.0F;
} /* end H5_trace() */