Wink Saville’s Blog

December 10, 2007

Android – faster, easier Log class.

Filed under: Android,programming — wink @ 10:01 pm

The log class seems quite nice, so I started a work-a-like, turns out that taking advantage of variable number of parameter syntax makes it easier and faster. I suspect it will grow significantly over time:

package com.saville.debug.android;

public final class Log {

	/**
	 * Log verbosely.
	 *
	 * On the android emulator this:
	 *      Log.v(TAG, "onCreate: dispatchInvoke dur=%fs rate=%f/s", dur, (count / dur));
	 * was 5 times faster than this:
	 *      Log.v(TAG, "onCreate: dispatchDirect dur=" + dur + "s rate=" + (count / dur) + "/s");
	 * The former took 0.005secs and the later about 0.02secs
	 *
	 * @param tag	Identification
	 * @param fmt	Format string as in printf
	 * @param args	Variable number of arguments
	 */
	public static void v(String tag, String fmt, Object... args) {
		android.util.Log.v(tag, String.format(fmt, args));
	}
}

No Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment

Powered by WordPress