> From: sana qadir [mailto:[EMAIL PROTECTED] > Sent: 24 June 2008 05:40 > Subject: precision of log4j > I am using log4j to help me record the execution times of several > functions (1 to n) using code similar to the following snippet: > > logger.debug("Timestamp before..."); > function_n(); > logger.debug("Timestamp after...");
OK, Log4J isn't necessarily going to do what you want: if you want high resolution timings you can use System.nanoTime and to make the timings accurate, don't corrupt them by logging while you're timing... long t1 = System.nanoTime(); function_n(); long t2 = System.nanoTime(); logger.debug("duration in nanos: "+(t2 -t1)); Regards, Michael Erskine. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]