1999-02-06 00:23:03 +08:00
|
|
|
/* timing.c - timing bdb2 backend */
|
1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
1999-02-06 00:23:03 +08:00
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <ac/string.h>
|
1999-03-06 08:57:25 +08:00
|
|
|
#include <ac/time.h>
|
|
|
|
#include <ac/unistd.h>
|
1999-02-06 00:23:03 +08:00
|
|
|
|
|
|
|
#include "slap.h"
|
|
|
|
#include "back-bdb2.h"
|
|
|
|
|
|
|
|
|
1999-02-22 19:22:44 +08:00
|
|
|
static char *
|
1999-02-06 00:23:03 +08:00
|
|
|
bdb2i_elapsed( struct timeval firsttime, struct timeval secondtime )
|
|
|
|
{
|
|
|
|
long int elapsedmicrosec, elapsedsec;
|
|
|
|
char elapsed_string[BUFSIZ];
|
|
|
|
|
|
|
|
elapsedsec = secondtime.tv_sec - firsttime.tv_sec;
|
|
|
|
elapsedmicrosec = secondtime.tv_usec - firsttime.tv_usec;
|
|
|
|
if(elapsedmicrosec < 0) {
|
|
|
|
elapsedmicrosec += 1000000;
|
|
|
|
elapsedsec -= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf( elapsed_string, "%ld.%.6ld", elapsedsec, elapsedmicrosec );
|
1999-02-22 19:22:44 +08:00
|
|
|
return( ch_strdup( elapsed_string ));
|
1999-02-06 00:23:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-02-12 22:36:16 +08:00
|
|
|
void
|
1999-02-22 19:22:44 +08:00
|
|
|
bdb2i_uncond_start_timing(
|
1999-02-12 22:36:16 +08:00
|
|
|
struct timeval *time1
|
|
|
|
)
|
|
|
|
{
|
1999-02-22 19:22:44 +08:00
|
|
|
gettimeofday( time1, NULL );
|
1999-02-12 22:36:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
1999-02-22 19:22:44 +08:00
|
|
|
bdb2i_uncond_stop_timing(
|
1999-02-12 22:36:16 +08:00
|
|
|
struct timeval time1,
|
|
|
|
char *func,
|
|
|
|
Connection *conn,
|
1999-02-22 19:22:44 +08:00
|
|
|
Operation *op,
|
|
|
|
int level
|
1999-02-12 22:36:16 +08:00
|
|
|
)
|
|
|
|
{
|
1999-02-22 19:22:44 +08:00
|
|
|
struct timeval time2;
|
|
|
|
char *elapsed_time;
|
|
|
|
char buf[BUFSIZ];
|
1999-02-12 22:36:16 +08:00
|
|
|
|
1999-02-22 19:22:44 +08:00
|
|
|
*buf = '\0';
|
1999-02-12 22:36:16 +08:00
|
|
|
|
1999-02-22 19:22:44 +08:00
|
|
|
gettimeofday( &time2, NULL);
|
|
|
|
elapsed_time = bdb2i_elapsed( time1, time2 );
|
1999-02-12 22:36:16 +08:00
|
|
|
|
1999-02-22 19:22:44 +08:00
|
|
|
if ( conn != NULL ) sprintf( buf, "conn=%d ", conn->c_connid );
|
|
|
|
if ( op != NULL ) sprintf( buf, "%sop=%d ", buf, op->o_opid );
|
1999-02-12 22:36:16 +08:00
|
|
|
|
1999-02-22 19:22:44 +08:00
|
|
|
Debug( level, "%s%s elapsed=%s\n", buf, func, elapsed_time );
|
1999-02-12 22:36:16 +08:00
|
|
|
|
1999-02-22 19:22:44 +08:00
|
|
|
free( elapsed_time );
|
1999-02-12 22:36:16 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|