1 /* timing.c - timing bdb2 backend */
10 #include <ac/unistd.h>
13 #include "back-bdb2.h"
17 bdb2i_elapsed( struct timeval firsttime, struct timeval secondtime )
19 long int elapsedmicrosec, elapsedsec;
20 char elapsed_string[BUFSIZ];
22 elapsedsec = secondtime.tv_sec - firsttime.tv_sec;
23 elapsedmicrosec = secondtime.tv_usec - firsttime.tv_usec;
24 if(elapsedmicrosec < 0) {
25 elapsedmicrosec += 1000000;
29 sprintf( elapsed_string, "%ld.%.6ld", elapsedsec, elapsedmicrosec );
30 return( ch_strdup( elapsed_string ));
35 bdb2i_uncond_start_timing(
39 gettimeofday( time1, NULL );
44 bdb2i_uncond_stop_timing(
58 gettimeofday( &time2, NULL);
59 elapsed_time = bdb2i_elapsed( time1, time2 );
61 if ( conn != NULL ) sprintf( buf, "conn=%d ", conn->c_connid );
62 if ( op != NULL ) sprintf( buf, "%sop=%d ", buf, op->o_opid );
64 Debug( level, "%s%s elapsed=%s\n", buf, func, elapsed_time );