]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb2/timing.c
Backout the input exhaustion change, it loops. Still looking for
[openldap] / servers / slapd / back-bdb2 / timing.c
1 /* timing.c - timing bdb2 backend */
2
3 #include "portable.h"
4
5 #include <stdio.h>
6
7 #include <ac/string.h>
8 #include <ac/time.h>
9 #include <ac/unistd.h>
10
11 #include "slap.h"
12 #include "back-bdb2.h"
13
14
15 static char *
16 bdb2i_elapsed( struct timeval firsttime,  struct timeval secondtime )
17 {
18     long int elapsedmicrosec, elapsedsec;
19     char elapsed_string[BUFSIZ];
20     
21     elapsedsec = secondtime.tv_sec - firsttime.tv_sec;
22     elapsedmicrosec = secondtime.tv_usec - firsttime.tv_usec;
23     if(elapsedmicrosec < 0) {
24         elapsedmicrosec += 1000000;
25         elapsedsec -= 1;
26     }
27
28     sprintf( elapsed_string, "%ld.%.6ld", elapsedsec, elapsedmicrosec );
29     return( ch_strdup( elapsed_string ));
30 }
31
32
33 void
34 bdb2i_uncond_start_timing(
35         struct timeval  *time1
36 )
37 {
38         gettimeofday( time1, NULL );
39 }
40
41
42 void
43 bdb2i_uncond_stop_timing(
44         struct timeval  time1,
45         char            *func,
46         Connection      *conn,
47         Operation       *op,
48         int             level
49 )
50 {
51         struct timeval  time2;
52         char            *elapsed_time;
53         char            buf[BUFSIZ];
54
55         *buf = '\0';
56
57         gettimeofday( &time2, NULL);
58         elapsed_time = bdb2i_elapsed( time1, time2 );
59
60         if ( conn != NULL ) sprintf( buf, "conn=%d ", conn->c_connid );
61         if ( op != NULL )   sprintf( buf, "%sop=%d ", buf, op->o_opid );
62
63         Debug( level, "%s%s elapsed=%s\n", buf, func, elapsed_time );
64
65         free( elapsed_time );
66
67 }
68
69