7 #include <sys/resource.h>
9 #include "opensrf/utils.h"
10 #include "opensrf/osrf_json.h"
12 struct timeval diff_timeval( const struct timeval * begin,
13 const struct timeval * end );
15 static const char sample_json[] =
16 "{\"menu\": {\"id\": \"file\", \"value\": \"File\","
17 "\"popup\": { \"menuitem\": [ {\"value\": \"New\", "
18 "\"onclick\": \"CreateNewDoc()\"},"
19 "{\"value\": \"Open\", \"onclick\": \"OpenDoc()\"}, "
20 "{\"value\": \"Close\", \"onclick\": \"CloseDoc()\"}]}}}";
25 struct timezone tz = { 240, 1 };
26 struct timeval begin_timeval;
27 struct timeval end_timeval;
29 gettimeofday( &begin_timeval, &tz );
32 jsonObject * pObj = NULL;
34 for( i = 10000000; i; --i )
36 // pObj = jsonParseString( sample_json );
37 pObj = jsonNewObject( NULL );
38 jsonObject * p1 = jsonNewObject( NULL );
39 jsonObject * p2 = jsonNewObject( NULL );
42 jsonObjectFree( pObj );
45 jsonObjectFreeUnused();
47 gettimeofday( &end_timeval, &tz );
49 struct timeval elapsed = diff_timeval( &begin_timeval, &end_timeval );
51 printf( "Elapsed time: %ld seconds, %ld microseconds\n",
52 (long) elapsed.tv_sec, (long) elapsed.tv_usec );
55 if( getrlimit( RLIMIT_DATA, &rlim ) )
56 printf( "Error calling getrlimit\n" );
58 printf( "Address space: %lu\n", (unsigned long) rlim.rlim_cur );
65 struct timeval diff_timeval( const struct timeval * begin, const struct timeval * end )
69 diff.tv_sec = end->tv_sec - begin->tv_sec;
70 diff.tv_usec = end->tv_usec - begin->tv_usec;
72 if( diff.tv_usec < 0 )
74 diff.tv_usec += 1000000;