Hi,
I think it's better to use some macros to measure the time consume by
functions in Axis2/C. Then we can measure the time consume by each function
using these macros and it will help us to understand performance
bottlenecks. We can use following macros to measure the time taken by
function using CPU ticks. These macros will use RDTSC feature of x86
processors.
#define rdtsc(val) __asm__ __volatile__ ("rdtsc" : "=A" (val))
#ifdef AXIS2_TRACE
#define AXIS2_TIMETICKER_START(func, env) \
long long ts0,ts1; \
long elapse = 0; \
AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, \
"Start Time : %s", func); \
rdtsc(ts0);
#else
#define AXIS2_TIMETICKER_START(params, ...)
#endif
#ifdef AXIS2_TRACE
#define AXIS2_TIMETICKER_STOP(func, env) \
rdtsc(ts1); \
elapse = ts1 - ts0; \
AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, \
"End Time : %s Ticks: %d", func, elapse);
#else
#define AXIS2_TIMETICKER_START(params, ...)
#endif
Then we can use these macros to measure time taken by functions in following
way:
AXIS2_EXTERN axiom_stax_builder_t * AXIS2_CALL
axiom_stax_builder_create(const axis2_env_t *env,
axiom_xml_reader_t *parser)
{
axiom_stax_builder_impl_t *builder = NULL;
AXIS2_TIMETICKER_START("axiom_stax_builder_create", env);
..........
........
AXIS2_TIMETICKER_STOP("axiom_stax_builder_create", env);
return &(builder->om_stax_builder);
}
This method will log time taken by function if AXIS2_TRACE is defined.
Is there are any better ways to do this or any comments about this idea. I
have already test this method on Linux environment and it works fine.
Thanks,
Milinda
--
[EMAIL PROTECTED]
WSO2, Inc: http://www.wso2.com "Oxygenating the Web Service Platform"
Blog: http://www.milindalakmal.wordpress.com