
var profView = null;

// sets up things we want to profile
function perfView() {
	if( !profView )
	{
		var viewConfig = {visible : true};
		var skipList = ['logDuration', 'perfView', 'recurseProtoPerf'];
		var protoList = [TripDisplay, Filter, FilterGroup, Array];
		
		// register all global functions
		if( !Prototype.Browser.IE )
			YAHOO.tool.Profiler.registerObject("", window, false);
		else
		{
			// work around IE being unable to enumerate functions in global space
			var globFn, winRef;
			var globFuns = globalVars.getOwn();
			var addList = ['$', '$$', '$A', '$F', '$H', '$R', '$w'];
			for( globFn in globFuns)
			{
					if( window[globFn] )
						YAHOO.tool.Profiler.registerFunction( globFn, window );
			}
			addList.each(function(fn){ YAHOO.tool.Profiler.registerFunction(fn, window); });
		}
		
		// things to remove from profiling
		skipList.each(function(fn){ if (window[fn]) YAHOO.tool.Profiler.unregisterFunction((Prototype.Browser.IE ? "" : ".")+fn); });
		
		// more explicit things to profile in all browsers
		protoList.each(recurseProtoPerf, window);
		YAHOO.tool.Profiler.registerFunction('toString', Object);
		YAHOO.tool.Profiler.registerObject('Element', Element, false);
//		YAHOO.tool.Profiler.registerObject('Enumerable', Enumerable, true);
		
		profView = new YAHOO.widget.ProfilerViewer(null, viewConfig);	//, base: "/javascripts/yui/"}); 		
	}
}

// recursive function to profile prototypes of objects and all their subclasses
function recurseProtoPerf(obj)
{
	YAHOO.tool.Profiler.registerObject(obj.prototype.constructor.__yuiFuncName, obj.prototype, false);
	if( obj.prototype.constructor.subclasses )
		obj.prototype.constructor.subclasses.each(recurseProtoPerf);
}

// turn on YUI logging to console
YAHOO.widget.Logger.enableBrowserConsole();
