///start file generated from microprofile.html
#ifdef MICROPROFILE_EMBED_HTML
const char g_MicroProfileHtml_begin_0[] =
"<!DOCTYPE HTML>\n"
"<html>\n"
"<head>\n"
"<title>MicroProfile Capture</title>\n"
"<style>\n"
"/* about css: http://bit.ly/1eMQ42U */\n"
"body {margin: 0px;padding: 0px; font: 12px Courier New;background-color:#343434; color:white;overflow:hidden;}\n"
"ul {list-style-type: none;margin: 0;padding: 0;}\n"
"li{display: inline; float:left;border:5px; position:relative;text-align:center;}\n"
"a {\n"
"    float:left;\n"
"    text-decoration:none;\n"
"    display: inline;\n"
"    text-align: center;\n"
"	padding:5px;\n"
"	padding-bottom:0px;\n"
"	padding-top:0px;\n"
"    color: #FFFFFF;\n"
"    background-color: #343434;\n"
"}\n"
"a:hover, a:active{\n"
"	background-color: #000000;\n"
"}\n"
"\n"
"ul ul {\n"
"    position:absolute;\n"
"    left:0;\n"
"    top:100%;\n"
"    margin-left:-999em;\n"
"}\n"
"li:hover ul {\n"
"    margin-left:0;\n"
"    margin-right:0;\n"
"}\n"
"ul li ul{ display:block;float:none;width:100%;}\n"
"ul li ul li{ display:block;float:none;width:100%;}\n"
"li li a{ display:block;float:none;width:100%;text-align:left;}\n"
"#nav li:hover div {margin-left:0;}\n"
".help {position:absolute;z-index:5;text-align:left;padding:2px;margin-left:-999em;background-color: #313131;width:300px;}\n"
".helpstart {position:absolute;z-index:5;text-align:left;padding:2px;background-color: #313131;width:300px;display:none}\n"
".root {z-index:1;position:absolute;top:0px;left:0px;}\n"
".filterinput0{position:fixed;bottom:10px;left:25px;background-color: #313131}\n"
".filterinput1{position:fixed;bottom:10px;left:175px;background-color: #313131}\n"
".filterinputsearchdiv{position:fixed; background-color: #313131;display:none;}\n"
".filterinputsearch{width:100px;}\n"
"</style>\n"
"</head>\n"
"<body style=\"\">\n"
"<div id=\'filterinput\'>\n"
"<div class=\"filterinput0\">Group<br><input type=\"text\" id=\"filtergroup\"></div>\n"
"<div class=\"filterinput1\">Timer/Thread<br><input type=\"text\" id=\"filtertimer\"></div>\n"
"</div>\n"
"<div class=\"filterinputsearchdiv\" id=\"FilterInputDiv\">Filter<br><input type=\"text\" id=\"FilterInput\" class=\"filterinputsearch\"></div>\n"
"<canvas id=\"History\" height=\"70\" style=\"background-color:#343434;margin:0px;padding:0px;\"></canvas><canvas id=\"DetailedView\" height=\"200\" style=\"background-color:#343434;margin:0px;padding:0px;\"></canvas>\n"
"<div id=\"root\" class=\"root\">\n"
"<ul id=\"nav\">\n"
"<li><a href=\"javascript:void(0)\" onclick=\"ToggleDebugMode();\">?</a>\n"
"<div class=\"help\" id=\"divFrameInfo\" style=\"left:20px;top:300px;width:auto;\">\n"
"</div>\n"
"</li>\n"
"<li><a id=\'ModeSubMenuText\'>Mode</a>\n"
"    <ul id=\'ModeSubMenu\'>\n"
"		<li><a href=\"javascript:void(0)\" onclick=\"SetMode(\'timers\', 0);\" id=\"buttonTimers\">Timers</a></li>\n"
"		<li><a href=\"javascript:void(0)\" onclick=\"SetMode(\'timers\', 1);\" id=\"buttonGroups\">Groups</a></li> \n"
"		<li><a href=\"javascript:void(0)\" onclick=\"SetMode(\'timers\', 2);\" id=\"buttonThreads\">Threads</a></li>\n"
"		<li><a href=\"javascript:void(0)\" onclick=\"SetMode(\'detailed\', 0);\" id=\"buttonDetailed\">Detailed</a></li>\n"
"		<li><a href=\"javascript:void(0)\" onclick=\"SetMode(\'counters\', 0);\" id=\"buttonCounters\">Counters</a></li>\n"
"	</ul>\n"
"</li>\n"
"<li><a>Reference</a>\n"
"    <ul id=\'ReferenceSubMenu\'>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"SetReferenceTime(\'5ms\');\">5ms</a></li>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"SetReferenceTime(\'10ms\');\">10ms</a></li>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"SetReferenceTime(\'15ms\');\">15ms</a></li>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"SetReferenceTime(\'20ms\');\">20ms</a></li>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"SetReferenceTime(\'33ms\');\">33ms</a></li>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"SetReferenceTime(\'50ms\');\">50ms</a></li>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"SetReferenceTime(\'100ms\');\">100ms</a></li>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"SetReferenceTime(\'250ms\');\">250ms</a></li>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"SetReferenceTime(\'500ms\');\">500ms</a></li>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"SetReferenceTime(\'1000ms\');\">1000ms</a></li>\n"
"    </ul>\n"
"</li>\n"
"<li id=\"ilColumns\"><a>Columns</a>\n"
"    <ul id=\'ColumnsSubMenu\'>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"ToggleColumn(0);\">Average</a></li>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"ToggleColumn(1);\">Max</a></li>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"ToggleColumn(2);\">Total</a></li>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"ToggleColumn(3);\">Min</a></li>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"ToggleColumn(4);\">Spike</a></li>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"ToggleColumn(5);\">Call Average</a></li>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"ToggleColumn(6);\">Call Count</a></li>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"ToggleColumn(7);\">Excl Average</a></li>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"ToggleColumn(8);\">Excl Max</a></li>\n"
"    </ul>\n"
"</li>\n"
"<li id=\"ilThreads\"><a>Threads</a>\n"
"    <ul id=\"ThreadSubMenu\">\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"ToggleThread();\">All</a></li>\n"
"        <li><a>---</a></li>\n"
"    </ul>\n"
"</li>\n"
"<li id=\"ilGroups\"><a>Groups</a>\n"
"    <ul id=\"GroupSubMenu\">\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"ToggleGroup();\">All</a></li>\n"
"        <li><a>---</a></li>\n"
"    </ul>\n"
"</li>\n"
"<li id=\"ilOptions\"><a>Options&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>\n"
"    <ul id=\'OptionsMenu\'>\n"
"        <li><a href=\"javascript:void(0)\" onclick=\"ToggleContextSwitch();\">Context Switch</a></li>\n"
"		<li><a href=\"javascript:void(0)\" onclick=\"ToggleDisableMerge();\">MergeDisable</a></li>\n"
"		<li><a href=\"javascript:void(0)\" onclick=\"ToggleDisableLod();\">LodDisable</a></li>\n"
"		<li id=\'GroupColors\'><a href=\"javascript:void(0)\" onclick=\"ToggleGroupColors();\">Group Colors</a></li>\n"
"        <li id=\'ShowHelp\'><a href=\"javascript:void(0)\" onclick=\"ShowHelp(1,1);\">Help</a></li>\n"
"<!--      	<li><a href=\"javascript:void(0)\" onclick=\"ToggleDebug();\">DEBUG</a></li> -->\n"
"    </ul>\n"
"</li>\n"
"</ul>\n"
"</div>\n"
"<div class=\"helpstart\" id=\"helpwindow\" style=\"left:20px;top:20px\">\n"
"History View:<br>\n"
"Click + Drag: Pan View<br>\n"
"Right Click + Drag : Zoom on region<br>\n"
"Click Frame : Center on frame<br>\n"
"<hr>\n"
"Main View:<br>\n"
"Ctrl + Mouse up/down: Zoom<br>\n"
"Mousewheel : Zoom<br>\n"
"Right Click + Drag: Select region<br>\n"
"Ctrl + Shift + Drag: Select region<br>\n"
"Space: Zoom to Selection<br>\n"
"Ctrl + Drag: Pan<br>\n"
"Click + Drag: Pan<br>\n"
"hold alt: Show tooltip from timer view in detailed, detailed in timer<br>\n"
"x : Toggle View<br>\n"
"<hr>\n"
"Detailed View:<br>\n"
"Tab: Go To Worst Instance<br>\n"
"Left/Right Arror: Next/Prev Instance<br>\n"
"Enter: Search for timer in view<br>\n"
"<hr>\n"
"Timer Views:<br>\n"
"Tab: go to filtering<br>\n"
"Esc: Exit &amp; Clear filter\n"
"<hr>\n"
"<table style=\"width:100%\">\n"
"<tr>\n"
"<td width=\"50%\" align=\"left\"><a href=\'javascript:void(0)\' onclick=\"ShowHelp(0, 0);\">Close</a></td>\n"
"<td width=\"50%\" align=\"right\"><a href=\'javascript:void(0)\' onclick=\"ShowHelp(0, 1);\">Close, Never Show</a></td>\n"
"</tr>\n"
"</table>\n"
"</div>\n"
"<script>\n"
"function ConvertRgbToHsl(hexTripletColor) //from https://gist.github.com/mjackson/5311256\n"
"{\n"
"	var color = hexTripletColor;\n"
"	color = color.substring(1);\n"
"	color = parseInt(color, 16);\n"
"	var r = ((color >> 16) % 256)/255.0;\n"
"	var g = ((color >> 8) % 256)/255.0;\n"
"	var b = ((color >> 0) % 256)/255.0;\n"
"	var max = Math.max(r, g, b), min = Math.min(r, g, b);\n"
"	var h, s, l = (max + min) / 2;\n"
"	if (max == min) {\n"
"		h = s = 0; // achromatic\n"
"	}\n"
"	else \n"
"	{\n"
"		var d = max - min;\n"
"		s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n"
"\n"
"		switch (max) \n"
"		{\n"
"			case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n"
"			case g: h = (b - r) / d + 2; break;\n"
"			case b: h = (r - g) / d + 4; break;\n"
"		}\n"
"		h /= 6;\n"
"	}\n"
"	return [ h, s, l ];\n"
"}\n"
"\n"
"function ConvertHslToColor(h, s, l) //from https://gist.github.com/mjackson/5311256\n"
"{\n"
"	var r, g, b;\n"
"	if (s == 0)\n"
"	{\n"
"		r = g = b = l; // achromatic\n"
"	}\n"
"	else\n"
"	{\n"
"		function hue2rgb(p, q, t)\n"
"		{\n"
"			if (t < 0) t += 1;\n"
"			if (t > 1) t -= 1;\n"
"			if (t < 1/6) return p + (q - p) * 6 * t;\n"
"			if (t < 1/2) return q;\n"
"			if (t < 2/3) return p + (q - p) * (2/3 - t) * 6;\n"
"			return p;\n"
"		}\n"
"		var q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n"
"		var p = 2 * l - q;\n"
"		r = hue2rgb(p, q, h + 1/3);\n"
"		g = hue2rgb(p, q, h);\n"
"		b = hue2rgb(p, q, h - 1/3);\n"
"	}\n"
"	var color = ((r*255)<<16) | ((g*255)<<8) | (b*255);\n"
"	return \'#\' + (\"000000\" + color.toString(16)).slice(-6);\n"
"}\n"
"\n"
"\n"
"function ConvertColorDark(hexTripletColor)\n"
"{\n"
"	var color = hexTripletColor;\n"
"	color = color.substring(1); // remove #\n"
"	color = parseInt(color, 16); // convert to integer\n"
"	console.log(color.toString(16));\n"
"	color = (color >> 1);\n"
"	console.log(color.toString(16));\n"
"	color = color & 0x7f7f7f;\n"
"	console.log(color.toString(16));\n"
"	return \'#\' + (\"000000\" + color.toString(16)).slice(-6);\n"
"}\n"
"function InvertColor(hexTripletColor) \n"
"{\n"
"	var color = hexTripletColor;\n"
"	color = color.substring(1); // remove #\n"
"	color = parseInt(color, 16); // convert to integer\n"
"	var R = ((color >> 16) % 256)/255.0;\n"
"	var G = ((color >> 8) % 256)/255.0;\n"
"	var B = ((color >> 0) % 256)/255.0;\n"
"	var lum = (0.2126*R + 0.7152*G + 0.0722*B);\n"
"	if(lum < 0.7)\n"
"	{\n"
"		return \'#ffffff\';\n"
"	}\n"
"	else\n"
"	{\n"
"		return \'#333333\';\n"
"	}\n"
"}\n"
"function InvertColorIndex(hexTripletColor) {\n"
"	var color = hexTripletColor;\n"
"	color = color.substring(1); // remove #\n"
"	color = parseInt(color, 16); // convert to integer\n"
"	var R = ((color >> 16) % 256)/255.0;\n"
"	var G = ((color >> 8) % 256)/255.0;\n"
"	var B = ((color >> 0) % 256)/255.0;\n"
"	var lum = (0.2126*R + 0.7152*G + 0.0722*B);\n"
"	if(lum < 0.7)\n"
"	{\n"
"		return 0;\n"
"	}\n"
"	else\n"
"	{\n"
"		return 1;\n"
"	}\n"
"}\n"
"function MakeGroup(id, name, category, numtimers, isgpu, total, average, max, color)\n"
"{\n"
"	var cid = GetColorIndex(color);\n"
"	var group = {\"id\":id, \"name\":name, \"category\":category, \"numtimers\":numtimers, \"isgpu\":isgpu, \"total\": total, \"average\" : average, \"max\" : max, \"cid\":cid};\n"
"	return group;\n"
"}\n"
"\n"
"function MakeTimer(id, name, group, color, colordark, average, max, min, exclaverage, exclmax, callaverage, callcount, total, meta, metaavg, metamax)\n"
"{\n"
"	var spike = max <= 0 || average <= 0 ? 0 : (100 * max / average);\n"
"	var cid = GetColorIndex(color);\n"
"	var timer = {\"id\":id, \"name\":name, \"len\":name.length, \"cid\":cid, \"timercid\":cid, \"group\":group, \"average\":average, \"max\":max, \"min\":min, \"exclaverage\":exclaverage, \"exclmax\":exclmax, \"callaverage\":callaverage, \"callcount\":callcount, \"spike\":spike,\"total\":total, \"meta\":meta, \"metaavg\":metaavg, \"metamax\":metamax, \"worst\":0, \"worststart\":0, \"worstend\":0};\n"
"	return timer;\n"
"}\n"
"function MakeFrame(id, framestart, frameend, framestartgpu, frameendgpu, ts, tt, ti)\n"
"{\n"
"	var frame = {\"id\":id, \"framestart\":framestart, \"frameend\":frameend, \"framestartgpu\":framestartgpu, \"frameendgpu\":frameendgpu, \"ts\":ts, \"tt\":tt, \"ti\":ti};\n"
"	return frame;\n"
"}\n"
"function MakeCounterHistory(id, history, prc)\n"
"{\n"
"	var counterhistory = {\"id\":id, \"history\":history, \"prc\":prc};\n"
"	return counterhistory;\n"
"}\n"
"function MakeCounter(id, parent, sibling, firstchild, level, name, value, minvalue, maxvalue, formatted, limit, formattedlimit, counterprc, boxprc, format, counterhistory)\n"
"{\n"
"	var counter = { \"id\":id, \"parent\":parent, \"sibling\":sibling, \"firstchild\":firstchild, \"level\": level, \"name\":name, \"value\":value, \"formatted\":formatted, \"limit\":limit, \"formattedlimit\":formattedlimit, \"counterprc\":counterprc, \"boxprc\":boxprc, \"counterhistory\":counterhistory, \"format\":format, \"minvalue\":minvalue, \"maxvalue\":maxvalue};\n"
"	return counter;\n"
"}\n"
"\n"
"\n"
"var g_ColorMap = {};\n"
"var g_Colors = new Array();\n"
"var g_ColorsDark = new Array();\n"
"var g_ColorsTextIndex = new Array();\n"
"var g_ColorH = new Array();\n"
"var g_ColorS = new Array();\n"
"var g_ColorL = new Array();\n"
"\n"
"function GetColorIndex(color)\n"
"{\n"
"	if(g_ColorMap[color])\n"
"	{\n"
"		return g_ColorMap[color];\n"
"	}\n"
"	else\n"
"	{\n"
"		var idx = g_Colors.length;\n"
"		g_ColorMap[color] = idx;\n"
"		g_Colors.push(color);\n"
"		g_ColorsDark.push(ConvertColorDark(color));\n"
"		g_ColorsTextIndex.push(InvertColorIndex(color));\n"
"		var hsl = ConvertRgbToHsl(color);\n"
"		g_ColorH.push(hsl[0]);\n"
"		g_ColorS.push(hsl[1]);\n"
"		g_ColorL.push(hsl[2]);\n"
"		return idx;\n"
"	}\n"
"}\n"
"//color index 0 reserved for blinking\n"
"var cidhovercolor = 0;\n"
"g_Colors.push(\'#000000\');\n"
"g_ColorsDark.push(\'#000000\');\n"
"g_ColorsTextIndex.push(0);\n"
"g_ColorH.push(0);\n"
"g_ColorS.push(0);\n"
"g_ColorL.push(0);\n"
"\n"
"\n"
"var Timeline = {};\n"
"var TimelineArray = [];\n"
"var TimelineIdArray = [];\n"
"var TimelineNames = [];\n"
"var TimelineColorArray = [];\n"
"\n"
"\n"
"\n"
"\n"
"";

const size_t g_MicroProfileHtml_begin_0_size = sizeof(g_MicroProfileHtml_begin_0);
const char* g_MicroProfileHtml_begin[] = {
&g_MicroProfileHtml_begin_0[0],
};
size_t g_MicroProfileHtml_begin_sizes[] = {
sizeof(g_MicroProfileHtml_begin_0),
};
size_t g_MicroProfileHtml_begin_count = 1;
const char g_MicroProfileHtml_end_0[] =
"\n"
"\n"
"\n"
"var CanvasDetailedView = document.getElementById(\'DetailedView\');\n"
"var CanvasHistory = document.getElementById(\'History\');\n"
"var CanvasDetailedOffscreen = document.createElement(\'canvas\');\n"
"var FilterInputGroup = document.getElementById(\'filtergroup\');\n"
"var FilterInputTimer = document.getElementById(\'filtertimer\');\n"
"\n"
"var FilterInput = document.getElementById(\'FilterInput\');\n"
"var FilterInputDiv = document.getElementById(\'FilterInputDiv\');\n"
"var FilterInputDivPos = {\"x\":-1,\"y\":-1,\"w\":-1,\"h\":-1};\n"
"\n"
"var FilterInputGroupString = null;\n"
"var FilterInputTimerString = null;\n"
"var FilterInputArray = [FilterInputGroup, FilterInputTimer];\n"
"var FilterGroup = null;\n"
"var FilterTimer = null;\n"
"var g_Msg = \'0\';\n"
"\n"
"var Initialized = 0;\n"
"var fDetailedOffset = Frames[0].framestart;\n"
"var fDetailedRange = Frames[Frames.length-1].frameend - fDetailedOffset;\n"
"var nWidth = CanvasDetailedView.width;\n"
"var nHeight = CanvasDetailedView.height;\n"
"var ReferenceTime = 33;\n"
"var nHistoryHeight = 70;\n"
"var nOffsetY = 0;\n"
"var nOffsetBarsX = 0;\n"
"var nOffsetBarsY = 0;\n"
"var nOffsetCountersY = 0;\n"
"var nOffsetFilterSearch = 0;\n"
"var FilterInputSearchLast = \'\';\n"
"var nBarsWidth = 80;\n"
"var GroupNameWidth = 200;\n"
"var TimerNameWidth = 200;\n"
"var MouseButtonState = [0,0,0,0,0,0,0,0];\n"
"var KeyShiftDown = 0;\n"
"var MouseDragButton = 0;\n"
"var KeyCtrlDown = 0;\n"
"var ToolTipFlip = 0; \n"
"var ToolTipCorner = 1;\n"
"var DetailedViewMouseX = 0;\n"
"var DetailedViewMouseY = 0;\n"
"var HistoryViewMouseX = -1;\n"
"var HistoryViewMouseY = -1;\n"
"var MouseHistory = 0;\n"
"var MouseDetailed = 0;\n"
"var FontHeight = 10;\n"
"var FontWidth = 1;\n"
"var FontAscent = 3; //Set manually\n"
"var Font = \'Bold \' + FontHeight + \'px Courier New\';\n"
"var FontFlash = \'Bold \' + 35 + \'px Courier New\';\n"
"var BoxHeight = FontHeight + 2;\n"
"var ThreadsActive = new Object();\n"
"var ThreadsAllActive = 1;\n"
"var GroupsActive = new Object();\n"
"var GroupsAllActive = 1;\n"
"var nMinWidth = 0.01;//subpixel width\n"
"var nMinWidthPan = 1.0;//subpixel width when panning\n"
"var nContextSwitchEnabled = 1;\n"
"var DisableLod = 0;\n"
"var DisableMerge = 0;\n"
"var GroupColors = 0;\n"
"var nModDown = 0;\n"
"var g_MSG = \'no\';\n"
"var nDrawCount = 0;\n"
"var nBackColors = [\'#292929\', \'#343434\' ];\n"
"var nBackColorsDark = [\'#292929\', \'#272727\' ];\n"
"var nBackColorOffset = \'#404040\';\n"
"var CSwitchColors =[\"#9DD8AF\",\"#D7B6DA\",\"#EAAC76\",\"#DBDA61\",\"#8AD5E1\",\"#8CE48B\",\"#C4D688\",\"#57E5C4\"];//generated by http://tools.medialab.sciences-po.fr/iwanthue/index.php\n"
"var CSwitchHeight = 5;\n"
"var FRAME_HISTORY_COLOR_CPU = \'#ff7f27\';\n"
"var FRAME_HISTORY_COLOR_GPU = \'#ffffff\';\n"
"var ZOOM_TIME = 0.5;\n"
"var AnimationActive = false;\n"
"var nHoverCSCpu = -1;\n"
"var nHoverCSCpuNext = -1;\n"
"var nHoverCSToolTip = null;\n"
"var nHoverToken = -1;\n"
"var nHoverFrame = -1;\n"
"var nHoverTokenIndex = -1;\n"
"var nHoverTokenLogIndex = -1;\n"
"var nHoverCounter = 0;\n"
"var nHoverCounterDelta = 8;\n"
"var nHoverTokenNext = -1;\n"
"var nHoverTokenLogIndexNext = -1;\n"
"var nHoverTokenIndexNext = -1;\n"
"var nHoverCounter = -1;\n"
"var nHoverTokenDrawn = -1;\n"
"var nHideHelp = 0;\n"
"var fFrameScale = 33.33;\n"
"var SortColumn = 0;\n"
"var SortColumnOrderFlip = 0;\n"
"var SortColumnMouseOver = null;\n"
"var SortColumnMouseOverNext = null;\n"
"var ColumnsWidth = [];\n"
"var ColumnsEnabled = [];\n"
"var NumColumns = 0;\n"
"var FilterSearchActive = 0;\n"
"var FilterSearchSelection = -1;\n"
"var FilterSearchSelectionMax = 0;\n"
"var FilterSearchPassIndex = -1;\n"
"var FilterSearchArray = new Array();\n"
"var FilterSearchStartTime = new Date();\n"
"function RangeInit()\n"
"{\n"
"	return {\"Begin\":-1, \"End\":-1, \"YBegin\":-1, \"YEnd\":-1, \"Thread\": -1 , \"Index\": -1};\n"
"}\n"
"function RangeValid(Range)\n"
"{\n"
"	return Range.Begin < Range.End;\n"
"}\n"
"function RangeCopy(Dst, Src)\n"
"{\n"
"	Dst.Begin = Src.Begin;\n"
"	Dst.End = Src.End;\n"
"	Dst.YBegin = Src.YBegin;\n"
"	Dst.YEnd = Src.YEnd;\n"
"	Dst.Thread = Src.Thread;\n"
"}\n"
"var RangeCpu = RangeInit();\n"
"var RangeGpu = RangeInit();\n"
"var RangeSelect = RangeInit();\n"
"\n"
"var RangeCpuNext = RangeInit();\n"
"var RangeGpuNext = RangeInit();\n"
"\n"
"var RangeCpuHistory = RangeInit();\n"
"var RangeGpuHistory = RangeInit();\n"
"\n"
"var fRangeBegin = 0;\n"
"var fRangeEnd = -1;\n"
"var fRangeThreadId = -1;\n"
"var fRangeThreadIdNext = -1;\n"
"var fRangeBeginNext = 0;\n"
"var fRangeEndNext = 0;\n"
"var fRangeBeginGpuNext = 0;\n"
"var fRangeEndGpuNext = 0;\n"
"var fRangeBeginHistory = -1;\n"
"var fRangeEndHistory = -1;\n"
"var fRangeBeginHistoryGpu = -1;\n"
"var fRangeEndHistoryGpu = -1;\n"
"var fRangeBeginSelect = 0;\n"
"var fRangeEndSelect = -1;\n"
"var ThreadY;\n"
"\n"
"var ModeDetailed = 0;\n"
"var ModeTimers = 1;\n"
"var ModeCounters = 2;\n"
"var Mode = ModeDetailed;\n"
"\n"
"var DebugDrawQuadCount = 0;\n"
"var DebugDrawTextCount = 0;\n"
"var ProfileMode = 0;\n"
"var ProfileRedraw0 = 0;\n"
"var ProfileRedraw1 = 0;\n"
"var ProfileRedraw2 = 0;\n"
"var ProfileFps = 0;\n"
"var ProfileFpsAggr = 0;\n"
"var ProfileFpsCount = 0;\n"
"var ProfileLastTimeStamp = new Date();\n"
"\n"
"var CSwitchCache = {};\n"
"var CSwitchOnlyThreads = [];\n"
"var ProfileData = {};\n"
"var ProfileStackTime = {};\n"
"var ProfileStackName = {};\n"
"var Debug = 1;\n"
"\n"
"var g_MaxStack = Array();\n"
"var g_TypeArray;\n"
"var g_TimeArray;\n"
"var g_IndexArray;\n"
"var LodData = new Array();\n"
"var NumLodSplits = 10;\n"
"var SplitMin = 100;\n"
"var SPLIT_LIMIT = 1e20;\n"
"var DPR = 1;\n"
"var DetailedRedrawState = {};\n"
"var OffscreenData;\n"
"var DetailedFrameCounter = 0;\n"
"var Invalidate = 0;\n"
"var GroupOrder = Array();\n"
"var ThreadOrder = Array();\n"
"var TimersGroups = 0;\n"
"var MetaLengths = Array();\n"
"var MetaLengthsAvg = Array();\n"
"var MetaLengthsMax = Array();\n"
"\n"
"var ZoomActive = 0;\n"
"\n"
"var StrGroup = \"Group\";\n"
"var StrThread = \"Thread\";\n"
"var StrTimer = \"Timer\";\n"
"var StrAverage = \"Average\";\n"
"var StrMax = \"Max\";\n"
"var StrTotal = \"Total\";\n"
"var StrMin = \"Min\";\n"
"var StrSpike = \"Spike%\";\n"
"var StrCallAverage = \"Call Average\";\n"
"var StrCount = \"Count\";\n"
"var StrExclAverage = \"Excl Average\";\n"
"var StrExclMax = \"Excl Max\";\n"
"\n"
"\n"
"\n"
"\n"
"\n"
"function ProfileModeClear()\n"
"{\n"
"	if(ProfileMode)\n"
"	{\n"
"		ProfileData = new Object();\n"
"		ProfileStackTime = new Array();\n"
"		ProfileStackName = new Array();\n"
"	}\n"
"}\n"
"function ProfileEnter(Name)\n"
"{\n"
"	if(ProfileMode)\n"
"	{\n"
"		ProfileStackTime.push(new Date());\n"
"		ProfileStackName.push(Name);\n"
"	}\n"
"}\n"
"function ProfileLeave()\n"
"{\n"
"	if(ProfileMode)\n"
"	{\n"
"		var Time = new Date();\n"
"		var Delta = Time - ProfileStackTime.pop();\n"
"		var Name = ProfileStackName.pop();\n"
"		var Obj = ProfileData[Name];\n"
"		if(!Obj)\n"
"		{\n"
"			Obj = new Object();\n"
"			Obj.Count = 0;\n"
"			Obj.Name = Name;\n"
"			Obj.Time = 0;\n"
"			ProfileData[Name] = Obj;\n"
"		}\n"
"		Obj.Time += Delta;\n"
"		Obj.Count += 1;\n"
"	}\n"
"}\n"
"\n"
"function ProfilePlot(s)\n"
"{\n"
"	if(ProfileMode)\n"
"	{\n"
"		var A = ProfileData.Plot;\n"
"		if(!A)\n"
"		{\n"
"			ProfileData.Plot = Array();\n"
"			A = ProfileData.Plot;\n"
"		}\n"
"		if(A.length<10)\n"
"		{\n"
"			A.push(s);\n"
"		}\n"
"	}\n"
"}\n"
"function ProfileModeDump()\n"
"{\n"
"	for(var idx in ProfileData)\n"
"	{\n"
"		var Timer = ProfileData[idx];\n"
"		console.log(Timer.Name + \" \" + Timer.Time + \"ms \" + Timer.Count);\n"
"	}\n"
"\n"
"}\n"
"function ProfileModeDraw(Canvas)\n"
"{\n"
"	if(ProfileMode)\n"
"	{\n"
"		var StringArray = [];\n"
"		for(var idx in ProfileData)\n"
"		{\n"
"			if(idx == \"Plot\")\n"
"				continue;\n"
"			var Timer = ProfileData[idx];\n"
"			StringArray.push(Timer.Name);\n"
"			StringArray.push(Timer.Time + \"ms\");\n"
"			StringArray.push(\"#\");\n"
"			StringArray.push(\"\" + Timer.Count);\n"
"		}\n"
"		StringArray.push(\"debug\");\n"
"		StringArray.push(Debug);\n"
"		var Time = new Date();\n"
"		var Delta = Time - ProfileLastTimeStamp;\n"
"		ProfileLastTimeStamp = Time;\n"
"		StringArray.push(\"Frame Delta\");\n"
"		StringArray.push(Delta + \"ms\");\n"
"		if(ProfileMode == 2)\n"
"		{\n"
"			ProfileFpsAggr += Delta;\n"
"			ProfileFpsCount ++ ;\n"
"			var AggrFrames = 10;\n"
"			if(ProfileFpsCount == AggrFrames)\n"
"			{\n"
"				ProfileFps = 1000 / (ProfileFpsAggr / AggrFrames);\n"
"				ProfileFpsAggr = 0;\n"
"				ProfileFpsCount = 0;\n"
"			}\n"
"			StringArray.push(\"FPS\");\n"
"			StringArray.push(\"\" + ProfileFps.toFixed(2));\n"
"		}\n"
"		StringArray.push(\"ProfileRedraw0\");\n"
"		StringArray.push(\"\" + ProfileRedraw0);\n"
"		StringArray.push(\"ProfileRedraw1\");\n"
"		StringArray.push(\"\" + ProfileRedraw1);\n"
"		StringArray.push(\"ProfileRedraw2\");\n"
"		StringArray.push(\"\" + ProfileRedraw2);\n"
"		ProfileRedraw0 = 0;\n"
"		ProfileRedraw1 = 0;\n"
"		ProfileRedraw2 = 0;\n"
"\n"
"\n"
"		for(var i = 0; i < ProfileData.Plot; ++i)\n"
"		{\n"
"			StringArray.push(\"\");\n"
"			StringArray.push(ProfileData.Plot[i]);\n"
"		}\n"
"		ProfileData.Plot = Array();\n"
"		DrawToolTip(StringArray, Canvas, 0, 200);\n"
"	}\n"
"}\n"
"\n"
"function ToggleDebugMode()\n"
"{\n"
"	ProfileMode = (ProfileMode+1)%4;\n"
"	console.log(\'Toggle Debug Mode \' + ProfileMode);\n"
"}\n"
"\n"
"function DetailedTotal()\n"
"{\n"
"	var Total = 0;\n"
"	for(var i = 0; i < Frames.length; i++)\n"
"	{\n"
"		var frfr = Frames[i];\n"
"		Total += frfr.frameend - frfr.framestart;\n"
"	}\n"
"	return Total;\n"
"}\n"
"\n"
"function InitFrameInfo()\n"
"{\n"
"\n"
"	var div = document.getElementById(\'divFrameInfo\');\n"
"	var txt = \'\';\n"
"	txt = txt + \'Timers View\' + \'<br>\';\n"
"	txt = txt + \'Frames:\' + AggregateInfo.Frames +\'<br>\';\n"
"	txt = txt + \'Time:\' + AggregateInfo.Time.toFixed(2) +\'ms<br>\';\n"
"	txt = txt + \'<hr>\';\n"
"	txt = txt + \'Detailed View\' + \'<br>\';\n"
"	txt = txt + \'Frames:\' + Frames.length +\'<br>\';\n"
"	txt = txt + \'Time:\' + DetailedTotal().toFixed(2) +\'ms<br>\';\n"
"	div.innerHTML = txt;\n"
"}\n"
"function InitGroups()\n"
"{\n"
"	for(groupid in GroupInfo)\n"
"	{\n"
"		var TimerArray = Array();\n"
"		for(timerid in TimerInfo)\n"
"		{\n"
"			if(TimerInfo[timerid].group == groupid)\n"
"			{\n"
"				TimerArray.push(timerid);\n"
"			}\n"
"		}\n"
"		GroupInfo[groupid].TimerArray = TimerArray;\n"
"	}\n"
"}\n"
"\n"
"function InitThreadMenu()\n"
"{\n"
"	var ulThreadMenu = document.getElementById(\'ThreadSubMenu\');\n"
"	var MaxLen = 7;\n"
"	ThreadOrder = CreateOrderArray(ThreadNames, function(a){return a;});\n"
"	for(var idx in ThreadOrder)\n"
"	{\n"
"		var name = ThreadNames[ThreadOrder[idx]];\n"
"		var li = document.createElement(\'li\');\n"
"		if(name.length > MaxLen)\n"
"		{\n"
"			MaxLen = name.length;\n"
"		}\n"
"		li.innerText = name;\n"
"		var asText = li.innerHTML;\n"
"		var html = \'<a href=\"javascript:void(0)\" onclick=\"ToggleThread(\\'\' + name + \'\\');\">\' + asText + \'</a>\';\n"
"		li.innerHTML = html;\n"
"		ulThreadMenu.appendChild(li);\n"
"	}\n"
"	var LenStr = (5+(1+MaxLen) * (1+FontWidth)) + \'px\';\n"
"	var Lis = ulThreadMenu.getElementsByTagName(\'li\');\n"
"	for(var i = 0; i < Lis.length; ++i)\n"
"	{\n"
"		Lis[i].style[\'width\'] = LenStr;\n"
"	}\n"
"}\n"
"\n"
"function UpdateThreadMenu()\n"
"{\n"
"	var ulThreadMenu = document.getElementById(\'ThreadSubMenu\');\n"
"	var as = ulThreadMenu.getElementsByTagName(\'a\');\n"
"	for(var i = 0; i < as.length; ++i)\n"
"	{\n"
"		var elem = as[i];\n"
"		var inner = elem.innerText;\n"
"		var bActive = false;\n"
"		if(i < 2)\n"
"		{\n"
"			if(inner == \'All\')\n"
"			{\n"
"				bActive = ThreadsAllActive;\n"
"			}\n"
"		}\n"
"		else\n"
"		{\n"
"			bActive = ThreadsActive[inner];\n"
"		}\n"
"		if(bActive)\n"
"		{\n"
"			elem.style[\'text-decoration\'] = \'underline\';\n"
"		}\n"
"		else\n"
"		{\n"
"			elem.style[\'text-decoration\'] = \'none\';\n"
"		}\n"
"	}\n"
"}\n"
"\n"
"function ToggleThread(ThreadName)\n"
"{\n"
"	if(ThreadName)\n"
"	{\n"
"		if(ThreadsActive[ThreadName])\n"
"		{\n"
"			ThreadsActive[ThreadName] = false;\n"
"		}\n"
"		else\n"
"		{\n"
"			ThreadsActive[ThreadName] = true;\n"
"		}\n"
"	}\n"
"	else\n"
"	{\n"
"		if(ThreadsAllActive)\n"
"		{\n"
"			ThreadsAllActive = 0;\n"
"		}\n"
"		else\n"
"		{\n"
"			ThreadsAllActive = 1;\n"
"		}\n"
"	}\n"
"	Invalidate = 0;\n"
"	UpdateThreadMenu();\n"
"	WriteCookie();\n"
"	Draw(1);\n"
"\n"
"}\n"
"\n"
"function CreateOrderArray(Source, NameFunc)\n"
"{\n"
"	var Temp = Array(Source.length);\n"
"	for(var i = 0; i < Source.length; ++i)\n"
"	{\n"
"		Temp[i] = {};\n"
"		Temp[i].index = i;\n"
"		Temp[i].namezz = NameFunc(Source[i]).toLowerCase();\n"
"	}\n"
"	Temp.sort(function(l, r)\n"
"	{ \n"
"		if(r.namezz<l.namezz)\n"
"			{return 1;}\n"
"		if(l.namezz<r.namezz)\n"
"			{return -1;} \n"
"		return 0;\n"
"	} );\n"
"	var OrderArray = Array(Source.length);\n"
"	for(var i = 0; i < Source.length; ++i)\n"
"	{\n"
"		OrderArray[i] = Temp[i].index;\n"
"	}\n"
"	return OrderArray;\n"
"}\n"
"\n"
"function InitColumnMenu()\n"
"{\n"
"	var ulColumnMenu = document.getElementById(\'ColumnsSubMenu\');\n"
"	var MaxLen = 10;\n"
"	var BaseIndex = ulColumnMenu.getElementsByTagName(\'li\').length;\n"
"	// for(var i = 0; i < MetaNames.length; ++i)\n"
"	// {\n"
"	// 	var li = document.createElement(\'li\');\n"
"	// 	var jsfunc = \'ToggleColumn\';\n"
"	// 	var html = \'<a href=\"javascript:void(0)\" onclick=\"\' + jsfunc + \'(\' + (i+BaseIndex) + \', 1);\">\' + MetaNames[i] + \'</a>\';\n"
"	// 	li.innerHTML = html;\n"
"	// 	ulColumnMenu.appendChild(li);\n"
"	// 	if(MetaNames[i].length > MaxLen)\n"
"	// 	{\n"
"	// 		MaxLen = MetaNames[i].length;\n"
"	// 	}\n"
"	// }\n"
"	var Lis = ulColumnMenu.getElementsByTagName(\'li\');\n"
"	var LenStr = (5+(4+MaxLen) * FontWidth) + \'px\';\n"
"	for(var i = 0; i < Lis.length; ++i)\n"
"	{\n"
"		Lis[i].style[\'width\'] = LenStr;\n"
"	}\n"
"	NumColumns = Lis.length;\n"
"\n"
"	while(ColumnsEnabled.length < NumColumns)\n"
"	{\n"
"		ColumnsEnabled.push(1);\n"
"	}\n"
"	while(ColumnsWidth.length < NumColumns)\n"
"	{\n"
"		ColumnsWidth.push(20);\n"
"	}\n"
"	UpdateColumnsMenu();\n"
"}\n"
"\n"
"function InitGroupMenu()\n"
"{\n"
"	var ulGroupMenu = document.getElementById(\'GroupSubMenu\');\n"
"	var MaxLen = 7;\n"
"	var MenuArray = Array();\n"
"	for(var i = 0; i < GroupInfo.length; ++i)\n"
"	{\n"
"		var x = {};\n"
"		x.IsCategory = 0;\n"
"		x.category = GroupInfo[i].category;\n"
"		x.name = GroupInfo[i].name;\n"
"		x.index = i;\n"
"		MenuArray.push(x);\n"
"	}\n"
"	for(var i = 0; i < CategoryInfo.length; ++i)\n"
"	{\n"
"		var x = {};\n"
"		x.IsCategory = 1;\n"
"		x.category = i;\n"
"		x.name = CategoryInfo[i];\n"
"		x.index = i;\n"
"		MenuArray.push(x);\n"
"	}\n"
"	var OrderFunction = function(a){ return a.category + \"__\" + a.name; };\n"
"	var OrderFunctionMenu = function(a){ return a.IsCategory ? (a.category + \'\') : (a.category + \"__\" + a.name); };\n"
"	GroupOrder = CreateOrderArray(GroupInfo, OrderFunction);\n"
"	var MenuOrder = CreateOrderArray(MenuArray, OrderFunctionMenu);\n"
"\n"
"	for(var idx in MenuOrder)\n"
"	{\n"
"		var MenuItem = MenuArray[MenuOrder[idx]];\n"
"		var name = MenuItem.name;\n"
"		var li = document.createElement(\'li\');\n"
"		if(name.length > MaxLen)\n"
"		{\n"
"			MaxLen = name.length;\n"
"		}\n"
"		var jsfunc = \'\';\n"
"		if(MenuItem.IsCategory)\n"
"		{				\n"
"			li.innerText = \'[\' + name + \']\';\n"
"			jsfunc = \"ToggleCategory\";\n"
"		}\n"
"		else\n"
"		{\n"
"			li.innerText = name;\n"
"			jsfunc = \"ToggleGroup\";\n"
"		}\n"
"		var asText = li.innerHTML;\n"
"		var html = \'<a href=\"javascript:void(0)\" onclick=\"\' + jsfunc + \'(\\'\' + name + \'\\');\">\' + asText + \'</a>\';\n"
"		li.innerHTML = html;\n"
"		ulGroupMenu.appendChild(li);\n"
"	}\n"
"	var LenStr = (5+(1+MaxLen) * FontWidth) + \'px\';\n"
"	var Lis = ulGroupMenu.getElementsByTagName(\'li\');\n"
"	for(var i = 0; i < Lis.length; ++i)\n"
"	{\n"
"		Lis[i].style[\'width\'] = LenStr;\n"
"	}\n"
"	UpdateGroupMenu();\n"
"}\n"
"\n"
"function UpdateGroupMenu()\n"
"{\n"
"	var ulThreadMenu = document.getElementById(\'GroupSubMenu\');\n"
"	var as = ulThreadMenu.getElementsByTagName(\'a\');\n"
"	for(var i = 0; i < as.length; ++i)\n"
"	{\n"
"		var elem = as[i];\n"
"		var inner = elem.innerText;\n"
"		var bActive = false;\n"
"		if(i < 2)\n"
"		{\n"
"			if(inner == \'All\')\n"
"			{\n"
"				bActive = GroupsAllActive;\n"
"			}\n"
"		}\n"
"		else\n"
"		{\n"
"			var CategoryString = inner.length>2 ? inner.substring(1, inner.length-2) : \"\";\n"
"			var CategoryIdx = CategoryIndex(CategoryString);\n"
"			if(inner[0] == \'[\' && inner[inner.length-1] == \']\' && CategoryIdx >= 0)\n"
"			{\n"
"				bActive = IsCategoryActive(CategoryIdx);\n"
"			}\n"
"			else\n"
"			{\n"
"				bActive = GroupsActive[inner];\n"
"			}\n"
"		}\n"
"		if(bActive)\n"
"		{\n"
"			elem.style[\'text-decoration\'] = \'underline\';\n"
"		}\n"
"		else\n"
"		{\n"
"			elem.style[\'text-decoration\'] = \'none\';\n"
"		}\n"
"	}\n"
"}\n"
"function CategoryIndex(CategoryName)\n"
"{\n"
"	for(var i = 0; i < CategoryInfo.length; ++i)\n"
"	{\n"
"		if(CategoryInfo[i] == CategoryName)\n"
"		{\n"
"			return i;\n"
"		}\n"
"	}\n"
"	return -1;\n"
"}\n"
"function IsCategoryActive(CategoryIdx)\n"
"{\n"
"	for(var i = 0; i < GroupInfo.length; ++i)\n"
"	{\n"
"		if(GroupInfo[i].category == CategoryIdx)\n"
"		{\n"
"			var Name = GroupInfo[i].name;\n"
"			if(!GroupsActive[Name])\n"
"			{\n"
"				return false;\n"
"			}\n"
"		}\n"
"	}\n"
"	return true;\n"
"\n"
"}\n"
"function ToggleCategory(CategoryName)\n"
"{\n"
"	var CategoryIdx = CategoryIndex(CategoryName);\n"
"	if(CategoryIdx < 0)\n"
"		return;\n"
"	var CategoryActive = IsCategoryActive(CategoryIdx);\n"
"	for(var i = 0; i < GroupInfo.length; ++i)\n"
"	{\n"
"		if(GroupInfo[i].category == CategoryIdx)\n"
"		{\n"
"			var Name = GroupInfo[i].name;\n"
"			if(CategoryActive)\n"
"			{\n"
"				GroupsActive[Name] = false;\n"
"			}\n"
"			else\n"
"			{\n"
"				GroupsActive[Name] = true;\n"
"			}\n"
"		}\n"
"	}\n"
"	UpdateGroupMenu();\n"
"	WriteCookie();\n"
"	RequestRedraw();\n"
"}\n"
"\n"
"function ToggleGroup(GroupName)\n"
"{\n"
"	if(GroupName)\n"
"	{\n"
"		if(GroupsActive[GroupName])\n"
"		{\n"
"			GroupsActive[GroupName] = false;\n"
"		}\n"
"		else\n"
"		{\n"
"			GroupsActive[GroupName] = true;\n"
"		}\n"
"	}\n"
"	else\n"
"	{\n"
"		if(GroupsAllActive)\n"
"		{\n"
"			GroupsAllActive = 0;\n"
"		}\n"
"		else\n"
"		{\n"
"			GroupsAllActive = 1;\n"
"		}\n"
"	}\n"
"	UpdateGroupMenu();\n"
"	WriteCookie();\n"
"	RequestRedraw();\n"
"}\n"
"function UpdateGroupColors()\n"
"{\n"
"	for(var i = 0; i < TimerInfo.length; ++i)\n"
"	{\n"
"		if(GroupColors)\n"
"		{\n"
"			TimerInfo[i].cid = GroupInfo[TimerInfo[i].group].cid;\n"
"		}\n"
"		else\n"
"		{\n"
"			TimerInfo[i].cid = TimerInfo[i].timercid;\n"
"		}\n"
"	}\n"
"}\n"
"\n"
"function ToggleGroupColors()\n"
"{\n"
"	GroupColors = !GroupColors;\n"
"	UpdateGroupColors();\n"
"	UpdateOptionsMenu();\n"
"	WriteCookie();\n"
"	RequestRedraw();\n"
"}\n"
"\n"
"function UpdateOptionsMenu()\n"
"{\n"
"	var ulGroupColors = document.getElementById(\'GroupColors\');\n"
"	ulGroupColors.style[\'text-decoration\'] = GroupColors ? \'underline\' : \'none\';\n"
"}\n"
"\n"
"function ShowHelp(Show, Forever)\n"
"{\n"
"	var HelpWindow = document.getElementById(\'helpwindow\');\n"
"	if(Show)\n"
"	{\n"
"		HelpWindow.style[\'display\'] = \'block\';\n"
"	}\n"
"	else\n"
"	{\n"
"		HelpWindow.style[\'display\'] = \'none\';\n"
"	}\n"
"	if(Forever)\n"
"	{\n"
"		nHideHelp = Show ? 0 : 1;\n"
"		WriteCookie();\n"
"	}\n"
"}\n"
"function ToggleMode()\n"
"{\n"
"	if(Mode == ModeTimers)\n"
"	{\n"
"		if(TimersGroups == 0)\n"
"		{\n"
"			SetMode(\'timers\', 1);\n"
"		}\n"
"		else if(TimersGroups == 1)\n"
"		{\n"
"			SetMode(\'timers\', 2);\n"
"		}\n"
"		else if(TimersGroups == 2)\n"
"		{\n"
"			SetMode(\'detailed\', 0);\n"
"		}\n"
"\n"
"	}\n"
"	else if(Mode == ModeCounters)\n"
"	{\n"
"		SetMode(\'timers\', 0);\n"
"	}\n"
"	else if(Mode == ModeDetailed)\n"
"	{\n"
"		SetMode(\'counters\', 0);\n"
"	}\n"
"}\n"
"\n"
"function SetMode(NewMode, Groups)\n"
"{\n"
"	ResetColumnWidth();\n"
"	var buttonTimers = document.getElementById(\'buttonTimers\');\n"
"	var buttonDetailed = document.getElementById(\'buttonDetailed\');\n"
"	var buttonGroups = document.getElementById(\'buttonGroups\');\n"
"	var buttonThreads = document.getElementById(\'buttonThreads\');\n"
"	var buttonCounters = document.getElementById(\'buttonCounters\');\n"
"	var ilThreads = document.getElementById(\'ilThreads\');\n"
"	var ilGroups = document.getElementById(\'ilGroups\');\n"
"	var ilColumns = document.getElementById(\'ilColumns\');\n"
"	var ModeElement = null;\n"
"	buttonTimers.style[\'text-decoration\'] = \'none\';\n"
"	buttonGroups.style[\'text-decoration\'] = \'none\';\n"
"	buttonThreads.style[\'text-decoration\'] = \'none\';\n"
"	buttonDetailed.style[\'text-decoration\'] = \'none\';\n"
"	buttonCounters.style[\'text-decoration\'] = \'none\';\n"
"	ilColumns.style[\'display\'] = \'none\';\n"
"\n"
"	if(NewMode == \'counters\' || NewMode == ModeCounters)\n"
"	{\n"
"		buttonCounters.style[\'text-decoration\'] = \'underline\';\n"
"		ilThreads.style[\'display\'] = \'none\';\n"
"		ilGroups.style[\'display\'] = \'none\';\n"
"		Mode = ModeCounters;\n"
"		ModeElement = buttonCounters;\n"
"\n"
"	}\n"
"	else if(NewMode == \'timers\' || NewMode == ModeTimers)\n"
"	{\n"
"		TimersGroups = Groups;\n"
"		buttonTimers.style[\'text-decoration\'] = TimersGroups ? \'none\' : \'underline\';\n"
"		buttonGroups.style[\'text-decoration\'] = TimersGroups == 1 ? \'underline\' : \'none\';\n"
"		buttonThreads.style[\'text-decoration\'] = TimersGroups == 2 ? \'underline\' : \'none\';\n"
"		buttonDetailed.style[\'text-decoration\'] = \'none\';\n"
"		if(TimersGroups == 0)\n"
"		{\n"
"			ilThreads.style[\'display\'] = \'none\';\n"
"			ilColumns.style[\'display\'] = \'block\';\n"
"		}\n"
"		else\n"
"		{\n"
"			ilThreads.style[\'display\'] = \'block\';\n"
"		}\n"
"		ilGroups.style[\'display\'] = \'block\';\n"
"		Mode = ModeTimers;\n"
"		ModeElement = TimersGroups == 2 ? buttonThreads : TimersGroups == 1 ? buttonGroups : buttonTimers;\n"
"\n"
"	}\n"
"	else if(NewMode == \'detailed\' || NewMode == ModeDetailed)\n"
"	{\n"
"		buttonDetailed.style[\'text-decoration\'] = \'underline\';\n"
"	\n"
"		ilThreads.style[\'display\'] = \'block\';\n"
"		ilGroups.style[\'display\'] = \'none\';\n"
"		Mode = ModeDetailed;\n"
"		ModeElement = buttonDetailed;\n"
"	}\n"
"	var ModeSubMenuText = document.getElementById(\'ModeSubMenuText\');\n"
"	ModeSubMenuText.innerText = \'Mode[\' + ModeElement.innerText + \']\';\n"
"\n"
"	if(Mode == ModeTimers)\n"
"	{\n"
"		SetFilterInput(FilterInputGroupString, FilterInputTimerString);\n"
"	}\n"
"	else\n"
"	{\n"
"		ShowFilterInput(0);\n"
"	}\n"
"\n"
"	WriteCookie();\n"
"	RequestRedraw();\n"
"\n"
"}\n"
"\n"
"function SetReferenceTime(TimeString)\n"
"{\n"
"	ReferenceTime = parseInt(TimeString);\n"
"	var ReferenceMenu = document.getElementById(\'ReferenceSubMenu\');\n"
"	var Links = ReferenceMenu.getElementsByTagName(\'a\');\n"
"	for(var i = 0; i < Links.length; ++i)\n"
"	{\n"
"		if(Links[i].innerHTML.match(\'^\' + TimeString))\n"
"		{\n"
"			Links[i].style[\'text-decoration\'] = \'underline\';\n"
"		}\n"
"		else\n"
"		{\n"
"			Links[i].style[\'text-decoration\'] = \'none\';\n"
"		}\n"
"	}\n"
"	WriteCookie();\n"
"	RequestRedraw();\n"
"\n"
"}\n"
"\n"
"function ToggleContextSwitch()\n"
"{\n"
"	SetContextSwitch(nContextSwitchEnabled ? 0 : 1);\n"
"}\n"
"function SetContextSwitch(Enabled)\n"
"{\n"
"	nContextSwitchEnabled = Enabled ? 1 : 0;\n"
"	var ReferenceMenu = document.getElementById(\'OptionsMenu\');\n"
"	var Links = ReferenceMenu.getElementsByTagName(\'a\');\n"
"	Links[0].style[\'text-decoration\'] = nContextSwitchEnabled ? \'underline\' : \'none\';\n"
"	WriteCookie();\n"
"	RequestRedraw();\n"
"}\n"
"\n"
"function ToggleDebug()\n"
"{\n"
"	Debug = (Debug + 1) % 2;\n"
"}\n"
"\n"
"function ToggleDisableMerge()\n"
"{\n"
"	DisableMerge = DisableMerge ? 0 : 1;\n"
"	var ReferenceMenu = document.getElementById(\'OptionsMenu\');\n"
"	var Links = ReferenceMenu.getElementsByTagName(\'a\');\n"
"	if(DisableMerge)\n"
"	{\n"
"		Links[1].style[\'text-decoration\'] = \'underline\';\n"
"	}\n"
"	else\n"
"	{\n"
"		Links[1].style[\'text-decoration\'] = \'none\';\n"
"	}\n"
"\n"
"}\n"
"\n"
"function ToggleDisableLod()\n"
"{\n"
"	DisableLod = DisableLod ? 0 : 1;\n"
"	var ReferenceMenu = document.getElementById(\'OptionsMenu\');\n"
"	var Links = ReferenceMenu.getElementsByTagName(\'a\');\n"
"	if(DisableLod)\n"
"	{\n"
"		Links[2].style[\'text-decoration\'] = \'underline\';\n"
"	}\n"
"	else\n"
"	{\n"
"		Links[2].style[\'text-decoration\'] = \'none\';\n"
"	}\n"
"\n"
"}\n"
"\n"
"function GatherHoverMetaCounters(TimerIndex, StartIndex, nLog, nFrameLast)\n"
"{\n"
"	var HoverInfo = new Object();\n"
"	return HoverInfo;\n"
"	var StackPos = 1;\n"
"	//search backwards, count meta counters \n"
"	for(var i = nFrameLast; i >= 0; i--)\n"
"	{\n"
"		var fr = Frames[i];\n"
"		var ts = fr.ts[nLog];\n"
"		var ti = fr.ti[nLog];\n"
"		var tt = fr.tt[nLog];\n"
"		var start = i == nFrameLast ? StartIndex-1-fr.LogStart[nLog] : ts.length-1;\n"
"\n"
"		for(var j = start; j >= 0; j--)\n"
"		{\n"
"			var type = tt[j];\n"
"			var index = ti[j];\n"
"			var time = ts[j];\n"
"			if(type == 1)\n"
"			{\n"
"				StackPos--;\n"
"				if(StackPos == 0 && index == TimerIndex)\n"
"				{\n"
"					return HoverInfo;\n"
"				}\n"
"			}\n"
"			else if(type == 0)\n"
"			{\n"
"				StackPos++;\n"
"			}\n"
"			else if(type > 1)\n"
"			{\n"
"				// var nMetaCount = type - 3;\n"
"				// var nMetaIndex = MetaNames[index];\n"
"				// if(nMetaIndex in HoverInfo)\n"
"				// {\n"
"				// 	HoverInfo[nMetaIndex] += nMetaCount;\n"
"				// }\n"
"				// else\n"
"				// {\n"
"				// 	HoverInfo[nMetaIndex] = nMetaCount;\n"
"				// }\n"
"			}\n"
"		}\n"
"	}\n"
"}\n"
"function CalculateAllTimers(fBegin, fEnd)\n"
"{\n"
"	var Sum = [];\n"
"	var Count = [];\n"
"	var Sorted = [];\n"
"	for(var i = 0; i < TimerInfo.length; ++i)\n"
"	{\n"
"		Sum.push(0.0);\n"
"		Count.push(0);\n"
"		Sorted.push(i);\n"
"	}\n"
"	var nFrameFirst = 0;\n"
"	var nFrameLast = Frames.length;\n"
"\n"
"	var nNumLogs = Frames[0].ts.length;\n"
"	var StackPosArray = Array(nNumLogs);\n"
"	var StackArray = Array(nNumLogs);\n"
"	for(var i = 0; i < nNumLogs; ++i)\n"
"	{\n"
"		StackPosArray[i] = 0;\n"
"		StackArray[i] = Array(20);\n"
"	}\n"
"\n"
"	for(var i = nFrameFirst; i < nFrameLast; i++)\n"
"	{\n"
"		var fr = Frames[i];\n"
"		for(nLog = 0; nLog < nNumLogs; nLog++)\n"
"		{\n"
"			var StackPos = StackPosArray[nLog];\n"
"			var Stack = StackArray[nLog];\n"
"			var ts = fr.ts[nLog];\n"
"			var ti = fr.ti[nLog];\n"
"			var tt = fr.tt[nLog];\n"
"			var count = ts.length;\n"
"			for(j = 0; j < count; j++)\n"
"			{\n"
"				var type = tt[j];\n"
"				var index = ti[j];\n"
"				var time = ts[j];\n"
"				if(type == 1 && time < fEnd) //enter\n"
"				{\n"
"					Stack[StackPos] = time < fBegin ? fBegin : time;\n"
"					if(StackArray[nLog][StackPos] != time)\n"
"					{\n"
"						console.log(\'fail fail fail\');\n"
"					}\n"
"					StackPos++;\n"
"				}\n"
"				else if(type == 0) // leave\n"
"				{\n"
"					if(StackPos>0)\n"
"					{\n"
"						var timeend = time;\n"
"						StackPos--;\n"
"						timestart = Stack[StackPos];\n"
"						var TimeDelta = timeend - timestart;\n"
"						Sum[index] += TimeDelta;\n"
"						Count[index]++;\n"
"					}\n"
"				}\n"
"			}\n"
"			StackPosArray[nLog] = StackPos;\n"
"		}\n"
"	}\n"
"	Sorted.sort(function(a,b){ return Sum[b] - Sum[a]; } );\n"
"	var Result = {\"Sorted\" : Sorted, \"Sum\" : Sum, \"Count\" : Count};\n"
"	return Result;\n"
"}\n"
"function CalculateTimers(Result, TimerIndex, nFrameFirst, nFrameLast)\n"
"{\n"
"	if(!nFrameFirst || nFrameFirst < 0)\n"
"		nFrameFirst = 0;\n"
"	if(!nFrameLast || nFrameLast > Frames.length)\n"
"		nFrameLast = Frames.length;\n"
"	var FrameCount = nFrameLast - nFrameFirst;\n"
"	if(0 == FrameCount)\n"
"		return;\n"
"	var CallCount = 0;\n"
"	var Sum = 0;\n"
"	var Max = 0;\n"
"	var FrameMax = 0;\n"
"\n"
"	var nNumLogs = Frames[0].ts.length;\n"
"	var StackPosArray = Array(nNumLogs);\n"
"	var StackArray = Array(nNumLogs);\n"
"	for(var i = 0; i < nNumLogs; ++i)\n"
"	{\n"
"		StackPosArray[i] = 0;\n"
"		StackArray[i] = Array(20);\n"
"	}\n"
"\n"
"	for(var i = nFrameFirst; i < nFrameLast; i++)\n"
"	{\n"
"		var FrameSum = 0;\n"
"		var fr = Frames[i];\n"
"		for(nLog = 0; nLog < nNumLogs; nLog++)\n"
"		{\n"
"			var StackPos = StackPosArray[nLog];\n"
"			var Stack = StackArray[nLog];\n"
"			var ts = fr.ts[nLog];\n"
"			var ti = fr.ti[nLog];\n"
"			var tt = fr.tt[nLog];\n"
"			var count = ts.length;\n"
"			for(j = 0; j < count; j++)\n"
"			{\n"
"				var type = tt[j];\n"
"				var index = ti[j];\n"
"				var time = ts[j];\n"
"				if(type == 1) //enter\n"
"				{\n"
"					//push\n"
"					Stack[StackPos] = time;\n"
"					if(StackArray[nLog][StackPos] != time)\n"
"					{\n"
"						console.log(\'fail fail fail\');\n"
"					}\n"
"					StackPos++;\n"
"				}\n"
"				else if(type == 0) // leave\n"
"				{\n"
"					var timestart;\n"
"					var timeend = time;\n"
"					if(StackPos>0)\n"
"					{\n"
"						StackPos--;\n"
"						timestart = Stack[StackPos];\n"
"					}\n"
"					else\n"
"					{\n"
"						timestart = Frames[nFrameFirst].framestart;\n"
"					}\n"
"					if(index == TimerIndex)\n"
"					{\n"
"						var TimeDelta = timeend - timestart;\n"
"						CallCount++;\n"
"						FrameSum += TimeDelta;\n"
"						Sum += TimeDelta;\n"
"						if(TimeDelta > Max)\n"
"							Max = TimeDelta;\n"
"					}\n"
"				}\n"
"				else\n"
"				{\n"
"					//meta\n"
"				}\n"
"			}\n"
"			if(FrameSum > FrameMax)\n"
"			{\n"
"				FrameMax = FrameSum;\n"
"			}\n"
"			StackPosArray[nLog] = StackPos;\n"
"		}\n"
"	}\n"
"\n"
"	Result.CallCount = CallCount;\n"
"	Result.Sum = Sum.toFixed(3);\n"
"	Result.Max = Max.toFixed(3);\n"
"	Result.Average = (Sum / CallCount).toFixed(3);\n"
"	Result.FrameAverage = (Sum / FrameCount).toFixed(3);\n"
"	Result.FrameCallAverage = (CallCount / FrameCount).toFixed(3);\n"
"	Result.FrameMax = FrameMax.toFixed(3);\n"
"	return Result;\n"
"}\n"
"\n"
"function PreprocessCalculateAllTimers()\n"
"{\n"
"	ProfileEnter(\"CalculateAllTimers\");\n"
"	var nFrameFirst = 0;\n"
"	var nFrameLast = Frames.length;\n"
"	var FrameCount = nFrameLast - nFrameFirst;\n"
"	if(0 == FrameCount)\n"
"		return;\n"
"	for(var j = 0; j < TimerInfo.length; j++)\n"
"	{\n"
"		TimerInfo[j].CallCount = 0;\n"
"		TimerInfo[j].Sum = 0;\n"
"		TimerInfo[j].Max = 0;\n"
"		TimerInfo[j].FrameMax = 0;\n"
"	}\n"
"\n"
"\n"
"	var nNumLogs = Frames[0].ts.length;\n"
"	var StackPosArray = Array(nNumLogs);\n"
"	var StackArray = Array(nNumLogs);\n"
"	for(var i = 0; i < nNumLogs; ++i)\n"
"	{\n"
"		StackPosArray[i] = 0;\n"
"		StackArray[i] = Array(20);\n"
"	}\n"
"\n"
"	for(var i = nFrameFirst; i < nFrameLast; i++)\n"
"	{\n"
"		for(var j = 0; j < TimerInfo.length; j++)\n"
"		{\n"
"			TimerInfo[j].FrameSum = 0;\n"
"		}\n"
"\n"
"		var fr = Frames[i];\n"
"		for(nLog = 0; nLog < nNumLogs; nLog++)\n"
"		{\n"
"			var StackPos = StackPosArray[nLog];\n"
"			var Stack = StackArray[nLog];\n"
"			var ts = fr.ts[nLog];\n"
"			var ti = fr.ti[nLog];\n"
"			var tt = fr.tt[nLog];\n"
"			var count = ts.length;\n"
"			for(j = 0; j < count; j++)\n"
"			{\n"
"				var type = tt[j];\n"
"				var index = ti[j];\n"
"				var time = ts[j];\n"
"				if(type == 1) //enter\n"
"				{\n"
"					//push\n"
"					Stack[StackPos] = time;\n"
"					if(StackArray[nLog][StackPos] != time)\n"
"					{\n"
"						console.log(\'fail fail fail\');\n"
"					}\n"
"					StackPos++;\n"
"				}\n"
"				else if(type == 0) // leave\n"
"				{\n"
"					var timestart;\n"
"					var timeend = time;\n"
"					if(StackPos>0)\n"
"					{\n"
"						StackPos--;\n"
"						timestart = Stack[StackPos];\n"
"					}\n"
"					else\n"
"					{\n"
"						timestart = Frames[nFrameFirst].framestart;\n"
"					}\n"
"					// if(index == TimerIndex)\n"
"					{\n"
"						var TimeDelta = timeend - timestart;\n"
"						TimerInfo[index].CallCount++;\n"
"						TimerInfo[index].FrameSum += TimeDelta;\n"
"						TimerInfo[index].Sum += TimeDelta;\n"
"						if(TimeDelta > TimerInfo[index].Max)\n"
"						{\n"
"							TimerInfo[index].Max = TimeDelta;\n"
"							TimerInfo[index].worst = TimeDelta;\n"
"							TimerInfo[index].worststart = timestart;\n"
"							TimerInfo[index].worstend = timeend;\n"
"							TimerInfo[index].worstthread = nLog;\n"
"						}\n"
"					}\n"
"				}\n"
"				else\n"
"				{\n"
"					//meta\n"
"				}\n"
"			}\n"
"			for(var j = 0; j < TimerInfo.length; j++)\n"
"			{\n"
"				if(TimerInfo[j].FrameSum > TimerInfo[j].FrameMax)\n"
"				{\n"
"					TimerInfo[j].FrameMax = TimerInfo[j].FrameSum;\n"
"				}\n"
"			}\n"
"			StackPosArray[nLog] = StackPos;\n"
"		}\n"
"\n"
"\n"
"	}\n"
"\n"
"	for(var j = 0; j < TimerInfo.length; j++)\n"
"	{\n"
"		var CallCount = TimerInfo[j].CallCount;\n"
"		var Sum = TimerInfo[j].Sum.toFixed(3);\n"
"		var Max = TimerInfo[j].Max.toFixed(3);\n"
"		var Average = (TimerInfo[j].Sum / TimerInfo[j].CallCount).toFixed(3);\n"
"		var FrameAverage = (TimerInfo[j].Sum / FrameCount).toFixed(3);\n"
"		var FrameCallAverage = (TimerInfo[j].CallCount / FrameCount).toFixed(3);\n"
"		var FrameMax = TimerInfo[j].FrameMax.toFixed(3);\n"
"		TimerInfo[j].CallCount = CallCount;\n"
"		TimerInfo[j].Sum = Sum;\n"
"		TimerInfo[j].Max  = Max ;\n"
"		TimerInfo[j].Average = Average;\n"
"		TimerInfo[j].FrameAverage = FrameAverage;\n"
"		TimerInfo[j].FrameCallAverage = FrameCallAverage;\n"
"		TimerInfo[j].FrameMax = FrameMax;\n"
"	}\n"
"	ProfileLeave();\n"
"}\n"
"\n"
"var FlashFrames = 10;\n"
"var FlashFrameCounter = 0;\n"
"var FlashMessage = \'\';\n"
"function TimeString(Diff)\n"
"{\n"
"	var DiffString = \"0 sec\";\n"
"	var DiffTable = [1,60,60*60,60*60*24];\n"
"	var DiffNameTable = [\"sec\", \"min\", \"hr\", \"day\"];\n"
"	for(var i = 0; i < DiffTable.length; ++i)\n"
"	{\n"
"		if(Diff >= DiffTable[i])\n"
"		{\n"
"			DiffString = Math.floor(Diff / DiffTable[i]) + \" \" + DiffNameTable[i];\n"
"		}\n"
"	}\n"
"	return DiffString;\n"
"\n"
"}\n"
"function ShowFlashMessage(Message, FrameCount)\n"
"{\n"
"	FlashMessage = Message;\n"
"	FlashFrameCounter = FrameCount;\n"
"}\n"
"function OnPageReady()\n"
"{\n"
"	var DumpDate = DumpUtcCaptureTime;\n"
"	var CurrentDate = Date.now() / 1000;\n"
"	var Diff = CurrentDate - DumpDate;\n"
"	var Limit = 10*60;//flash old message when loading captures older than 10 minutes \n"
"	if(Diff > Limit)\n"
"	{\n"
"		ShowFlashMessage(\"Captured \" + TimeString(Diff) + \" ago\", 100);\n"
"	}\n"
"}\n"
"\n"
"function DrawFlashMessage(context)\n"
"{\n"
"	if(FlashFrameCounter > 0)\n"
"	{\n"
"		if(FlashFrameCounter>1)\n"
"		{\n"
"			var FlashPrc = Math.sin(FlashFrameCounter / FlashFrames);\n"
"			context.font = FontFlash;\n"
"			context.globalAlpha = FlashPrc * 0.35 + 0.5;\n"
"			context.textAlign = \'center\';\n"
"			context.fillStyle = \'red\';\n"
"			context.fillText(FlashMessage, nWidth * 0.5, 50);\n"
"			context.globalAlpha = 1;\n"
"			context.textAlign = \'left\';\n"
"			context.font = Font;\n"
"		}\n"
"		FlashFrameCounter -= 1;\n"
"\n"
"	}\n"
"}\n"
"\n"
"function DrawCaptureInfo(context)\n"
"{\n"
"	context.fillStyle = \'white\';\n"
"	context.textAlign = \'right\';\n"
"	context.font = Font;\n"
"	var DumpDate = DumpUtcCaptureTime;\n"
"	var CurrentDate = Date.now() / 1000;\n"
"	var Diff = CurrentDate - DumpDate;\n"
"	var DiffString = TimeString(Diff) + \" ago\";\n"
"	context.fillText(new Date(DumpDate*1000).toLocaleString(), nWidth, FontHeight);\n"
"	if(Mode == ModeTimers)\n"
"	{\n"
"		context.fillText(\"Timer Frames: \" + AggregateInfo.Frames, nWidth, FontHeight*2);\n"
"	}\n"
"	else\n"
"	{\n"
"		context.fillText(\"Detailed Frames \"+ Frames.length, nWidth, FontHeight*2);\n"
"	}\n"
"	context.fillText(DumpHost, nWidth, FontHeight*3);\n"
"	context.fillText(DiffString, nWidth, FontHeight*4);\n"
"	context.textAlign = \'left\';\n"
"	DrawFlashMessage(context);\n"
"}\n"
"\n"
"function DrawDetailedFrameHistory()\n"
"{\n"
"	ProfileEnter(\"DrawDetailedFrameHistory\");\n"
"	var x = HistoryViewMouseX;\n"
"\n"
"	var context = CanvasHistory.getContext(\'2d\');\n"
"	context.clearRect(0, 0, CanvasHistory.width, CanvasHistory.height);\n"
"\n"
"	var fHeight = nHistoryHeight;\n"
"	var fWidth = nWidth / Frames.length;\n"
"	var fHeightScale = fHeight / ReferenceTime;\n"
"	var fX = 0;\n"
"	var FrameIndex = -1;\n"
"	var MouseDragging = MouseDragState != MouseDragOff;\n"
"	RangeCpuHistory = RangeInit();\n"
"	RangeGpuHistory = RangeInit()\n"
"\n"
"	var FrameFirst = -1;\n"
"	var FrameLast = nWidth;\n"
"	var fDetailedOffsetEnd = fDetailedOffset + fDetailedRange;\n"
"	for(i = 0; i < Frames.length; i++)\n"
"	{\n"
"		var fMs = Frames[i].frameend - Frames[i].framestart;\n"
"		if(fDetailedOffset <= Frames[i].frameend && fDetailedOffset >= Frames[i].framestart)\n"
"		{\n"
"			var lerp = (fDetailedOffset - Frames[i].framestart) / (Frames[i].frameend - Frames[i].framestart);\n"
"			FrameFirst = fX + fWidth * lerp;\n"
"		}\n"
"		if(fDetailedOffsetEnd <= Frames[i].frameend && fDetailedOffsetEnd >= Frames[i].framestart)\n"
"		{\n"
"			var lerp = (fDetailedOffsetEnd - Frames[i].framestart) / (Frames[i].frameend - Frames[i].framestart);\n"
"			FrameLast = fX + fWidth * lerp;\n"
"		}\n"
"		var fH = fHeightScale * fMs;\n"
"		var bMouse = x > fX && x < fX + fWidth;\n"
"		if(bMouse && !MouseDragging)\n"
"		{\n"
"			context.fillStyle = FRAME_HISTORY_COLOR_GPU;\n"
"			RangeCpuHistory.Begin = Frames[i].framestart;\n"
"			RangeCpuHistory.End = Frames[i].frameend;\n"
"			if(Frames[i].framestartgpu)\n"
"			{\n"
"				RangeGpuHistory.Begin = Frames[i].framestartgpu;\n"
"				RangeGpuHistory.End = Frames[i].frameendgpu;\n"
"			}\n"
"			FrameIndex = i;\n"
"		}\n"
"		else\n"
"		{\n"
"			context.fillStyle = FRAME_HISTORY_COLOR_CPU;\n"
"		}\n"
"		context.fillRect(fX, fHeight - fH, fWidth-1, fH);\n"
"		fX += fWidth;\n"
"	}\n"
"\n"
"	var fRangeHistoryBegin = FrameFirst;\n"
"	var fRangeHistoryEnd = FrameLast;\n"
"	var X = fRangeHistoryBegin;\n"
"	var Y = 0;\n"
"	var W = fRangeHistoryEnd - fRangeHistoryBegin;\n"
"	context.globalAlpha = 0.35;\n"
"	context.fillStyle = \'#009900\';\n"
"	context.fillRect(X, Y, W, fHeight);\n"
"	context.globalAlpha = 1;\n"
"	context.strokeStyle = \'#00ff00\';\n"
"	context.beginPath();\n"
"	context.moveTo(X, Y);\n"
"	context.lineTo(X, Y+fHeight);\n"
"	context.moveTo(X+W, Y);\n"
"	context.lineTo(X+W, Y+fHeight);\n"
"	context.stroke();\n"
"\n"
"\n"
"\n"
"\n"
"	DrawCaptureInfo(context);\n"
"\n"
"	if(FrameIndex>=0 && !MouseDragging)\n"
"	{\n"
"		var StringArray = [];\n"
"		StringArray.push(\"Frame\");\n"
"		StringArray.push(\"\" + FrameIndex);\n"
"		StringArray.push(\"Time\");\n"
"		StringArray.push(\"\" + (Frames[FrameIndex].frameend - Frames[FrameIndex].framestart).toFixed(3));\n"
"\n"
"		DrawToolTip(StringArray, CanvasHistory, HistoryViewMouseX, HistoryViewMouseY+20);\n"
"\n"
"	}\n"
"	ProfileLeave();\n"
"}\n"
"fun";

const size_t g_MicroProfileHtml_end_0_size = sizeof(g_MicroProfileHtml_end_0);
const char g_MicroProfileHtml_end_1[] =
"ction TimeToMsString(Time)\n"
"{\n"
"	return Time.toFixed(3) + \"ms\";\n"
"}\n"
"function TimeToString(Time)\n"
"{\n"
"	if(Time > 1000)\n"
"	{\n"
"		return (Time/1000.0).toFixed(0) +\"s\";\n"
"	}\n"
"	else if(Time > 0.9)\n"
"	{\n"
"		return Time.toFixed(0) + \"ms\";\n"
"	}\n"
"	else if(Time > 0.0009)\n"
"	{\n"
"		return (Time*1000).toFixed(0) + \"us\";\n"
"	}\n"
"	else\n"
"	{\n"
"		return (Time*1000000).toFixed(0) + \"ns\";\n"
"	}\n"
"}\n"
"\n"
"function DrawDetailedBackground(context)\n"
"{\n"
"	var fMs = fDetailedRange;\n"
"	var fMsEnd = fMs + fDetailedOffset;\n"
"	var fMsToScreen = nWidth / fMs;\n"
"	var fRate = Math.floor(2*((Math.log(fMs)/Math.log(10))-1))/2;\n"
"	var fStep = Math.pow(10, fRate);\n"
"	var fRcpStep = 1.0 / fStep;\n"
"	var nColorIndex = Math.floor(fDetailedOffset * fRcpStep) % 2;\n"
"	if(nColorIndex < 0)\n"
"		nColorIndex = -nColorIndex;\n"
"	var fStart = Math.floor(fDetailedOffset * fRcpStep) * fStep;\n"
"	var fHeight = CanvasDetailedView.height;\n"
"	var fScaleX = nWidth / fDetailedRange; \n"
"	var HeaderString = TimeToString(fStep);\n"
"	context.textAlign = \'center\';\n"
"	for(f = fStart; f < fMsEnd; )\n"
"	{\n"
"		var fNext = f + fStep;\n"
"		var X = (f - fDetailedOffset) * fScaleX;\n"
"		var W = (fNext-f)*fScaleX;\n"
"		context.fillStyle = nBackColors[nColorIndex];\n"
"		context.fillRect(X, 0, W+2, fHeight);\n"
"		nColorIndex = 1 - nColorIndex;\n"
"		context.fillStyle = \'#777777\'\n"
"		context.fillText(HeaderString, X + W * 0.5, 10);\n"
"		context.fillText(HeaderString, X + W * 0.5, nHeight - 10);\n"
"		f = fNext;\n"
"	}\n"
"	context.textAlign = \'left\';\n"
"	var fScaleX = nWidth / fDetailedRange; \n"
"	context.globalAlpha = 0.5;\n"
"	context.strokeStyle = \'#bbbbbb\';\n"
"	context.beginPath();\n"
"	for(var i = 0; i < Frames.length; i++)\n"
"	{\n"
"		var frfr = Frames[i];\n"
"		if(frfr.frameend < fDetailedOffset || frfr.framestart > fDetailedOffset + fDetailedRange)\n"
"		{\n"
"			continue;\n"
"		}\n"
"		var X = (frfr.framestart - fDetailedOffset) * fScaleX;\n"
"		if(X >= 0 && X < nWidth)\n"
"		{\n"
"			context.moveTo(X, 0);\n"
"			context.lineTo(X, nHeight);\n"
"		}\n"
"	}\n"
"	context.stroke();\n"
"	context.globalAlpha = 1;\n"
"\n"
"}\n"
"function DrawToolTip(StringArray, Canvas, x, y)\n"
"{\n"
"	var context = Canvas.getContext(\'2d\');\n"
"	context.font = Font;\n"
"	var WidthArray = Array(StringArray.length);\n"
"	var nMaxWidth = 0;\n"
"	var nHeight = 0;\n"
"	for(i = 0; i < StringArray.length; i += 2)\n"
"	{\n"
"		var nWidth0 = context.measureText(StringArray[i]).width;\n"
"		var nWidth1 = context.measureText(StringArray[i+1]).width;\n"
"		var nSum = nWidth0 + nWidth1;\n"
"		WidthArray[i] = nWidth0;\n"
"		WidthArray[i+1] = nWidth1;\n"
"		if(nSum > nMaxWidth)\n"
"		{\n"
"			nMaxWidth = nSum;\n"
"		}\n"
"		nHeight += BoxHeight;\n"
"	}\n"
"	nMaxWidth += 15;\n"
"	//bounds check.\n"
"	var CanvasRect = Canvas.getBoundingClientRect();\n"
"	if(y + nHeight > CanvasRect.height)\n"
"	{\n"
"		y = CanvasRect.height - nHeight;\n"
"		x += 20;\n"
"	}\n"
"	if(x + nMaxWidth > CanvasRect.width)\n"
"	{\n"
"		x = CanvasRect.width - nMaxWidth;\n"
"	}\n"
"\n"
"	context.fillStyle = \'black\';\n"
"	context.fillRect(x-1, y, nMaxWidth+2, nHeight);\n"
"	context.fillStyle = \'white\';\n"
"\n"
"	var XPos = x;\n"
"	var XPosRight = x + nMaxWidth;\n"
"	var YPos = y + BoxHeight-2;\n"
"	for(i = 0; i < StringArray.length; i += 2)\n"
"	{\n"
"		context.fillText(StringArray[i], XPos, YPos);\n"
"		context.fillText(StringArray[i+1], XPosRight - WidthArray[i+1], YPos);\n"
"		YPos += BoxHeight;\n"
"	}\n"
"}\n"
"function DrawHoverToolTip()\n"
"{\n"
"	ProfileEnter(\"DrawHoverToolTip\");\n"
"	if(nHoverToken != -1)\n"
"	{\n"
"		var StringArray = [];\n"
"		var groupid = TimerInfo[nHoverToken].group;\n"
"		StringArray.push(\"Timer\");\n"
"		StringArray.push(TimerInfo[nHoverToken].name);\n"
"		StringArray.push(\"Group\");\n"
"		StringArray.push(GroupInfo[groupid].name);\n"
"\n"
"		var bShowTimers = Mode == ModeTimers;\n"
"		if(ToolTipFlip == 1)\n"
"		{\n"
"			bShowTimers = !bShowTimers;\n"
"		}\n"
"		if(bShowTimers)\n"
"		{\n"
"\n"
"			StringArray.push(\"\");\n"
"			StringArray.push(\"\");\n"
"			var Timer = TimerInfo[nHoverToken];\n"
"			StringArray.push(\"Average\");\n"
"			StringArray.push(Timer.average);\n"
"			StringArray.push(\"Max\");\n"
"			StringArray.push(Timer.max);\n"
"			StringArray.push(\"Excl Max\");\n"
"			StringArray.push(Timer.exclmax);\n"
"			StringArray.push(\"Excl Average\");\n"
"			StringArray.push(Timer.exclaverage);\n"
"			StringArray.push(\"Call Average\");\n"
"			StringArray.push(Timer.callaverage);\n"
"			StringArray.push(\"Call Count\");\n"
"			StringArray.push(Timer.callcount);\n"
"\n"
"			StringArray.push(\"\");\n"
"			StringArray.push(\"\");\n"
"\n"
"\n"
"			StringArray.push(\"Group\");\n"
"			StringArray.push(GroupInfo[groupid].name);\n"
"			StringArray.push(\"Average\");\n"
"			StringArray.push(GroupInfo[groupid].average);\n"
"			StringArray.push(\"Max\");\n"
"			StringArray.push(GroupInfo[groupid].max);\n"
"\n"
"			StringArray.push(\"\");\n"
"			StringArray.push(\"\");\n"
"\n"
"			StringArray.push(\"Timer Capture\");\n"
"			StringArray.push(\"\");\n"
"			StringArray.push(\"Frames\");\n"
"			StringArray.push(AggregateInfo.Frames);\n"
"			StringArray.push(\"Time\");\n"
"			StringArray.push(AggregateInfo.Time.toFixed(2) + \"ms\");\n"
"\n"
"\n"
"\n"
"\n"
"		}\n"
"		else\n"
"		{\n"
"			StringArray.push(\"\");\n"
"			StringArray.push(\"\");\n"
"\n"
"\n"
"\n"
"			StringArray.push(\"Time\");\n"
"			StringArray.push((RangeCpu.End-RangeCpu.Begin).toFixed(3));\n"
"			StringArray.push(\"\");\n"
"			StringArray.push(\"\");\n"
"			StringArray.push(\"Total\");\n"
"			StringArray.push(\"\" + TimerInfo[nHoverToken].Sum);\n"
"			StringArray.push(\"Max\");\n"
"			StringArray.push(\"\" + TimerInfo[nHoverToken].Max);\n"
"			StringArray.push(\"Average\");\n"
"			StringArray.push(\"\" + TimerInfo[nHoverToken].Average);\n"
"			StringArray.push(\"Count\");\n"
"			StringArray.push(\"\" + TimerInfo[nHoverToken].CallCount);\n"
"\n"
"			StringArray.push(\"\");\n"
"			StringArray.push(\"\");\n"
"\n"
"			StringArray.push(\"Max/Frame\");\n"
"			StringArray.push(\"\" + TimerInfo[nHoverToken].FrameMax);\n"
"\n"
"			StringArray.push(\"Average Time/Frame\");\n"
"			StringArray.push(\"\" + TimerInfo[nHoverToken].FrameAverage);\n"
"\n"
"			StringArray.push(\"Average Count/Frame\");\n"
"			StringArray.push(\"\" + TimerInfo[nHoverToken].FrameCallAverage);\n"
"\n"
"\n"
"\n"
"\n"
"\n"
"		\n"
"			if(nHoverFrame != -1)\n"
"			{\n"
"				StringArray.push(\"\");\n"
"				StringArray.push(\"\");\n"
"				StringArray.push(\"Frame \" + nHoverFrame);\n"
"				StringArray.push(\"\");\n"
"\n"
"				var FrameTime = new Object();\n"
"				CalculateTimers(FrameTime, nHoverToken, nHoverFrame, nHoverFrame+1);\n"
"				StringArray.push(\"Total\");\n"
"				StringArray.push(\"\" + FrameTime.Sum);\n"
"				StringArray.push(\"Count\");\n"
"				StringArray.push(\"\" + FrameTime.CallCount);\n"
"				StringArray.push(\"Average\");\n"
"				StringArray.push(\"\" + FrameTime.Average);\n"
"				StringArray.push(\"Max\");\n"
"				StringArray.push(\"\" + FrameTime.Max);\n"
"			}\n"
"\n"
"			var HoverInfo = GatherHoverMetaCounters(nHoverToken, nHoverTokenIndex, nHoverTokenLogIndex, nHoverFrame);\n"
"			var Header = 0;\n"
"			for(index in HoverInfo)\n"
"			{\n"
"				if(0 == Header)\n"
"				{\n"
"					Header = 1;\n"
"					StringArray.push(\"\");\n"
"					StringArray.push(\"\");\n"
"					StringArray.push(\"Meta\");\n"
"					StringArray.push(\"\");\n"
"\n"
"				}\n"
"				StringArray.push(\"\"+index);\n"
"				StringArray.push(\"\"+HoverInfo[index]);\n"
"			}\n"
"\n"
"			StringArray.push(\"\");\n"
"			StringArray.push(\"\");\n"
"\n"
"			StringArray.push(\"Detailed Capture\");\n"
"			StringArray.push(\"\");\n"
"			StringArray.push(\"Frames\");\n"
"			StringArray.push(Frames.length);\n"
"			StringArray.push(\"Time\");\n"
"			StringArray.push(DetailedTotal().toFixed(2) + \"ms\");	\n"
"		}\n"
"		if(ToolTipCorner)\n"
"			DrawToolTip(StringArray, CanvasDetailedView, nWidth, nHeight);\n"
"		else\n"
"			DrawToolTip(StringArray, CanvasDetailedView, DetailedViewMouseX, DetailedViewMouseY+20)\n"
"	}\n"
"	else if(nHoverCSCpu >= 0)\n"
"	{\n"
"		var StringArray = [];\n"
"		StringArray.push(\"Context Switch\");\n"
"		StringArray.push(\"\");\n"
"		StringArray.push(\"\");\n"
"		StringArray.push(\"\");\n"
"		StringArray.push(\"Cpu\");\n"
"		StringArray.push(\"\" + nHoverCSCpu);\n"
"		StringArray.push(\"Begin\");\n"
"		StringArray.push(\"\" + RangeCpu.Begin);\n"
"		StringArray.push(\"End\");\n"
"		StringArray.push(\"\" + RangeCpu.End);\n"
"		if(ToolTipCorner)\n"
"			DrawToolTip(StringArray, CanvasDetailedView, nWidth, nHeight);\n"
"		else\n"
"			DrawToolTip(StringArray, CanvasDetailedView, DetailedViewMouseX, DetailedViewMouseY+20);\n"
"	}\n"
"	ProfileLeave();\n"
"}\n"
"\n"
"function FormatMeta(Value, Dec)\n"
"{\n"
"	if(!Value)\n"
"	{\n"
"		Value = \"0\";\n"
"	}\n"
"	else\n"
"	{\n"
"		Value = \'\' + Value.toFixed(Dec);\n"
"	}\n"
"	return Value;\n"
"}\n"
"\n"
"function FilterMatch(FilterArray, value)\n"
"{\n"
"	if(!FilterArray)\n"
"		return true;\n"
"	for(var i = 0; i < FilterArray.length; ++i)\n"
"	{\n"
"		var res = value.search(FilterArray[i]);\n"
"		if(res<0)\n"
"			return false;\n"
"	}\n"
"	return true;\n"
"}\n"
"\n"
"\n"
"function DrawBarView()\n"
"{\n"
"	ProfileEnter(\"DrawBarView\");\n"
"	Invalidate++;\n"
"	nHoverToken = -1;\n"
"	nHoverFrame = -1;\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"	context.clearRect(0, 0, nWidth, nHeight);\n"
"\n"
"	var Height = BoxHeight;\n"
"	var Width = nWidth;\n"
"	var NameWidth = Math.max(TimerNameWidth, GroupNameWidth) + 20;\n"
"\n"
"	//clamp offset to prevent scrolling into the void\n"
"	var nTotalRows = 0;\n"
"	for(var groupid in GroupInfo)\n"
"	{\n"
"		if(GroupsAllActive || GroupsActive[GroupInfo[groupid].name])\n"
"		{\n"
"			nTotalRows += GroupInfo[groupid].TimerArray.length + 1;\n"
"		}\n"
"	}\n"
"	var nTotalRowPixels = nTotalRows * Height;\n"
"	var nFrameRows = nHeight - BoxHeight;\n"
"	if(nOffsetBarsY + nFrameRows > nTotalRowPixels && nTotalRowPixels > nFrameRows)\n"
"	{\n"
"		nOffsetBarsY = nTotalRowPixels - nFrameRows;\n"
"	}\n"
"	var ColumnsWidthBefore = new Array(ColumnsWidth.length);\n"
"	for(var i = 0; i < ColumnsWidth.length; ++i)\n"
"	{\n"
"		ColumnsWidthBefore[i] = ColumnsWidth[i];\n"
"	}\n"
"\n"
"	var Y = -nOffsetBarsY + BoxHeight;\n"
"	if(TimersGroups)\n"
"	{\n"
"		nOffsetBarsX = 0;\n"
"	}\n"
"	var XBase = -nOffsetBarsX;\n"
"	var nColorIndex = 0;\n"
"\n"
"	context.fillStyle = \'white\';\n"
"	context.font = Font;\n"
"	var bMouseIn = 0;\n"
"	var RcpReferenceTime = 1.0 / ReferenceTime;\n"
"	var CountWidth = 12 * FontWidth;\n"
"	var nMetaLen = TimerInfo[0].meta.length;\n"
"	var nMetaCharacters = 10;\n"
"	var InnerBoxHeight = BoxHeight-2;\n"
"	var TimerLen = 8; //todo: fix max digits.\n"
"	var TimerWidth = TimerLen * FontWidth;\n"
"	var nWidthBars = nBarsWidth+2;\n"
"	var nWidthMs = TimerWidth+2+10;\n"
"	var R = 0;\n"
"	var AllColumns = TimersGroups != 0;\n"
"\n"
"\n"
"\n"
"	for(var i = 0; i < nMetaLen; ++i)\n"
"	{\n"
"		if(nMetaCharacters < MetaNames[i].length)\n"
"			nMetaCharacters = MetaNames[i].length;\n"
"	}\n"
"	var nWidthMeta = nMetaCharacters * FontWidth + 6;\n"
"	function HeaderMouseHandle(XBegin, X, Header)\n"
"	{\n"
"		var bMouseIn = DetailedViewMouseY >= 0 && DetailedViewMouseY < BoxHeight && DetailedViewMouseX < X && DetailedViewMouseX > XBegin;\n"
"		if(bMouseIn)\n"
"		{\n"
"			SortColumnMouseOverNext = Header;\n"
"		}\n"
"	}\n"
"	function HeaderString(Header)\n"
"	{\n"
"		if(Header == SortColumnMouseOver)\n"
"		{\n"
"			return Header + (SortColumnOrderFlip ? \'<\' : \'>\');\n"
"		}\n"
"		else\n"
"		{\n"
"			return Header;\n"
"		}\n"
"\n"
"	}\n"
"	function DrawHeaderSplit(Header)\n"
"	{\n"
"		if(ColumnsEnabled[R]||AllColumns)\n"
"		{\n"
"			context.fillStyle = \'white\';\n"
"			context.fillText(HeaderString(Header), X, Height-FontAscent);\n"
"			var XBegin = X;\n"
"			X += nWidthBars;\n"
"			context.fillStyle = nBackColorOffset;\n"
"			X += ColumnsWidth[R];\n"
"			if(X >= NameWidth)\n"
"			{\n"
"				context.fillRect(X-3, 0, 1, nHeight);\n"
"			}\n"
"			HeaderMouseHandle(XBegin, X, Header);\n"
"		}\n"
"		R++;\n"
"	}\n"
"	function DrawHeaderSplitSingle(Header, Col)\n"
"	{\n"
"		if(ColumnsEnabled[Col]||AllColumns)\n"
"		{\n"
"			context.fillStyle = \'white\';\n"
"			context.fillText(HeaderString(Header), X, Height-FontAscent);\n"
"			var XBegin = X;\n"
"			X += ColumnsWidth[R];\n"
"			context.fillStyle = nBackColorOffset;\n"
"			if(X >= NameWidth)\n"
"			{\n"
"				context.fillRect(X-3, 0, 1, nHeight);\n"
"			}\n"
"			HeaderMouseHandle(XBegin, X, Header);\n"
"		}\n"
"		R++;\n"
"	}\n"
"	function DrawHeaderSplitLeftRight(HeaderLeft, HeaderRight, Width)\n"
"	{\n"
"		context.textAlign = \'left\';\n"
"		context.fillStyle = \'white\';\n"
"		context.fillText(HeaderLeft, X, Height-FontAscent);\n"
"		var XBegin = X;\n"
"		X += Width;\n"
"		context.textAlign = \'right\';\n"
"		context.fillText(HeaderRight, X-5, Height-FontAscent);\n"
"		context.textAlign = \'left\';\n"
"		context.fillStyle = nBackColorOffset;\n"
"		if(X >= NameWidth)\n"
"		{\n"
"			context.fillRect(X-3, 0, 1, nHeight);\n"
"		}\n"
"		HeaderMouseHandle(XBegin, X, HeaderLeft);\n"
"	}\n"
"	function DrawTimer(Value, Color)\n"
"	{\n"
"		if(ColumnsEnabled[R]||AllColumns)\n"
"		{\n"
"			var Prc = Value * RcpReferenceTime;\n"
"			var YText = Y+Height-FontAscent;\n"
"			if(Prc > 1)\n"
"			{\n"
"				Prc = 1;\n"
"			}\n"
"			context.textAlign = \'left\';\n"
"			context.fillStyle = Color;\n"
"			context.fillRect(X+1, Y+1, Prc * nBarsWidth, InnerBoxHeight);\n"
"			var TimerText = Value.toFixed(2);\n"
"			var W = context.measureText(TimerText).width + FontWidth;\n"
"			ColumnsWidth[R] = Math.max(W, ColumnsWidth[R]);\n"
"			X += nWidthBars;\n"
"			X += ColumnsWidth[R];\n"
"			context.fillStyle = \'white\';\n"
"			context.textAlign = \'right\';\n"
"			context.fillText(TimerText, X - FontWidth, YText);\n"
"			context.textAlign = \'left\';\n"
"		}\n"
"		R++;\n"
"	}\n"
"	function DrawCount(Str)\n"
"	{\n"
"		if(ColumnsEnabled[R]||AllColumns)\n"
"		{\n"
"			X += ColumnsWidth[R];\n"
"			context.fillStyle = \'white\';\n"
"			context.textAlign = \'right\';\n"
"			var YText = Y+Height-FontAscent;\n"
"			context.fillText(Str, X-6, YText);\n"
"			var W = Math.max(80, context.measureText(Str).width + FontWidth * 2);\n"
"			ColumnsWidth[R] = Math.max(W, ColumnsWidth[R]);\n"
"		}\n"
"		R++;\n"
"	\n"
"	}\n"
"\n"
"\n"
"	function DrawMeta(Value, Width, Dec, YText, Col)\n"
"	{\n"
"		if(ColumnsEnabled[Col]||AllColumns)\n"
"		{\n"
"			Value = FormatMeta(Value, Dec);\n"
"			X += (FontWidth*Width);\n"
"			ColumnsWidth[R] = FontWidth*Width;\n"
"			context.textAlign = \'right\';\n"
"			context.fillText(Value, X-FontWidth, YText);\n"
"			context.textAlign = \'left\';\n"
"		}\n"
"		R++;\n"
"	}\n"
"\n"
"\n"
"\n"
"	function DrawTimerRow(timerid, showgroup)\n"
"	{\n"
"		R = 0;\n"
"		var Timer = TimerInfo[timerid];\n"
"		var Average = Timer.average;\n"
"		var Max = Timer.max;\n"
"		var Min = Timer.min;\n"
"		var Spike = Timer.spike;\n"
"		var ExclusiveMax = Timer.exclmax;\n"
"		var ExclusiveAverage = Timer.exclaverage;\n"
"		var CallAverage = Timer.callaverage;\n"
"		var CallCount = Timer.callcount;\n"
"		var YText = Y+Height-FontAscent;\n"
"		var Color = g_Colors[Timer.cid];\n"
"		X = NameWidth + XBase;\n"
"\n"
"		nColorIndex = 1-nColorIndex;\n"
"		bMouseIn = DetailedViewMouseY >= Y && DetailedViewMouseY < Y + BoxHeight;\n"
"		if(bMouseIn)\n"
"		{\n"
"			nHoverToken = timerid;\n"
"		}\n"
"		context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
"		context.fillRect(0, Y, Width, FontHeight+2);\n"
"\n"
"		DrawTimer(Average,  Color);\n"
"		DrawTimer(Max, Color);\n"
"		DrawTimer(Timer.total, Color);\n"
"		DrawTimer(Min, Color);\n"
"		DrawCount(Spike.toFixed(2) + \'%\');\n"
"		DrawTimer(CallAverage, Color);\n"
"		DrawCount(CallCount);\n"
"		DrawTimer(ExclusiveAverage, Color);\n"
"		DrawTimer(ExclusiveMax, Color);\n"
"\n"
"		context.fillStyle = \'white\';\n"
"		var Col = R;\n"
"		for(var j = 0; j < nMetaLen; ++j)\n"
"		{\n"
"		    DrawMeta(Timer.meta[j], MetaLengths[j], 0, YText, Col + j);\n"
"		    DrawMeta(Timer.metaavg[j], MetaLengthsAvg[j], 2, YText, Col + j);\n"
"		    DrawMeta(Timer.metamax[j], MetaLengthsMax[j], 0, YText, Col + j);\n"
"		}\n"
"		context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
"		context.fillRect(0, Y, NameWidth, Height);\n"
"		context.textAlign = \'right\';\n"
"		context.fillStyle = Color;\n"
"		context.fillText(Timer.name, NameWidth - 5, YText);\n"
"		context.textAlign = \'left\';\n"
"		if(showgroup)\n"
"		{\n"
"			context.fillStyle = \'white\';\n"
"			context.fillText(GroupInfo[Timer.group].name, 1, YText);\n"
"		}\n"
"	}\n"
"	if(SortColumn && TimersGroups == 0)\n"
"	{\n"
"		var OrderArray = new Array(TimerInfo.length);\n"
"		var KeyArray = new Array(TimerInfo.length);\n"
"		for(var idx in GroupOrder)\n"
"		{\n"
"			var Group = GroupInfo[idx];\n"
"			if((GroupsAllActive || GroupsActive[Group.name]) && FilterMatch(FilterGroup, Group.name))\n"
"			{\n"
"				var TimerArray = Group.TimerArray;\n"
"				for(var timerindex in TimerArray)\n"
"				{\n"
"					var timerid = TimerArray[timerindex];\n"
"					if(FilterMatch(FilterTimer, TimerInfo[timerid].name))\n"
"					{\n"
"						OrderArray.push(timerid);\n"
"						NameWidth = Math.max(TimerInfo[timerid].wtotal, NameWidth);\n"
"					}\n"
"				}\n"
"			}\n"
"		}\n"
"		var KeyFunc = null;\n"
"		switch(SortColumn)\n"
"		{\n"
"			case 1: KeyFunc = function (a) { return TimerInfo[a].average; }; break;\n"
"			case 2: KeyFunc = function (a) { return TimerInfo[a].max; }; break;\n"
"			case 3: KeyFunc = function (a) { return TimerInfo[a].total; }; break;\n"
"			case 4: KeyFunc = function (a) { return TimerInfo[a].min; }; break;\n"
"			case 5: KeyFunc = function (a) { return TimerInfo[a].spike; }; break;\n"
"			case 6: KeyFunc = function (a) { return TimerInfo[a].callaverage; }; break;\n"
"			case 7: KeyFunc = function (a) { return TimerInfo[a].callcount; }; break;\n"
"			case 8: KeyFunc = function (a) { return TimerInfo[a].exclaverage; }; break;\n"
"			case 9: KeyFunc = function (a) { return TimerInfo[a].exclmax; }; break;\n"
"		}\n"
"\n"
"		var Flip = SortColumnOrderFlip == 1 ? -1 : 1;\n"
"		OrderArray.sort(function(a,b) { return Flip * (KeyFunc(b) - KeyFunc(a)); } );\n"
"\n"
"		for(var i in OrderArray)\n"
"		{\n"
"			DrawTimerRow(OrderArray[i], 1);\n"
"			Y += Height;\n"
"		}			\n"
"\n"
"	}\n"
"	else if(2 == TimersGroups)\n"
"	{\n"
"		for(var i = 0; i < ThreadNames.length; ++i)\n"
"		{\n"
"			if((ThreadsActive[ThreadNames[i]] || ThreadsAllActive) && FilterMatch(FilterTimer, ThreadNames[i]))\n"
"			{\n"
"				var X = 0;\n"
"				var YText = Y+Height-FontAscent;\n"
"				bMouseIn = DetailedViewMouseY >= Y && DetailedViewMouseY < Y + BoxHeight;\n"
"				nColorIndex = 1-nColorIndex;\n"
"				context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
"				context.fillRect(0, Y, Width, FontHeight+2);\n"
"				var ThreadColor = CSwitchColors[i % CSwitchColors.length];\n"
"				context.fillStyle = ThreadColor;\n"
"				context.fillText(ThreadNames[i], 1, YText);\n"
"				context.textAlign = \'left\';\n"
"				Y += Height;\n"
"				for(var idx in GroupOrder)\n"
"				{\n"
"					R = 0;\n"
"					var groupid = GroupOrder[idx];\n"
"					var Group = GroupInfo[groupid];\n"
"					var PerThreadTimer = ThreadGroupTimeArray[i][groupid];\n"
"					var PerThreadTimerTotal = ThreadGroupTimeTotalArray[i][groupid];\n"
"					if((PerThreadTimer > 0.0001|| PerThreadTimerTotal>0.1) && (GroupsAllActive || GroupsActive[Group.name]) && FilterMatch(FilterGroup, Group.name))\n"
"					{\n"
"						var GColor = GroupColors ? g_Colors[GroupInfo[groupid].cid] : \'white\';\n"
"						var X = 0;\n"
"						nColorIndex = 1-nColorIndex;\n"
"						bMouseIn = DetailedViewMouseY >= Y && DetailedViewMouseY < Y + BoxHeight;\n"
"						context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
"						context.fillRect(0, Y, Width, nHeight);\n"
"						context.fillStyle = GColor;\n"
"						context.textAlign = \'right\';\n"
"						context.fillText(Group.name, NameWidth - 5, Y+Height-FontAscent);\n"
"						context.textAlign = \'left\';\n"
"						X += NameWidth;\n"
"						DrawTimer(PerThreadTimer, GColor);\n"
"						DrawTimer(PerThreadTimerTotal, GColor);\n"
"						Y += Height;\n"
"					}\n"
"				}\n"
"			}\n"
"		}\n"
"	}\n"
"	else\n"
"	{\n"
"		for(var idx in GroupOrder)\n"
"		{\n"
"			var groupid = GroupOrder[idx];\n"
"			var Group = GroupInfo[groupid];\n"
"			var GColor = GroupColors ? g_Colors[GroupInfo[groupid].cid] : \'white\';\n"
"			if((GroupsAllActive || GroupsActive[Group.name]) && FilterMatch(FilterGroup, Group.name))\n"
"			{\n"
"				R = 0;\n"
"				var TimerArray = Group.TimerArray;\n"
"				var X = XBase;\n"
"				nColorIndex = 1-nColorIndex;\n"
"				bMouseIn = DetailedViewMouseY >= Y && DetailedViewMouseY < Y + BoxHeight;\n"
"				context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
"				context.fillRect(0, Y, Width, FontHeight+2);\n"
"				context.fillStyle = GColor;\n"
"				context.fillText(Group.name, 1, Y+Height-FontAscent);\n"
"				X += NameWidth;\n"
"				DrawTimer(Group.average, GColor);\n"
"				DrawTimer(Group.max, GColor);\n"
"				DrawTimer(Group.total, GColor);\n"
"\n"
"				context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
"				context.fillRect(0, Y, NameWidth, FontHeight+2);\n"
"				context.fillStyle = GColor;\n"
"				context.fillText(Group.name, 1, Y+Height-FontAscent);\n"
"\n"
"\n"
"\n"
"				Y += Height;\n"
"				if(TimersGroups)\n"
"				{\n"
"					for(var i = 0; i < ThreadNames.length; ++i)\n"
"					{\n"
"						R = 0;\n"
"						var PerThreadTimer = ThreadGroupTimeArray[i][groupid];\n"
"						var PerThreadTimerTotal = ThreadGroupTimeTotalArray[i][groupid];\n"
"						if((PerThreadTimer > 0.0001|| PerThreadTimerTotal>0.1) && (ThreadsActive[ThreadNames[i]] || ThreadsAllActive) && FilterMatch(FilterTimer, ThreadNames[i]))\n"
"						{\n"
"							var YText = Y+Height-FontAscent;\n"
"							bMouseIn = DetailedViewMouseY >= Y && DetailedViewMouseY < Y + BoxHeight;\n"
"							nColorIndex = 1-nColorIndex;\n"
"							context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
"							context.fillRect(0, Y, Width, FontHeight+2);\n"
"							var ThreadColor = CSwitchColors[i % CSwitchColors.length];\n"
"							context.fillStyle = ThreadColor;\n"
"							context.textAlign = \'right\';\n"
"							context.fillText(ThreadNames[i], NameWidth - 5, YText);\n"
"							context.textAlign = \'left\';\n"
"							X = NameWidth;\n"
"							DrawTimer(PerThreadTimer, ThreadColor);\n"
"							X += nWidthBars + ColumnsWidth[R++];	\n"
"							DrawTimer(PerThreadTimerTotal, ThreadColor);\n"
"							Y += Height;\n"
"						}\n"
"					}\n"
"				}\n"
"				else\n"
"				{\n"
"					for(var timerindex in TimerArray)\n"
"					{\n"
"						var timerid = TimerArray[timerindex];\n"
"						if(FilterMatch(FilterTimer, TimerInfo[timerid].name))\n"
"						{\n"
"							DrawTimerRow(timerid, 0);\n"
"							Y += Height;\n"
"						}\n"
"					}			\n"
"				}\n"
"			}\n"
"		}\n"
"	}\n"
"	X = 0;\n"
"	R = 0;\n"
"	context.fillStyle = nBackColorOffset;\n"
"	context.fillRect(0, 0, Width, Height);\n"
"	context.fillStyle = \'white\';\n"
"	SortColumnMouseOverNext = null;\n"
"\n"
"	if(TimersGroups)\n"
"	{\n"
"		if(2 == TimersGroups)\n"
"		{\n"
"			DrawHeaderSplitLeftRight(StrThread, StrGroup, NameWidth);\n"
"			DrawHeaderSplit(StrAverage);\n"
"			DrawHeaderSplit(StrTotal);\n"
"		}\n"
"		else\n"
"		{\n"
"			DrawHeaderSplitLeftRight(StrGroup, StrThread, NameWidth);\n"
"			DrawHeaderSplit(StrAverage);\n"
"			DrawHeaderSplit(StrMax);\n"
"			DrawHeaderSplit(StrTotal);\n"
"		}\n"
"	}\n"
"	else\n"
"	{\n"
"		X = NameWidth + XBase;\n"
"		DrawHeaderSplit(StrAverage);\n"
"		DrawHeaderSplit(StrMax);\n"
"		DrawHeaderSplit(StrTotal);\n"
"		DrawHeaderSplit(StrMin);\n"
"		DrawHeaderSplitSingle(StrSpike, R);\n"
"		DrawHeaderSplit(StrCallAverage);\n"
"		DrawHeaderSplitSingle(StrCount, R);\n"
"		DrawHeaderSplit(StrExclAverage);\n"
"		DrawHeaderSplit(StrExclMax);\n"
"		var Col = R;\n"
"		for(var i = 0; i < nMetaLen; ++i)\n"
"		{\n"
"			DrawHeaderSplitSingle(MetaNames[i], Col + i);\n"
"			DrawHeaderSplitSingle(MetaNames[i] + \" Avg\", Col + i);\n"
"			DrawHeaderSplitSingle(MetaNames[i] + \" Max\", Col + i);\n"
"		}\n"
"		X = 0;\n"
"		context.fillStyle = nBackColorOffset;\n"
"		context.fillRect(0, 0, NameWidth, Height);\n"
"		context.fillStyle = \'white\';\n"
"	\n"
"		DrawHeaderSplitLeftRight(StrGroup, StrTimer, NameWidth);\n"
"	\n"
"	}\n"
"\n"
"	var ColumnsChanged = false;\n"
"	for(var i = 0; i < ColumnsWidth.length; ++i)\n"
"	{\n"
"		if(ColumnsWidthBefore[i] != ColumnsWidth[i])\n"
"		{\n"
"			ColumnsChanged = true;\n"
"		}\n"
"	}\n"
"	if(ColumnsChanged)\n"
"	{\n"
"		Invalidate = 0;\n"
"	}\n"
"\n"
"\n"
"\n"
"\n"
"	ProfileLeave();\n"
"}\n"
"\n"
"var CounterNameWidth = 100;\n"
"var CounterValueWidth = 100;\n"
"var CounterLimitWidth = 100;\n"
"\n"
"var FormatCounterDefault = 0;\n"
"var FormatCounterBytes = 1;\n"
"var FormatCounterBytesExt = [ \"b\",\"kb\",\"mb\",\"gb\",\"tb\",\"pb\", \"eb\",\"zb\", \"yb\" ];\n"
"\n"
"function ShiftRight10(v)\n"
"{\n"
"	if(v > 1024)\n"
"	{\n"
"		return v / 1024.0;\n"
"	}\n"
"	else\n"
"	{\n"
"		return v >> 10;\n"
"	}\n"
"}\n"
"\n"
"\n"
"function FormatCounter(Format, Counter)\n"
"{\n"
"	if(!Counter)\n"
"	{\n"
"		return \'0\';\n"
"	}\n"
"	var Negative = 0;\n"
"	if(Counter < 0)\n"
"	{\n"
"		Counter = -Counter;\n"
"		Negative = 1;\n"
"		if(Counter < 0) // handle INT_MIN\n"
"		{\n"
"			Counter = -(Counter+1);\n"
"			if(Counter < 0)\n"
"			{\n"
"				return \'?\';\n"
"			}\n"
"		}\n"
"	}\n"
"	var str = Negative ? \'-\' :\'\' ;\n"
"	if(Format == FormatCounterDefault)\n"
"	{\n"
"		var Seperate = 0;\n"
"		var result = \'\';\n"
"		while (Counter)\n"
"		{\n"
"			if (Seperate)\n"
"			{\n"
"				result += \'.\';\n"
"			}\n"
"			Seperate = 1;\n"
"			for (var i = 0; Counter && i < 3; ++i)\n"
"			{\n"
"				var Digit = Math.floor(Counter % 10);\n"
"				Counter = Math.floor(Counter / 10);\n"
"				result += \'\' + Digit;\n"
"			}\n"
"		}\n"
"\n"
"		for(var i = 0; i < result.length; ++i)\n"
"		{\n"
"			str += result[result.length-1-i];\n"
"		}\n"
"		return str;\n"
"	}\n"
"	else if(Format == FormatCounterBytes)\n"
"	{\n"
"		var Shift = 0;\n"
"		var Divisor = 1;\n"
"		var CountShifted = ShiftRight10(Counter);\n"
"		while(CountShifted)\n"
"		{\n"
"			Divisor <<= 10;\n"
"			CountShifted = ShiftRight10(CountShifted);\n"
"			Shift++;\n"
"		}\n"
"		if(Shift)\n"
"		{\n"
"			return str + (Counter / Divisor).toFixed(2) + \'\' + FormatCounterBytesExt[Shift];\n"
"		}\n"
"		else\n"
"		{\n"
"			return str + Counter.toFixed(2) + \'\' + FormatCounterBytesExt[0];\n"
"		}\n"
"	}\n"
"	return \'?\'\n"
"}\n"
"function DrawCounterView()\n"
"{\n"
"	ProfileEnter(\"DrawCounterView\");\n"
"	Invalidate++;\n"
"	nHoverToken = -1;\n"
"	nHoverFrame = -1;\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"	context.clearRect(0, 0, nWidth, nHeight);\n"
"\n"
"	var Height = BoxHeight;\n"
"	var Width = nWidth;\n"
"	//clamp offset to prevent scrolling into the void\n"
"	var nTotalRows = CounterInfo.length;\n"
"	var nTotalRowPixels = nTotalRows * Height;\n"
"	var nFrameRows = nHeight - BoxHeight;\n"
"	if(nOffsetCountersY + nFrameRows > nTotalRowPixels && nTotalRowPixels > nFrameRows)\n"
"	{\n"
"		nOffsetCountersY = nTotalRowPixels - nFrameRows;\n"
"	}\n"
"\n"
"	var CounterNameWidthTemp = 10;\n"
"	var CounterValueWidthTemp = 10;\n"
"	var CounterLimitWidthTemp = 10;\n"
"\n"
"	var CounterWidth = 150;\n"
"	var Y = -nOffsetCountersY + BoxHeight;\n"
"	var X = 0;\n"
"	var nColorIndex = 0;\n"
"	context.fillStyle = \'white\';\n"
"	context.font = Font;\n"
"	var bMouseIn = 0;\n"
"	function DrawHeaderSplitSingle(Header, Width)\n"
"	{\n"
"		context.fillStyle = \'white\';\n"
"		context.fillText(Header, X, Height-FontAscent);\n"
"		X += Width;\n"
"		context.fillStyle = nBackColorOffset;\n"
"		context.fillRect(X-3, 0, 1, nHeight);\n"
"	}\n"
"	function DrawHeaderSplitSingleRight(Header, Width)\n"
"	{\n"
"		X += Width;\n"
"		context.fillStyle = \'white\';\n"
"		context.textAlign  = \'right\';\n"
"		context.fillText(Header, X - FontWidth, Height-FontAscent);\n"
"		context.fillStyle = nBackColorOffset;\n"
"		context.fillRect(X, 0, 1, nHeight);\n"
"		context.textAlign  = \'left\';\n"
"	}\n"
"	var TimerLen = 6;\n"
"	var TimerWidth = TimerLen * FontWidth;\n"
"	nHoverCounter = -1;\n"
"	function CounterIndent(Level)\n"
"	{\n"
"		return Level * 4 * FontWidth;\n"
"	}\n"
"	function Max(a, b)\n"
"	{\n"
"		return a > b ? a : b;\n"
"	}\n"
"\n"
"	function DrawCounterRecursive(Index)\n"
"	{\n"
"		var Counter = CounterInfo[Index];\n"
"		var Indent = CounterIndent(Counter.level);\n"
"		CounterNameWidthTemp = Max(CounterNameWidthTemp, Counter.name.length+1 + Indent / (FontWidth+1));\n"
"		CounterValueWidthTemp = Max(CounterValueWidthTemp, Counter.formatted.length);\n"
"		CounterLimitWidthTemp = Max(CounterLimitWidthTemp, Counter.formattedlimit.length);\n"
"\n"
"		var X = 0;\n"
"		nColorIndex = 1-nColorIndex;\n"
"		var HeightExpanded = Counter.Expanded ? Height * 5 : Height\n"
"\n"
"		bMouseIn = DetailedViewMouseY >= Y && DetailedViewMouseY < Y + HeightExpanded;\n"
"		if(bMouseIn)\n"
"		{\n"
"			nHoverCounter = Index;\n"
"		}\n"
"		var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
"		context.fillStyle = bgcolor;\n"
"		context.fillRect(0, Y, Width, HeightExpanded);\n"
"		context.fillStyle = \'white\';\n"
"		var c = Counter.closed ? \'*\' : \' \';\n"
"		context.fillText(c + Counter.name, Indent, Y+Height-FontAscent);\n"
"		X += CounterNameWidth;\n"
"		X += CounterValueWidth - FontWidth;\n"
"		context.textAlign = \'right\';\n"
"		context.fillText(Counter.formatted, X, Y+Height-FontAscent);\n"
"		context.textAlign = \'left\';\n"
"		X += FontWidth * 4;\n"
"		var Y0 = Y + 1;\n"
"		if(Counter.limit != 0)\n"
"		{\n"
"			context.fillText(Counter.formattedlimit, X, Y+Height-FontAscent);\n"
"			X += CounterLimitWidth;\n"
"			var X0 = X + 1;\n"
"			context.fillStyle = \'white\';\n"
"			context.fillRect(X0, Y0, Counter.boxprc * (CounterWidth-2), Height-2);\n"
"			context.fillStyle = bgcolor;\n"
"			context.fillRect(X0+1, Y0+1, Counter.boxprc * (CounterWidth-4), Height-4);\n"
"			context.fillStyle = \'cyan\';\n"
"			context.fillRect(X0+1, Y0+1, Counter.counterprc * (CounterWidth-4), Height-4);\n"
"			X += CounterWidth + 10;\n"
"		}\n"
"		else\n"
"		{\n"
"			X += CounterLimitWidth;\n"
"			X += CounterWidth + 10;\n"
"		}\n"
"		var CounterHistory = Counter.counterhistory;\n"
"		if(CounterHistory)\n"
"		{\n"
"			var Prc = CounterHistory.prc;\n"
"\n"
"			context.fillStyle = \'cyan\';\n"
"			context.strokeStyle = \'cyan\';\n"
"			context.globalAlpha = 0.5;\n"
"			context.beginPath();\n"
"			var x = X;\n"
"			var YBase = Y0 + HeightExpanded-1;\n"
"			var YOffset = -(HeightExpanded-2);\n"
"\n"
"			context.moveTo(X, Y0);\n"
"			for(var i = 0; i < Prc.length; ++i)\n"
"			{\n"
"				context.moveTo(x, YBase);\n"
"				context.lineTo(x, YBase + Prc[i] * YOffset);\n"
"				\n"
"				x += 1;\n"
"			}\n"
"			context.stroke();\n"
"\n"
"			x = X;\n"
"			context.globalAlpha = 1.0;\n"
"			context.beginPath();\n"
"			context.moveTo(X, YBase);\n"
"\n"
"			for(var i = 0; i < Prc.length; ++i)\n"
"			{\n"
"				context.lineTo(x, YBase + Prc[i] * YOffset);\n"
"				x += 1;\n"
"			}\n"
"			context.stroke();\n"
"			if(bMouseIn)\n"
"			{\n"
"				var MouseGraphX = Math.floor(DetailedViewMouseX - X);\n"
"				if(MouseGraphX >= 0 && MouseGraphX < CounterHistory.history.length)\n"
"				{\n"
"					context.fillStyle = \'white\';\n"
"					var Formatted = FormatCounter(Counter.format, CounterHistory.history[MouseGraphX]);\n"
"					context.fillText(Formatted, X, Y+Height-FontAscent);\n"
"				}\n"
"				context.strokeStyle = \'orange\';\n"
"				context.beginPath();\n"
"				var CrossX = X + MouseGraphX;\n"
"				var CrossY = YBase + Prc[MouseGraphX] * YOffset;\n"
"				context.moveTo(CrossX-2, CrossY-2);\n"
"				context.lineTo(CrossX+2, CrossY+2);\n"
"				context.moveTo(CrossX+2, CrossY-2);\n"
"				context.lineTo(CrossX-2, CrossY+2);\n"
"				context.stroke();\n"
"\n"
"			}\n"
"			X += Prc.length + 5;\n"
"			context.fillStyle = \'white\';\n"
"			context.fillText( FormatCounter(Counter.format, Counter.minvalue), X, Y + Height - FontAscent);\n"
"			X += CounterWidth + 5;\n"
"			context.fillText( FormatCounter(Counter.format, Counter.maxvalue), X, Y + Height - FontAscent);\n"
"			X += CounterWidth + 5;\n"
"		}\n"
"\n"
"		Y += HeightExpanded;\n"
"\n"
"		if(!Counter.closed)\n"
"		{\n"
"			var ChildIndex = Counter.firstchild;\n"
"			while(ChildIndex != -1)\n"
"			{\n"
"				DrawCounterRecursive(ChildIndex);\n"
"				ChildIndex = CounterInfo[ChildIndex].sibling;\n"
"			}\n"
"		}\n"
"	}\n"
"\n"
"	for(var i = 0; i < CounterInfo.length; ++i)\n"
"	{\n"
"		if(CounterInfo[i].parent == -1)\n"
"		{\n"
"			DrawCounterRecursive(i);\n"
"		}\n"
"	}\n"
"\n"
"	X = 0;\n"
"	context.fillStyle = nBackColorOffset;\n"
"	context.fillRect(0, 0, Width, Height);\n"
"	context.fillStyle = \'white\';\n"
"	DrawHeaderSplitSingle(\'Name\', CounterNameWidth);\n"
"	DrawHeaderSplitSingleRight(\'Value\', CounterValueWidth + (FontWidth+1));\n"
"	DrawHeaderSplitSingle(\'Limit\', CounterLimitWidth + CounterWidth + 3 * (FontWidth+1));\n"
"\n"
"\n"
"\n"
"\n"
"\n"
"	var CounterNameWidthNew = CounterNameWidthTemp * (FontWidth+1);\n"
"	var CounterValueWidthNew = CounterValueWidthTemp * (FontWidth+1);\n"
"	var CounterLimitWidthNew = CounterLimitWidthTemp * (FontWidth+1);\n"
"	if(CounterNameWidthNew != CounterNameWidth || CounterValueWidthNew != CounterValueWidth || CounterLimitWidthNew != CounterLimitWidth)\n"
"	{\n"
"		// console.log(\'requesting redraw 0\' + CounterNameWidthNew + \'= \' + CounterNameWidth );\n"
"		// console.log(\'requesting redraw 1\' + CounterValueWidthNew + \'= \' + CounterValueWidth );\n"
"		// console.log(\'requesting redraw 2\' + CounterLimitWidthNew + \'= \' + CounterLimitWidth );\n"
"		CounterNameWidth = CounterNameWidthNew;\n"
"		CounterValueWidth = CounterValueWidthNew;\n"
"		CounterLimitWidth = CounterLimitWidthNew;\n"
"		Invalidate = 0;\n"
"	}\n"
"\n"
"	ProfileLeave();\n"
"}\n"
"\n"
"\n"
"//preprocess context switch data to contain array per thread\n"
"function PreprocessContextSwitchCacheItem(ThreadId)\n"
"{\n"
"	var CSObject = CSwitchCache[ThreadId];\n"
"	if(ThreadId > 0 && !CSObject)\n"
"	{\n"
"		CSArrayIn = new Array();\n"
"		CSArrayOut = new Array();\n"
"		CSArrayCpu = new Array();\n"
"		var nCount = CSwitchTime.length;\n"
"		var j = 0;\n"
"		var TimeIn = -1.0;\n"
"		for(var i = 0; i < nCount; ++i)\n"
"		{	\n"
"			var ThreadIn = CSwitchThreadInOutCpu[j];\n"
"			var ThreadOut = CSwitchThreadInOutCpu[j+1];\n"
"			var Cpu = CSwitchThreadInOutCpu[j+2];\n"
"			if(TimeIn < 0)\n"
"			{\n"
"				if(ThreadIn == ThreadId)\n"
"				{\n"
"					TimeIn = CSwitchTime[i];\n"
"				}\n"
"			}\n"
"			else\n"
"			{\n"
"				if(ThreadOut == ThreadId)\n"
"				{\n"
"					var TimeOut = CSwitchTime[i];\n"
"					CSArrayIn.push(TimeIn);\n"
"					CSArrayOut.push(TimeOut);\n"
"					CSArrayCpu.push(Cpu);\n"
"					TimeIn = -1;\n"
"				}\n"
"			}\n"
"			j += 3;\n"
"		}\n"
"		CSObject = new Object();\n"
"		CSObject.Size = CSArrayIn.length;\n"
"		CSObject.In = CSArrayIn;\n"
"		CSObject.Out = CSArrayOut;\n"
"		CSObject.Cpu = CSArrayCpu;\n"
"		CSwitchCache[ThreadId] = CSObject;\n"
"	}\n"
"\n"
"}\n"
"function PreprocessContextSwitchCache()\n"
"{\n"
"	ProfileEnter(\"PreprocessContextSwitchCache\");\n"
"	var AllThreads = {};\n"
"	var nCount = CSwitchTime.length;\n"
"	for(var i = 0; i < nCount; ++i)\n"
"	{	\n"
"		var nThreadIn = CSwitchThreadInOutCpu[i];\n"
"		if(!AllThreads[nThreadIn])\n"
"		{\n"
"		    AllThreads[nThreadIn] = \'\' + nThreadIn;\n"
"		    var FoundThread = false;\n"
"		    for(var i = 0; i < ThreadIds.length; ++i)\n"
"		    {\n"
"		        if(ThreadIds[i] == nThreadIn)\n"
"		        {\n"
"		            FoundThread = true;\n"
"		        }\n"
"		    }\n"
"		    if(!FoundThread)\n"
"		    {\n"
"		        CSwitchOnlyThreads.push(nThreadIn);\n"
"		    }\n"
"		}\n"
"	}\n"
"	for(var i = 0; i < CSwitchOnlyThreads.length; ++i)\n"
"	{\n"
"		PreprocessContextSwitchCacheItem(CSwitchOnlyThreads[i]);\n"
"	}\n"
"	for(var i = 0; i < ThreadIds.length; ++i)\n"
"	{\n"
"		PreprocessContextSwitchCacheItem(ThreadIds[i]);	\n"
"	}\n"
"	function HandleMissingThread(a)\n"
"	{\n"
"		if(!CSwitchThreads[a])\n"
"		{\n"
"			CSwitchThreads[a] = {\'tid\':a, \'pid\':-1, \'t\':\'?\', \'p\':\'?\'}\n"
"		}\n"
"	}\n"
"	function CompareThreadInfo(a, b)\n"
"	{\n"
"		if(a.pid != b.pid)\n"
"			return a.pid - b.pid;\n"
"		else\n"
"			return a.tid - b.tid;\n"
"	}\n"
"	CSwitchOnlyThreads.sort( function(a, b){ \n"
"		HandleMissingThread(a);\n"
"		HandleMissingThread(b);\n"
"		return CompareThreadInfo(CSwitchThreads[a], CSwitchThreads[b]); \n"
"	} );\n"
"\n"
"	ProfileLeave();\n"
"}\n"
"\n"
"function DrawContextSwitchBars(context, ThreadId, fScaleX, fOffsetY, fDetailedOffset, nHoverColor, MinWidth, bDrawEnabled)\n"
"{\n"
"	ProfileEnter(\"DrawContextSwitchBars\");\n"
"	var CSObject = CSwitchCache[ThreadId];\n"
"	if(CSObject)\n"
"	{\n"
"		var Size = CSObject.Size;		\n"
"		var In = CSObject.In;\n"
"		var Out = CSObject.Out;\n"
"		var Cpu = CSObject.Cpu;\n"
"		var nNumColors = CSwitchColors.length;\n"
"		for(var i = 0; i < Size; ++i)\n"
"		{\n"
"			var TimeIn = In[i];\n"
"			var TimeOut = Out[i];\n"
"			var ActiveCpu = Cpu[i];\n"
"\n"
"			var X = (TimeIn - fDetailedOffset) * fScaleX;\n"
"			if(X > nWidth)\n"
"			{\n"
"				break;\n"
"			}\n"
"			var W = (TimeOut - TimeIn) * fScaleX;\n"
"			if(W > MinWidth && X+W > 0)\n"
"			{\n"
"				if(nHoverCSCpu == ActiveCpu || bDrawEnabled)\n"
"				{\n"
"					if(nHoverCSCpu == ActiveCpu)\n"
"					{\n"
"						context.fillStyle = nHoverColor;\n"
"					}\n"
"					else\n"
"					{\n"
"						context.fillStyle = CSwitchColors[ActiveCpu % nNumColors];\n"
"					}\n"
"					context.fillRect(X, fOffsetY, W, CSwitchHeight);\n"
"				}\n"
"				if(DetailedViewMouseX >= X && DetailedViewMouse";

const size_t g_MicroProfileHtml_end_1_size = sizeof(g_MicroProfileHtml_end_1);
const char g_MicroProfileHtml_end_2[] =
"X <= X+W && DetailedViewMouseY < fOffsetY+CSwitchHeight && DetailedViewMouseY >= fOffsetY)\n"
"				{\n"
"					nHoverCSCpuNext = ActiveCpu;\n"
"					RangeCpuNext.Begin = TimeIn;\n"
"					RangeCpuNext.End = TimeOut;\n"
"					RangeCpuNext.Thread = ThreadId;\n"
"					RangeGpuNext.Begin = RangeGpuNext.End = -1;\n"
"				}\n"
"			}\n"
"		}\n"
"	}\n"
"	ProfileLeave();\n"
"}\n"
"\n"
"function DrawDetailedView(context, MinWidth, bDrawEnabled)\n"
"{\n"
"	if(bDrawEnabled)\n"
"	{\n"
"		DrawDetailedBackground(context);\n"
"	}\n"
"\n"
"	var colors = [ \'#ff0000\', \'#ff00ff\', \'#ffff00\'];\n"
"	var fScaleX = nWidth / fDetailedRange; \n"
"	var fOffsetY = -nOffsetY + BoxHeight;\n"
"	nHoverTokenNext = -1;\n"
"	nHoverTokenLogIndexNext = -1;\n"
"	nHoverTokenIndexNext = -1;\n"
"	nHoverCounter += nHoverCounterDelta;\n"
"	if(nHoverCounter >= 255) \n"
"	{\n"
"		nHoverCounter = 255;\n"
"		nHoverCounterDelta = -nHoverCounterDelta;\n"
"	}\n"
"	if(nHoverCounter < 128) \n"
"	{\n"
"		nHoverCounter = 128;\n"
"		nHoverCounterDelta = -nHoverCounterDelta;\n"
"	}\n"
"	var nHoverHigh = nHoverCounter.toString(16);\n"
"	var nHoverLow = (127+255-nHoverCounter).toString(16);\n"
"	var nHoverColor = \'#\' + nHoverHigh + nHoverHigh + nHoverHigh;\n"
"	var nHoverColorIndex;\n"
"\n"
"	context.fillStyle = \'black\';\n"
"	context.font = Font;\n"
"	var nNumLogs = Frames[0].ts.length;\n"
"	var fTimeEnd = fDetailedOffset + fDetailedRange;\n"
"\n"
"	var FirstFrame = 0;\n"
"	for(var i = 0; i < Frames.length ; i++)\n"
"	{\n"
"		if(Frames[i].frameend < fDetailedOffset)\n"
"		{\n"
"			FirstFrame = i;\n"
"		}\n"
"	}\n"
"\n"
"	// var BatchesColor = new Array();\n"
"	// var BatchesColorColor = new Array();\n"
"	// var BatchesColorDark = new Array();\n"
"	var Batches = new Array(g_Colors.length+1);\n"
"	var BatchesTxt = new Array();\n"
"	var BatchesTxtPos = new Array();\n"
"	var BatchesTxtColor = [\'#ffffff\', \'#333333\'];\n"
"\n"
"	for(var i = 0; i < 2; ++i)\n"
"	{\n"
"		BatchesTxt[i] = Array();\n"
"		BatchesTxtPos[i] = Array();\n"
"	}\n"
"	for(var i = 0; i < Batches.length; ++i)\n"
"	{\n"
"		Batches[i] = Array();\n"
"	}\n"
"\n"
"\n"
"	var AddBatch = function(index, X, Y, W, Name, NameLen, Duration)\n"
"	{\n"
"		var B = Batches[index];\n"
"		var txtidx = g_ColorsTextIndex[index];\n"
"		if(txtidx < 0 || txtidx > 1)\n"
"			debugger;\n"
"		var BTxt = BatchesTxt[txtidx];\n"
"		var BTxtPos = BatchesTxtPos[txtidx];\n"
"		B.push(X);\n"
"		B.push(Y);\n"
"		B.push(W);\n"
"		DebugDrawQuadCount++;\n"
"\n"
"		var XText = X < 0 ? 0 : X;\n"
"		var WText = W - (XText-X);\n"
"		if(XText + WText > nWidth)\n"
"		{\n"
"			WText = nWidth - XText;\n"
"		}\n"
"		var BarTextLen = Math.floor((WText-2)/FontWidth);\n"
"		var TimeText = TimeToMsString(Duration);\n"
"		var TimeTextLen = TimeText.length;\n"
"\n"
"		if(BarTextLen >= 2)\n"
"		{\n"
"			if(BarTextLen < NameLen)\n"
"				Name = Name.substr(0, BarTextLen);\n"
"			var YPos = Y+BoxHeight-FontAscent;\n"
"			BTxt.push(Name);\n"
"			BTxtPos.push(XText+2);\n"
"\n"
"			BTxtPos.push(YPos);\n"
"			DebugDrawTextCount++;\n"
"			if(BarTextLen - NameLen > TimeTextLen)\n"
"			{\n"
"				BTxt.push(TimeText);\n"
"				BTxtPos.push(XText+WText-2 - TimeTextLen * FontWidth);\n"
"				BTxtPos.push(YPos);\n"
"				DebugDrawTextCount++;\n"
"			}\n"
"		}\n"
"	};\n"
"\n"
"\n"
"\n"
"	{\n"
"		context.fillStyle = \'white\';\n"
"		fOffsetY += BoxHeight;\n"
"		context.fillText(\"Timeline\", 0, fOffsetY);\n"
"		fOffsetY += BoxHeight;\n"
"\n"
"\n"
"		var Times = Timeline.Times;\n"
"		var Colors = Timeline.Colors;\n"
"		var Ends = Timeline.Ends;\n"
"		var Positions = Timeline.Positions;\n"
"		var Names = Timeline.Names;\n"
"		var off = 0.7;\n"
"		var off2 = 2*off;\n"
"		var MaxPosition = 1;\n"
"		for(var i = 0; i < Timeline.Positions.length; ++i)\n"
"		{\n"
"			var TimeStart = Times[i];\n"
"			var TimeEnd = Ends[i];\n"
"			var Position = Positions[i];\n"
"			if(Position >= 0)\n"
"			{\n"
"				MaxPosition = Math.max(Position, MaxPosition);\n"
"				var Color = Colors[i];\n"
"				var Name = Names[i];\n"
"				var P = Positions[i];\n"
"				var X = (TimeStart - fDetailedOffset) * fScaleX;\n"
"				var Y = fOffsetY + P * (BoxHeight+2);\n"
"				var W = (TimeEnd-TimeStart)*fScaleX;\n"
"\n"
"				if(DetailedViewMouseX >= X && DetailedViewMouseX <= X+W && DetailedViewMouseY < Y+BoxHeight && DetailedViewMouseY >= Y)\n"
"				{\n"
"					RangeCpuNext.Begin = TimeStart;\n"
"					RangeCpuNext.End = TimeEnd;\n"
"					RangeCpuNext.Thread = -1;\n"
"					nHoverColorIndex = Color;\n"
"					Color = cidhovercolor;\n"
"				}\n"
"				AddBatch(Color, X, Y, W, Name, Name.length, TimeEnd-TimeStart);\n"
"			}\n"
"		}\n"
"		fOffsetY += (1+MaxPosition) * (BoxHeight+3);\n"
"	}\n"
"	var nMinTimeMs = MinWidth / fScaleX;\n"
"	{\n"
"\n"
"		if(!ThreadY)\n"
"		{\n"
"			ThreadY = new Array(ThreadNames.length+1);\n"
"		}\n"
"\n"
"		for(nLog = 0; nLog < nNumLogs; nLog++)\n"
"		{\n"
"			var ThreadName = ThreadNames[nLog];\n"
"			ThreadY[nLog] = fOffsetY;\n"
"			if(ThreadsAllActive || ThreadsActive[ThreadName])\n"
"			{\n"
"				var LodIndex = 0;\n"
"				var MinDelta = 0;\n"
"				var NextLod = 1;\n"
"				while(NextLod < LodData.length && LodData[NextLod].MinDelta[nLog] < nMinTimeMs)\n"
"				{\n"
"					LodIndex = NextLod;\n"
"					NextLod = NextLod + 1;\n"
"					MinDelta = LodData[LodIndex].MinDelta[nLog];\n"
"				}\n"
"				if(LodIndex == LodData.length)\n"
"				{\n"
"					LodIndex = LodData.length-1;\n"
"				}\n"
"				if(DisableLod)\n"
"				{\n"
"					LodIndex = 0;\n"
"				}\n"
"\n"
"				context.fillStyle = \'white\';\n"
"				fOffsetY += BoxHeight;\n"
"				context.fillText(ThreadName, 0, fOffsetY);\n"
"				if(nContextSwitchEnabled)\n"
"				{\n"
"					DrawContextSwitchBars(context, ThreadIds[nLog], fScaleX, fOffsetY, fDetailedOffset, nHoverColor, MinWidth, bDrawEnabled);\n"
"					fOffsetY += CSwitchHeight+1;\n"
"				}\n"
"				var MaxDepth = 1;\n"
"				var StackPos = 0;\n"
"				var Stack = Array(20);\n"
"				var Lod = LodData[LodIndex];\n"
"\n"
"				var TypeArray = Lod.TypeArray[nLog];\n"
"				var IndexArray = Lod.IndexArray[nLog];\n"
"				var TimeArray = Lod.TimeArray[nLog];\n"
"\n"
"				var LocalFirstFrame = Frames[FirstFrame].FirstFrameIndex[nLog];\n"
"				var IndexStart = ISGPU[nLog] ? 0 : Lod.LogStart[LocalFirstFrame][nLog];\n"
"				var IndexEnd = TimeArray.length;\n"
"				IndexEnd = TimeArray.length;\n"
"				var HasSetHover = 0;\n"
"\n"
"\n"
"				for(var j = IndexStart; j < IndexEnd; ++j)\n"
"				{\n"
"					var type = TypeArray[j];\n"
"					var index = IndexArray[j];\n"
"					var time = TimeArray[j];\n"
"					if(type == 1)\n"
"					{\n"
"						//push\n"
"						Stack[StackPos] = j;\n"
"						StackPos++;\n"
"						if(StackPos > MaxDepth)\n"
"						{\n"
"							MaxDepth = StackPos;\n"
"						}\n"
"					}\n"
"					else if(type == 0)\n"
"					{\n"
"						if(StackPos>0)\n"
"						{\n"
"							StackPos--;\n"
"\n"
"							var StartIndex = Stack[StackPos];\n"
"							var timestart = TimeArray[StartIndex];\n"
"							var timeend = time;\n"
"							var X = (timestart - fDetailedOffset) * fScaleX;\n"
"							var Y = fOffsetY + StackPos * BoxHeight;\n"
"							var W = (timeend-timestart)*fScaleX;\n"
"\n"
"							if(W > MinWidth && X < nWidth && X+W > 0)\n"
"							{\n"
"								if(bDrawEnabled || index == nHoverToken)\n"
"								{\n"
"									var cid = TimerInfo[index].cid;\n"
"									if(index == nHoverToken)\n"
"									{\n"
"										nHoverColorIndex = cid;\n"
"										cid = cidhovercolor;\n"
"									}\n"
"									AddBatch(cid, X, Y, W, TimerInfo[index].name, TimerInfo[index].len, timeend-timestart);\n"
"								}\n"
"\n"
"								if(index == FilterSearchPassIndex)\n"
"								{\n"
"									var Range = RangeInit();\n"
"									Range.Begin = timestart;\n"
"									Range.End = timeend;\n"
"									Range.Thread = nLog;\n"
"									Range.YBegin = Y - ThreadY[nLog];\n"
"\n"
"									if(FilterSearchArray.length < 500)\n"
"									{\n"
"										FilterSearchArray.push(Range);\n"
"										if(FilterSearchArray.length == 500)\n"
"										{\n"
"											ShowFlashMessage(\'Capping Search Result to 500\', 30);\n"
"										}\n"
"									}\n"
"								}\n"
"\n"
"								if(DetailedViewMouseX >= X && DetailedViewMouseX <= X+W && DetailedViewMouseY < Y+BoxHeight && DetailedViewMouseY >= Y)\n"
"								{\n"
"\n"
"									RangeCpuNext.Begin = timestart;\n"
"									RangeCpuNext.End = timeend;\n"
"									RangeCpuNext.Thread = nLog;\n"
"									if(TypeArray[StartIndex+1] == 3 && TypeArray[j+1] == 3)\n"
"									{\n"
"										RangeGpuNext.Begin = RangeCpuNext.Begin;\n"
"										RangeGpuNext.End = RangeCpuNext.End;\n"
"										RangeGpuNext.Thread = nLog;\n"
"										//cpu tick is stored following\n"
"										RangeCpuNext.Begin = TimeArray[StartIndex+1];\n"
"										RangeCpuNext.End = TimeArray[j+1];\n"
"										RangeCpuNext.Thread = IndexArray[StartIndex+1];\n"
"									}\n"
"									else\n"
"									{\n"
"										RangeGpuNext.Begin = -1;\n"
"										RangeGpuNext.End = -1\n"
"									}\n"
"\n"
"									nHoverTokenNext = index;\n"
"									nHoverTokenIndexNext = j;\n"
"									nHoverTokenLogIndexNext = nLog;\n"
"									HasSetHover = 1;\n"
"								}\n"
"							}\n"
"							if(StackPos == 0 && time > fTimeEnd)\n"
"								break;											\n"
"						}\n"
"					}\n"
"				}\n"
"				fOffsetY += (1+g_MaxStack[nLog]) * BoxHeight;\n"
"\n"
"				if(HasSetHover)\n"
"				{\n"
"					for(var i = 0; i < Frames.length-1; ++i)\n"
"					{\n"
"						var IndexStart = Lod.LogStart[i][nLog];\n"
"						if(nHoverTokenIndexNext >= IndexStart)\n"
"						{\n"
"							nHoverFrame = i;\n"
"						}\n"
"					}\n"
"				}\n"
"			}\n"
"			ThreadY[nLog+1] = fOffsetY;\n"
"		}\n"
"\n"
"		if(nContextSwitchEnabled) //non instrumented threads.\n"
"		{\n"
"			var CurrentPid = -112;\n"
"			var ContextSwitchThreads = CSwitchOnlyThreads;\n"
"			function DrawHeader(str, X, Y)\n"
"			{\n"
"				var width = str.length * FontWidth;\n"
"				context.globalAlpha = 0.5;\n"
"				context.fillStyle = \'grey\';\n"
"				context.fillRect(X, Y-FontHeight + 2, width, FontHeight);\n"
"				context.globalAlpha = 1.0;\n"
"				context.fillStyle = \'white\';\n"
"				context.fillText(str, X, Y);\n"
"\n"
"\n"
"			}\n"
"			for(var i = 0; i < ContextSwitchThreads.length; ++i)\n"
"			{\n"
"				var ThreadId = ContextSwitchThreads[i];\n"
"				var ThreadName = \'\' + ThreadId;\n"
"				var TI = CSwitchThreads[ThreadId];\n"
"\n"
"				if(TI)\n"
"				{\n"
"					if(CurrentPid != TI.pid)\n"
"					{\n"
"						fOffsetY += BoxHeight + 1;\n"
"						CurrentPid = TI.pid;\n"
"						var str = TI.pid.toString(16) +\':\' +TI.p;\n"
"						DrawHeader(str, 0, fOffsetY+5);\n"
"						fOffsetY += BoxHeight + 1;\n"
"					}\n"
"				}\n"
"\n"
"				DrawContextSwitchBars(context, ThreadId, fScaleX, fOffsetY, fDetailedOffset, nHoverColor, MinWidth, bDrawEnabled);\n"
"\n"
"				if(TI)\n"
"				{\n"
"					DrawHeader(TI.tid.toString(16) +\':\' +TI.t, 10, fOffsetY+5);\n"
" 				}\n"
"				fOffsetY += BoxHeight + 1;\n"
"			}\n"
"		}\n"
"		var FillRects = function(a, color, colordark)\n"
"		{\n"
"			context.fillStyle = color;\n"
"			for(var j = 0; j < a.length; j += 3)\n"
"			{						\n"
"				var X = a[j];\n"
"				var Y = a[j+1];\n"
"				var W = a[j+2];\n"
"				if(W >= 1)\n"
"				{\n"
"					context.fillRect(X, Y, W, BoxHeight-1);\n"
"				}\n"
"			}\n"
"			// context.fillStyle = color;\n"
"			// for(var j = 0; j < a.length; j += 3)\n"
"			// {						\n"
"			// 	var X = a[j];\n"
"			// 	var Y = a[j+1];\n"
"			// 	var W = a[j+2];\n"
"			// 	if(W > 0)\n"
"			// 	{\n"
"			// 		context.fillRect(X+off, Y+off, W-off2, BoxHeight-1-off2);\n"
"			// 	}\n"
"			// }\n"
"		}\n"
"\n"
"\n"
"		{\n"
"			for(var i = 0; i < Batches.length; ++i)\n"
"			{\n"
"				var a = Batches[i];\n"
"				if(a.length)\n"
"				{\n"
"					if(!DisableMerge)\n"
"					{\n"
"						for(var j = 0; j < a.length; j += 3)\n"
"						{						\n"
"							var X = a[j];\n"
"							var Y = a[j+1];\n"
"							var BaseWidth = j + 2;\n"
"							var W = a[BaseWidth];\n"
"							while(j+1 < a.length && W < 1)\n"
"							{\n"
"								var jnext = j+3;\n"
"								var XNext = a[jnext];\n"
"								var YNext = a[jnext+1];\n"
"								var WNext = a[jnext+2];\n"
"								var Delta = XNext - (X+W);\n"
"								var YDelta = Math.abs(Y - YNext);							\n"
"								if(Delta < 0.3 && YDelta < 0.5 && WNext < 1)\n"
"								{\n"
"									W = (XNext+WNext) - X;\n"
"									a[BaseWidth] = W;\n"
"									a[jnext+2] = 0;\n"
"									j += 3;\n"
"								}\n"
"								else\n"
"								{\n"
"									break;\n"
"								}\n"
"\n"
"							}\n"
"						}\n"
"					}\n"
"					var Color = i == 0 ? nHoverColor : g_Colors[i];\n"
"					var ColorDark = i == 0 ? nHoverColor : g_ColorsDark[i];\n"
"					if(i == 0)\n"
"					{\n"
"						if(nHoverColorIndex)\n"
"						{\n"
"							var mult = nHoverCounter / 255.0;\n"
"							var m2 =mult -0.5;\n"
"							var m4 = m2 * 0.5;\n"
"							var H = g_ColorH[nHoverColorIndex];\n"
"							var S = g_ColorS[nHoverColorIndex];\n"
"							var L = g_ColorL[nHoverColorIndex];\n"
"							var offset = 0;\n"
"							if(S> 0.5)\n"
"								offset = 0.5 - S;\n"
"							var offsetL = 0;\n"
"							if(L > 0.75)\n"
"								offsetL = 0.75 - L;\n"
"							L = L + m4 + offsetL;\n"
"							L = L > 1 ? 1 : (L < 0 ? 0 : L);\n"
"							S = S + m2 + offset;\n"
"							S = S > 1 ? 1 : (S < 0 ? 0 : S);\n"
"							var ColorCV = ConvertHslToColor(H, S, L);\n"
"							// ShowFlashMessage(\'S\' + S + \'H\' + H, 10); \n"
"							ColorDark = Color = ColorCV; ;\n"
"							// console.log(\'hover color string \' + Color + \' ... old \' + \'hsl(\' + H + \',\' + S + \',\' + L + \')\');\n"
"						}\n"
"					}\n"
"					FillRects(a, Color, ColorDark);\n"
"\n"
"				}\n"
"			}	\n"
"		}\n"
"		for(var i = 0; i < BatchesTxt.length; ++i)\n"
"		{\n"
"			context.fillStyle = BatchesTxtColor[i];\n"
"			var TxtArray = BatchesTxt[i];\n"
"			var PosArray = BatchesTxtPos[i];\n"
"			for(var j = 0; j < TxtArray.length; ++j)\n"
"			{\n"
"				var k = j * 2;\n"
"				context.fillText(TxtArray[j], PosArray[k],PosArray[k+1]);\n"
"			}\n"
"		}\n"
"	}\n"
"}\n"
"function DrawTextBox(context, text, x, y, align)\n"
"{\n"
"	var textsize = context.measureText(text).width;\n"
"	var offsetx = 0;\n"
"	var offsety = -FontHeight;\n"
"	if(align == \'center\')\n"
"	{\n"
"		offsetx = -textsize / 2.0;\n"
"	}\n"
"	else if(align == \'right\')\n"
"	{\n"
"		offsetx = -textsize;\n"
"	}\n"
"	context.fillStyle = nBackColors[0];\n"
"	context.fillRect(x + offsetx, y + offsety, textsize+2, FontHeight + 2);\n"
"	context.fillStyle = \'white\';\n"
"	context.fillText(text, x, y);\n"
"\n"
"}\n"
"\n"
"function DrawFilterSearchRanges(context, Ranges, ColorBack, ColorFront, ThreadY)\n"
"{\n"
"	if(0 == Ranges.length)\n"
"		return;\n"
"	//todo: arrow key support \n"
"	var MarginTop = 1.0 * FontHeight;\n"
"	var MarginBottom = nHeight - 1.0 * FontHeight;\n"
"\n"
"\n"
"	var Time = new Date();\n"
"	var Delta = Time - FilterSearchStartTime;\n"
"	var BlinkTime = 2.5 * 1000;\n"
"	var Blinks = 5;\n"
"	var HoverFloat = 0.2;\n"
"	var Blinking = 0;\n"
"	if(Delta < BlinkTime)\n"
"	{\n"
"		Blinking = 1;\n"
"		var b0 = Blinks* Math.PI * Delta;\n"
"		var b1 = b0 / BlinkTime;\n"
"		var Mag = Math.abs(Math.sin(b1));\n"
"		HoverFloat = Mag * 0.5 + 0.2;\n"
"	}\n"
"	var Lines = new Array();\n"
"	var Rects = new Array();\n"
"\n"
"\n"
"	for(var i = 0; i < Ranges.length; ++i)\n"
"	{\n"
"		var Range = Ranges[i];\n"
"		var fBegin = Range.Begin;\n"
"		var fEnd = Range.End;\n"
"		var OffsetTop = Range.YBegin + ThreadY[Range.Thread];\n"
"		var OffsetBottom = OffsetTop + BoxHeight;\n"
"\n"
"		if(fBegin < fEnd)\n"
"		{\n"
"			{\n"
"				OffsetTop = Math.max(OffsetTop, 0);\n"
"				OffsetBottom = Math.max(OffsetBottom, MarginTop);\n"
"				OffsetTop = Math.min(OffsetTop, MarginBottom);\n"
"				OffsetBottom = Math.min(OffsetBottom, nHeight);\n"
"				var fScaleX = nWidth / fDetailedRange; \n"
"				var X = (fBegin - fDetailedOffset) * fScaleX;\n"
"				var Y = OffsetTop;\n"
"				var W = (fEnd - fBegin) * fScaleX;\n"
"				if(W > 1)\n"
"				{\n"
"					Rects.push(X-3);\n"
"					Rects.push(OffsetTop-3);\n"
"					Rects.push(W+5);\n"
"					Rects.push(5 + OffsetBottom - OffsetTop);\n"
"				}\n"
"				else\n"
"				{\n"
"					X += W * 0.5;\n"
"					Lines.push(X);\n"
"					context.beginPath();\n"
"					context.moveTo(X, 0);\n"
"					context.lineTo(X, nHeight);\n"
"					context.stroke();\n"
"				}\n"
"			}\n"
"		}\n"
"	}\n"
"\n"
"	context.fillStyle = ColorBack;\n"
"	context.strokeStyle = ColorBack;\n"
"\n"
"	context.globalAlpha = HoverFloat;\n"
"\n"
"	for(var i = 0; i < Rects.length;)\n"
"	{\n"
"		var X = Rects[i++];\n"
"		var Y = Rects[i++];\n"
"		var W = Rects[i++];\n"
"		var H = Rects[i++];\n"
"		context.fillRect(X, Y, W, H);\n"
"	}\n"
"	context.globalAlpha = 1;\n"
"	for(var i = 0; i < Rects.length;)\n"
"	{\n"
"		var X = Rects[i++];\n"
"		var Y = Rects[i++];\n"
"		var W = Rects[i++];\n"
"		var H = Rects[i++];\n"
"		context.strokeRect(X, Y, W, H);\n"
"	}\n"
"\n"
"	for(var i = 0; i < Lines.length; ++i)\n"
"	{\n"
"		context.beginPath();\n"
"		context.moveTo(Lines[i], 0);\n"
"		context.lineTo(Lines[i], nHeight);\n"
"		context.stroke();\n"
"	}\n"
"	if(Blinking>0)\n"
"	{\n"
"		Invalidate = 1;\n"
"	}\n"
"\n"
"}\n"
"\n"
"\n"
"function DrawRange(context, Range, ColorBack, ColorFront, Name, Offset)\n"
"{\n"
"	if(!Offset)\n"
"		Offset = 0;\n"
"	var fBegin = Range.Begin;\n"
"	var fEnd = Range.End;\n"
"	var OffsetTop = Range.YBegin;\n"
"	var OffsetBottom = Range.YEnd;\n"
"	if(fBegin < fEnd)\n"
"	{\n"
"		var MarginTop = (1.0+Offset) * (FontHeight+1);\n"
"		var MarginBottom = nHeight - (Offset+1.5) * (FontHeight+1);\n"
"		if(OffsetTop < MarginTop)\n"
"		{\n"
"			Offset += 1;\n"
"			OffsetTop = MarginTop;\n"
"		}\n"
"		if(OffsetBottom > MarginBottom)\n"
"		{\n"
"			OffsetBottom = MarginBottom;\n"
"		}\n"
"		var fRulerOffset = FontHeight * 0.5;\n"
"		var fScaleX = nWidth / fDetailedRange; \n"
"		var X = (fBegin - fDetailedOffset) * fScaleX;\n"
"		var YSpace = (FontHeight+2);\n"
"		var Y = OffsetTop;\n"
"		var YBottom = OffsetBottom;\n"
"		var W = (fEnd - fBegin) * fScaleX;\n"
"		context.globalAlpha = 0.1;\n"
"		context.fillStyle = ColorBack;\n"
"		context.fillRect(X, OffsetTop + fRulerOffset, W, OffsetBottom - OffsetTop);\n"
"		context.globalAlpha = 1;\n"
"		context.strokeStyle = ColorFront;\n"
"		context.beginPath();\n"
"		context.moveTo(X, 0);\n"
"		context.lineTo(X, nHeight);\n"
"		context.moveTo(X+W, 0);\n"
"		context.lineTo(X+W, nHeight);\n"
"		context.stroke();\n"
"		var Duration = (fEnd - fBegin).toFixed(2) + \"ms\";\n"
"		var Center = ((fBegin + fEnd) / 2.0) - fDetailedOffset;\n"
"		var DurationWidth = context.measureText(Duration+ \"   \").width;\n"
"\n"
"		context.fillStyle = \'white\';\n"
"		context.textAlign = \'right\';\n"
"		var TextPosY = Y + YSpace;\n"
"		DrawTextBox(context, fBegin.toFixed(2), X-3, TextPosY, \'right\');\n"
"		var YS = [Y, YBottom];\n"
"		for(var i = 0; i < YS.length; ++i)\n"
"		{\n"
"			var Y = YS[i];\n"
"			var Y0 = Y + fRulerOffset;\n"
"			var W0 = W - DurationWidth + FontWidth*1.5;\n"
"			if(W0 > 6)\n"
"			{\n"
"				context.textAlign = \'center\';\n"
"				DrawTextBox(context, Duration,Center * fScaleX, Y + YSpace, \'center\');\n"
"				W0 = W0 / 2.0;\n"
"				var X0 = X + W0;\n"
"				var X1 = X + W - W0;\n"
"				context.strokeStyle = ColorFront;\n"
"				context.beginPath();\n"
"				context.moveTo(X, Y0);\n"
"				context.lineTo(X0, Y0);\n"
"				context.moveTo(X0, Y0-2);\n"
"				context.lineTo(X0, Y0+2);\n"
"				context.moveTo(X1, Y0-2);\n"
"				context.lineTo(X1, Y0+2);\n"
"				context.moveTo(X1, Y0);\n"
"				context.lineTo(X + W, Y0);\n"
"				context.stroke();\n"
"			}\n"
"			else\n"
"			{\n"
"				if(i == 1)\n"
"				{\n"
"					context.textAlign = \'right\';\n"
"					DrawTextBox(context, Duration, X - 3, Y0, \'right\');\n"
"					context.textAlign = \'left\';\n"
"					DrawTextBox(context, Duration, X + W + 2, Y0, \'left\');\n"
"				}\n"
"				context.strokeStyle = ColorFront;\n"
"				context.beginPath();\n"
"				context.moveTo(X, Y0);\n"
"				context.lineTo(X+W, Y0);\n"
"				context.stroke();\n"
"			}\n"
"		}\n"
"		context.textAlign = \'left\';\n"
"		DrawTextBox(context, fEnd.toFixed(2), X + W + 2, TextPosY, \'left\');\n"
"		DrawTextBox(context, Name, X + W + 2, OffsetTop + YSpace + FontHeight, \'left\');\n"
"	}\n"
"	return Offset;\n"
"}\n"
"\n"
"function DrawDetailed(Animation)\n"
"{\n"
"	if(AnimationActive != Animation || !Initialized)\n"
"	{\n"
"		return;\n"
"	}\n"
"	ProfileEnter(\"DrawDetailed\");\n"
"	DebugDrawQuadCount = 0;\n"
"	DebugDrawTextCount = 0;\n"
"	nHoverCSCpuNext = -1;\n"
"\n"
"	RangeCpuNext = RangeInit();\n"
"	RangeGpuNext = RangeInit();\n"
"\n"
"	var start = new Date();\n"
"	nDrawCount++;\n"
"\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"	var offscreen = CanvasDetailedOffscreen.getContext(\'2d\');\n"
"	var fScaleX = nWidth / fDetailedRange; \n"
"	var fOffsetY = -nOffsetY + BoxHeight;\n"
"\n"
"	if(DetailedRedrawState.fOffsetY == fOffsetY && DetailedRedrawState.fDetailedOffset == fDetailedOffset && DetailedRedrawState.fDetailedRange == fDetailedRange && !KeyCtrlDown && !KeyShiftDown && !MouseDragButton)\n"
"	{\n"
"		Invalidate++;\n"
"	}\n"
"	else\n"
"	{\n"
"		Invalidate = 0;\n"
"		DetailedRedrawState.fOffsetY = fOffsetY;\n"
"		DetailedRedrawState.fDetailedOffset = fDetailedOffset;\n"
"		DetailedRedrawState.fDetailedRange = fDetailedRange;\n"
"	}\n"
"	if(nHoverTokenDrawn != nHoverToken)\n"
"	{\n"
"		Invalidate = 1;\n"
"	}\n"
"	nHoverTokenDrawn = nHoverToken;\n"
"	if(Invalidate == 0) //when panning, only draw bars that are a certain width to keep decent framerate\n"
"	{\n"
"		context.clearRect(0, 0, CanvasDetailedView.width, CanvasDetailedView.height);\n"
"		DrawDetailedView(context, nMinWidthPan, true);\n"
"		ProfileRedraw0++;\n"
"	}\n"
"	else if(Invalidate == 1) //draw full and store\n"
"	{\n"
"		offscreen.clearRect(0, 0, CanvasDetailedView.width, CanvasDetailedView.height);\n"
"		DrawDetailedView(offscreen, nMinWidth, true);\n"
"		OffscreenData = offscreen.getImageData(0, 0, CanvasDetailedOffscreen.width, CanvasDetailedOffscreen.height);\n"
"		ProfileRedraw1++;\n"
"	}\n"
"	else//reuse stored result untill next time viewport is changed.\n"
"	{\n"
"		context.clearRect(0, 0, CanvasDetailedView.width, CanvasDetailedView.height);\n"
"		context.putImageData(OffscreenData, 0, 0);\n"
"		DrawDetailedView(context, nMinWidth, false);\n"
"		ProfileRedraw2++;\n"
"	}\n"
"\n"
"	if(KeyShiftDown || KeyCtrlDown || MouseDragSelectRange() || ZoomActive || FilterSearchActive)\n"
"	{\n"
"		nHoverToken = -1;\n"
"		nHoverTokenIndex = -1;\n"
"		nHoverTokenLogIndex = -1;\n"
"		RangeCpu = RangeInit();\n"
"		RangeGpu = RangeInit();\n"
"	}\n"
"	else\n"
"	{\n"
"		nHoverToken = nHoverTokenNext;\n"
"		nHoverTokenIndex = nHoverTokenIndexNext;\n"
"		nHoverTokenLogIndex = nHoverTokenLogIndexNext;\n"
"		if(RangeValid(RangeCpuHistory))\n"
"		{\n"
"			RangeCopy(RangeCpu, RangeCpuHistory);\n"
"			RangeCopy(RangeGpu, RangeGpuHistory);\n"
"		}\n"
"		else\n"
"		{\n"
"			RangeCopy(RangeCpu, RangeCpuNext);\n"
"			RangeCopy(RangeGpu, RangeGpuNext);\n"
"		}\n"
"	}\n"
"\n"
"	DrawTextBox(context, TimeToMsString(fDetailedOffset), 0, FontHeight, \'left\');\n"
"	context.textAlign = \'right\';\n"
"	DrawTextBox(context, TimeToMsString(fDetailedOffset + fDetailedRange), nWidth, FontHeight, \'right\');\n"
"	context.textAlign = \'left\';\n"
"\n"
"	var YBegin = ThreadY[fRangeThreadIdNext];\n"
"	var YEnd = ThreadY[fRangeThreadIdNext+1];\n"
"	var YBeginGpu = YBegin;\n"
"	var YEndGpu = YEnd;\n"
"	function RangeSet(R)\n"
"	{\n"
"		if(R.Thread >= 0)\n"
"		{\n"
"			R.YBegin = ThreadY[R.Thread];\n"
"			R.YEnd = ThreadY[R.Thread + 1];\n"
"		}\n"
"		else\n"
"		{\n"
"			R.YBegin = 0;\n"
"			R.YEnd = nHeight;\n"
"		}\n"
"	}\n"
"	RangeSet(RangeSelect);\n"
"	RangeSet(RangeCpu);\n"
"	RangeSet(RangeGpu);\n"
"	var Offset = 0;\n"
"	Offset = DrawRange(context, RangeSelect, \'#59d0ff\', \'#00ddff\', \"Selection\", Offset);\n"
"	Offset = DrawRange(context, RangeCpu, \'#009900\', \'#00ff00\', \"Cpu\", Offset);\n"
"	Offset = DrawRange(context, RangeGpu, \'#996600\', \'#775500\', \"Gpu\", Offset);\n"
"\n"
"	DrawFilterSearchRanges(context, FilterSearchArray, \'#ff9900\', \'#ff9900\', ThreadY);\n"
"\n"
"	nHoverCSCpu = nHoverCSCpuNext;\n"
"\n"
"	DrawFilterSearch();\n"
"\n"
"\n"
"	ProfileLeave();\n"
"}\n"
"function ZoomToHighlight(NoGpu)\n"
"{\n"
"	if(RangeValid(RangeGpu) && !NoGpu)\n"
"	{\n"
"		ZoomTo(RangeGpu.Begin, RangeGpu.End);\n"
"	}\n"
"	else if(RangeValid(RangeCpu))\n"
"	{\n"
"		ZoomTo(RangeCpu.Begin, RangeCpu.End);\n"
"	}\n"
"	RangeCpu = RangeInit();\n"
"	RangeGpu = RangeInit();\n"
"}\n"
"\n"
"function MoveToNext(Direction) //1 forward, -1 backwards\n"
"{\n"
"	var fTimeBegin, fTimeEnd, nLog;\n"
"	var Index = nHoverToken;\n"
"\n"
"	if(nHoverToken != -1 && nHoverTokenLogIndex != -1)\n"
"	{\n"
"		fTimeBegin = RangeCpu.Begin;\n"
"		fTimeEnd = RangeCpu.End;\n"
"		nLog = nHoverTokenLogIndex;\n"
"	}\n"
"	else if(RangeValid(RangeSelect))\n"
"	{\n"
"		fTimeBegin = RangeSelect.Begin;\n"
"		fTimeEnd = RangeSelect.End;\n"
"		nLog = RangeSelect.Thread;\n"
"		Index = RangeSelect.Index;\n"
"	}\n"
"	else\n"
"	{\n"
"		return;\n"
"	}\n"
"	if(nLog<0)\n"
"	{\n"
"		return;\n"
"	}\n"
"	var Forward = Direction && Direction < 0 ? 0 : 1;\n"
"	var bFound = false;\n"
"	var nStackPos = 0;\n"
"	var fResultTimeBegin, fResultTimeEnd;\n"
"	var TypeBegin = Forward ? 1 : 0;\n"
"	var TypeEnd = Forward ? 0 : 1;\n"
"	var SearchTimeBegin = Forward ? fTimeBegin : fTimeEnd;\n"
"\n"
"	var istart = Forward ? 0 : Frames.length-1;\n"
"	var iend = Forward ? Frames.length : -1;\n"
"	var idelta = Forward ? 1 : -1;\n"
"	for(var i = istart; i != iend; i += idelta)\n"
"	{\n"
"		var fr = Frames[i];\n"
"		var ts = fr.ts[nLog];\n"
"		var ti = fr.ti[nLog];\n"
"		var tt = fr.tt[nLog];\n"
"		var jstart = Forward ? 0 : ts.length-1;\n"
"		var jend = Forward ? ts.length : -1;\n"
"		var jdelta = Forward ? 1 : -1;\n"
"		for(var j = jstart; j != jend; j += jdelta)\n"
"		{\n"
"			if(!bFound)\n"
"			{\n"
"				if(tt[j] == TypeBegin && Index == ti[j])\n"
"				{\n"
"					if(SearchTimeBegin == ts[j])\n"
"					{\n"
"						bFound = true;\n"
"					}\n"
"				}\n"
"			}\n"
"			else\n"
"			{\n"
"				if(Index == ti[j])\n"
"				{\n"
"					var type = tt[j];\n"
"					if(type == TypeBegin)\n"
"					{\n"
"						if(0 == nStackPos)\n"
"						{\n"
"							fResultTimeBegin = ts[j];\n"
"						}\n"
"						nStackPos++;\n"
"					}\n"
"					else if(type == TypeEnd && nStackPos)\n"
"					{\n"
"						nStackPos--;\n"
"						if(0 == nStackPos)\n"
"						{\n"
"							fResultTimeEnd = ts[j];\n"
"							if(0 == Forward)\n"
"							{\n"
"								var Tmp = fResultTimeBegin;\n"
"								fResultTimeBegin = fResultTimeEnd;\n"
"								fResultTimeEnd = Tmp;\n"
"							}\n"
"							RangeSelect.Begin = fResultTimeBegin;\n"
"							RangeSelect.End = fResultTimeEnd;\n"
"							RangeSelect.Thread = nLog;\n"
"							RangeSelect.Index = Index;\n"
"							MoveTo(fResultTimeBegin,fResultTimeEnd);\n"
"							return;\n"
"						}\n"
"					}\n"
"				}\n"
"			}\n"
"		}\n"
"	}\n"
"}\n"
"\n"
"function MoveTo(fMoveBegin, fMoveEnd, YTop, YBottom)\n"
"{\n"
"	var nOffsetYBottom = YBottom - nHeight;\n"
"	var nOffsetYDest = nOffsetY;\n"
"	if(nOffsetYDest < nOffsetYBottom)\n"
"	{\n"
"		nOffsetYDest = nOffsetYBottom;\n"
"	}\n"
"	if(nOffsetYDest > YTop)\n"
"	{	\n"
"		nOffsetYDest = YTop;\n"
"	}\n"
"	var fRange = fDetailedRange;\n"
"	var fMinRange = (fMoveEnd-fMoveBegin) * 2.0;\n"
"	if(fRange < fMinRange)\n"
"	{\n"
"		fRange = fMinRange;\n"
"	}\n"
"	var fMoveCenter = (fMoveBegin + fMoveEnd) * 0.5;\n"
"	fMoveBegin = fMoveCenter - 0.5 * fRange;\n"
"	fMoveEnd = fMoveCenter + 0.5 * fRange;\n"
"	var nOffset;\n"
"	if(nOffsetYDest != nOffsetY)\n"
"		nOffset = nOffsetYDest;\n"
"	ZoomTo(fMoveBegin, fMoveEnd, nOffsetYDest, -1);\n"
"}\n"
"function ZoomTo(fZoomBegin, fZoomEnd, OffsetYDest, ZoomTime)\n"
"{\n"
"	if(fZoomBegin < fZoomEnd)\n"
"	{\n"
"		AnimationActive = true;\n"
"		var fDetailedOffsetOriginal = fDetailedOffset;\n"
"		var fDetailedRangeOriginal = fDetailedRange;\n"
"		var fDetailedOffsetTarget = fZoomBegin;\n"
"		var fDetailedRangeTarget = fZoomEnd - fZoomBegin;\n"
"		var OffsetYOriginal = nOffsetY;\n"
"		var OffsetYTarget = OffsetYDest;\n"
"		var TimestampStart = new Date();\n"
"		var count = 0;\n"
"		if(!ZoomTime)\n"
"		{			\n"
"			ZoomTime = ZOOM_TIME;\n"
"		}\n"
"\n"
"		function ZoomFunc(Timestamp)\n"
"		{\n"
"			ZoomActive = 1;\n"
"			var fPrc = (new Date() - TimestampStart) / (ZoomTime * 1000.0);\n"
"			if(fPrc > 1.0 || ZoomTime < 0.01)\n"
"			{\n"
"				fPrc = 1.0;\n"
"			}\n"
"			fPrc = Math.pow(fPrc, 0.3);\n"
"			fDetailedOffset = fDetailedOffsetOriginal + (fDetailedOffsetTarget - fDetailedOffsetOriginal) * fPrc;\n"
"			fDetailedRange = fDetailedRangeOriginal + (fDetailedRangeTarget - fDetailedRangeOriginal) * fPrc;\n"
"			if(OffsetYDest)\n"
"			{\n"
"				nOffsetY = OffsetYOriginal + (OffsetYTarget - OffsetYOriginal) * fPrc;\n"
"			}\n"
"			DrawDetailed(true);\n"
"			if(fPrc >= 1.0)\n"
"			{\n"
"				AnimationActive = false;\n"
"				fDetailedOffset = fDetailedOffsetTarget;\n"
"				fDetailedRange = fDetailedRangeTarget;\n"
"				if(OffsetYDest)\n"
"				{\n"
"					nOffsetY = OffsetYTarget;\n"
"				}\n"
"			}\n"
"			else\n"
"			{\n"
"				requestAnimationFrame(ZoomFunc);\n"
"			}\n"
"		}\n"
"		requestAnimationFrame(ZoomFunc);\n"
"	}\n"
"}\n"
"function RequestRedraw()\n"
"{\n"
"	Invalidate = 0;\n"
"	Draw(1);\n"
"}\n"
"function Draw(RedrawMode)\n"
"{\n"
"	if(!Initialized)\n"
"	{\n"
"		return;\n"
"	}\n"
"	if(ProfileMode)\n"
"	{\n"
"		ProfileModeClear();\n"
"		ProfileEnter(\"Total\");\n"
"	}\n"
"	if(RedrawMode == 1)\n"
"	{\n"
"		if(Mode == ModeTimers)\n"
"		{\n"
"			DrawBarView();\n"
"			DrawHoverToolTip();\n"
"		}\n"
"		else if(Mode == ModeDetailed)\n"
"		{\n"
"			DrawDetailed(false);\n"
"			DrawHoverToolTip();\n"
"		}\n"
"		else if(Mode == ModeCounters)\n"
"		{\n"
"			DrawCounterView();\n"
"			DrawHoverToolTip();\n"
"		}\n"
"	}\n"
"	DrawDetailedFrameHistory();\n"
"\n"
"	if(ProfileMode)\n"
"	{\n"
"		ProfileLeave();\n"
"		ProfileModeDraw(CanvasDetailedView);\n"
"	}\n"
"}\n"
"\n"
"function AutoRedraw(Timestamp)\n"
"{\n"
"	var RedrawMode = 0;\n"
"	if(Mode == ModeDetailed)\n"
"	{\n"
"		if(ProfileMode == 2 || ((nHoverCSCpu >= 0 || nHoverToken != -1) && !KeyCtrlDown && !KeyShiftDown && !MouseDragButton)||(Invalidate<2 && !KeyCtrlDown && !KeyShiftDown && !MouseDragButton))\n"
"		{\n"
"			RedrawMode = 1;\n"
"		}\n"
"	}\n"
"	else\n"
"	{\n"
"		if(Invalidate < 1)\n"
"		{\n"
"			RedrawMode = 1;\n"
"		}\n"
"	}\n"
"	if(RedrawMode)\n"
"	{\n"
"		Draw(RedrawMode);\n"
"	}\n"
"	else if(FlashFrameCounter>0)\n"
"	{\n"
"		Draw(0);\n"
"	}\n"
"	requestAnimationFrame(AutoRedraw);\n"
"}\n"
"\n"
"\n"
"function ZoomGraph(nZoom)\n"
"{\n"
"	var fOldRange = fDetailedRange;\n"
"	if(nZoom>0)\n"
"	{\n"
"		fDetailedRange *= Math.pow(nModDown ? 1.40 : 1.03, nZoom);\n"
"	}\n"
"	else\n"
"	{\n"
"		var fNewDetailedRange = fDetailedRange / Math.pow((nModDown ? 1.40 : 1.03), -nZoom);\n"
"		if(fNewDetailedRange < 0.0001) //100ns\n"
"			fNewDetailedRange = 0.0001;\n"
"		fDetailedRange = fNewDetailedRange;\n"
"	}\n"
"\n"
"	var fDiff = fOldRange - fDetailedRange;\n"
"	var fMousePrc = DetailedViewMouseX / nWidth;\n"
"	if(fMousePrc < 0)\n"
"	{\n"
"		fMousePrc = 0;\n"
"	}\n"
"	fDetailedOffset += fDiff * fMousePrc;\n"
"\n"
"}\n"
"\n"
"function MeasureFont()\n"
"{\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"	context.font = Font;\n"
"	FontWidth = context.measureText(\'W\').width;\n"
"\n"
"}\n"
"function ResizeCanvas() \n"
"{\n"
"	nWidth = window.innerWidth;\n"
"	nHeight = window.innerHeight - CanvasHistory.height-2;\n"
"	DPR = window.devicePixelRatio;\n"
"\n"
"	if(DPR)\n"
"	{\n"
"		CanvasDetailedView.style.width = nWidth + \'px\'; \n"
"		CanvasDetailedView.style.height = nHeight + \'px\';\n"
"		CanvasDetailedView.width = nWidth * DPR;\n"
"		CanvasDetailedView.height = nHeight * DPR;\n"
"		CanvasHistory.style.width = window.innerWidth + \'px\';\n"
"		CanvasHistory.style.height = 70 + \'px\';\n"
"		CanvasHistory.width = window.innerWidth * DPR;\n"
"		CanvasHistory.height = 70 * DPR;\n"
"		CanvasHistory.getContext(\'2d\').scale(DPR,DPR);\n"
"		CanvasDetailedView.getContext(\'2d\').scale(DPR,DPR);\n"
"\n"
"		CanvasDetailedOffscreen.style.width = nWidth + \'px\';\n"
"		CanvasDetailedOffscreen.style.height = nHeight + \'px\';\n"
"		CanvasDetailedOffscreen.width = nWidth * DPR;\n"
"		CanvasDetailedOffscreen.height = nHeight * DPR;\n"
"		CanvasDetailedOffscreen.getContext(\'2d\').scale(DPR,DPR);\n"
"\n"
"	}\n"
"	else\n"
"	{\n"
"		DPR = 1;\n"
"		CanvasDetailedView.width = nWidth;\n"
"		CanvasDetailedView.height = nHeight;\n"
"		CanvasDetailedOffscreen.width = nWidth;\n"
"		CanvasDetailedOffscreen.height = nHeight;\n"
"		CanvasHistory.width = window.innerWidth;\n"
"	}\n"
"	RequestRedraw();\n"
"}\n"
"\n"
"var MouseDragOff = 0;\n"
"var MouseDragDown = 1;\n"
"var MouseDragUp = 2;\n"
"var MouseDragMove = 3;\n"
"var MouseDragState = MouseDragOff;\n"
"var MouseDragTarget = 0;\n"
"var MouseDragButton = 0;\n"
"var MouseDragKeyShift = 0;\n"
"var MouseDragKeyCtrl = 0;\n"
"var MouseDragX = 0;\n"
"var MouseDragY = 0;\n"
"var MouseDragXLast = 0;\n"
"var MouseDragYLast = 0;\n"
"var MouseDragXStart = 0;\n"
"var MouseDragYStart = 0;\n"
"\n"
"function clamp(number, min, max)\n"
"{\n"
"  return Math.max(min, Math.min(number, max));\n"
"}\n"
"\n"
"function MouseDragPan()\n"
"{\n"
"	return MouseDragButton == 1 || MouseDragKeyShift;\n"
"}\n"
"function MouseDragSelectRange()\n"
"{\n"
"	return MouseDragState == MouseDragMove && (MouseDragButton == 3 || (MouseDragKeyShift && MouseDragKeyCtrl));\n"
"}\n"
"function MouseHandleDrag()\n"
"{\n"
"	if(MouseDragTarget == CanvasDetailedView)\n"
"	{\n"
"		if(Mode == ModeDetailed)\n"
"		{\n"
"\n"
"			if(FilterSearchActive)\n"
"			{\n"
"				if(MouseDragKeyShift || MouseDragButton == 1)\n"
"				{\n"
"					var Y = MouseDragY - MouseDragYLast;\n"
"					nOffsetFilterSearch -= Y;\n"
"					if(nOffsetFilterSearch < 0)\n"
"					{\n"
"						nOffsetFilterSearch = 0;\n"
"					}\n"
"				}\n"
"			}\n"
"			else\n"
"			{\n"
"				if(MouseDragSelectRange())\n"
"				{\n"
"					var xStart = MouseDragXStart;\n"
"					var xEnd = MouseDragX;\n"
"					if(xStart > xEnd)\n"
"					{\n"
"						var Temp = xStart;\n"
"						xStart = xEnd;\n"
"						xEnd = Temp;\n"
"					}\n"
"					if(xEnd - xStart > 1)\n"
"					{\n"
"						RangeCpu.Begin = fDetailedOffset + fDetailedRange * (xStart / nWidth);\n"
"						RangeCpu.End = fDetailedOffset + fDetailedRange * (xEnd / nWidth);\n"
"						RangeSelect.Begin = fDetailedOffset + fDetailedRange * (xStart / nWidth);\n"
"						RangeSelect.End = fDetailedOffset + fDetailedRange * (xEnd / nWidth);\n"
"						RangeSelect.Thread = -1;\n"
"						RangeSelect.Index = -1;\n"
"					}\n"
"				}\n"
"				else if(MouseDragPan())\n"
"				{\n"
"					var X = MouseDragX - MouseDragXLast;\n"
"					var Y = MouseDragY - MouseDragYLast;\n"
"					if(X)\n"
"					{\n"
"						fDetailedOffset += -X * fDetailedRange / nWidth;\n"
"					}\n"
"					nOffsetY -= Y;\n"
"					if(nOffsetY < 0)\n"
"					{\n"
"						nOffsetY = 0;\n"
"					}\n"
"				}\n"
"				else if(MouseDragKeyCtrl)\n"
"				{\n"
"					if(MouseDragY != MouseDragYLast)\n"
"					{\n"
"						ZoomGraph(MouseDragY - MouseDragYLast);\n"
"					}\n"
"				}\n"
"			}	\n"
"		}\n"
"		else if(Mode == ModeTimers)\n"
"		{\n"
"			if(MouseDragKeyShift || MouseDragButton == 1)\n"
"			{\n"
"				var X = MouseDragX - MouseDragXLast;\n"
"				var Y = MouseDragY - MouseDragYLast;\n"
"				nOffsetBarsY -= Y;\n"
"				nOffsetBarsX -= X;\n"
"				if(nOffsetBarsY < 0)\n"
"				{\n"
"					nOffsetBarsY = 0;\n"
"				}\n"
"				if(nOffsetBarsX < 0)\n"
"				{\n"
"					nOffsetBarsX = 0;\n"
"				}\n"
"			}\n"
"		}\n"
"		else if(Mode == ModeCounters)\n"
"		{\n"
"			if(MouseDragKeyShift || MouseDragButton == 1)\n"
"			{\n"
"				var Y = MouseDragY - MouseDragYLast;\n"
"				nOffsetCountersY -= Y;\n"
"				if(nOffsetCountersY < 0)\n"
"				{\n"
"					nOffsetCountersY = 0;\n"
"				}\n"
"			}\n"
"		}\n"
"\n"
"	}\n"
"	else if(MouseDragTarget == CanvasHistory)\n"
"	{\n"
"		function HistoryFrameTime(x)\n"
"		{\n"
"			var NumFrames = Frames.length;\n"
"			var fBarWidth = nWidth / NumFrames;\n"
"			var Index = clamp(Math.floor(NumFrames * x / nWidth), 0, NumFrames-1);\n"
"			var Lerp = clamp((x/fBarWidth - Index) , 0, 1);\n"
"			var time = Frames[Index].framestart + (Frames[Index].frameend - Frames[Index].framestart) * Lerp;\n"
"			return time;\n"
"		}\n"
"		if(MouseDragSelectRange())\n"
"		{\n"
"			RangeCpu = RangeInit();\n"
"			RangeGpu = RangeInit();\n"
"\n"
"			var xStart = MouseDragXStart;\n"
"			var xEnd = MouseDragX;\n"
"			if(xStart > xEnd)\n"
"			{\n"
"				var Temp = xStart;\n"
"				xStart = xEnd;\n"
"				xEnd = Temp;\n"
"			}\n"
"			if(xEnd - xStart > 2)\n"
"			{\n"
"				var timestart = HistoryFrameTime(xStart);\n"
"				var timeend = HistoryFrameTime(xEnd);\n"
"				fDetailedOffset = timestart;\n"
"				fDetailedRange = timeend-timestart;\n"
"			}\n"
"		}\n"
"		else if(MouseDragPan())\n"
"		{\n"
"			var Time = HistoryFrameTime(MouseDragX);\n"
"			fDetailedOffset = Time - fDetailedRange / 2.0;\n"
"		}\n"
"	}\n"
"}\n"
"function MouseHandleDragEnd()\n"
"{\n"
"	if(MouseDragTarget == CanvasDetailedView)\n"
"	{\n"
"\n"
"	}\n"
"	else if(MouseDragTarget == CanvasHistory)\n"
"	{\n"
"		if(!MouseDragSelectRange() && !MouseDragPan())\n"
"		{\n"
"			ZoomToHighlight(1);\n"
"		}\n"
"	}\n"
"}\n"
"\n"
"function MouseHandleDragClick()\n"
"{\n"
"	if(MouseDragTarget == CanvasDetailedView)\n"
"	{\n"
"		if(Mode == ModeCounters)\n"
"		{\n"
"			if(nHoverCounter != -1)\n"
"			{\n"
"				if(CounterInfo[nHoverCounter].firstchild != -1)\n"
"				{\n"
"					CounterInfo[nHoverCounter].closed = !CounterInfo[nHoverCounter].closed;\n"
"				}\n"
"				else\n"
"				{\n"
"					CounterInfo[nHoverCounter].Expanded = !CounterInfo[nHoverCounter].Expanded;\n"
"				}\n"
"				Draw(1);\n"
"			}\n"
"		}\n"
"		else if(Mode == ModeDetailed && FilterSearchSelection >= 0)\n"
"		{\n"
"			FilterInputCommit();\n"
"		}\n"
"		else\n"
"		{\n"
"			ZoomToHighlight();\n"
"		}\n"
"	}\n"
"	else if(MouseDragTarget == CanvasHistory)\n"
"	{\n"
"		if(Mode == ModeDetailed)\n"
"		{\n"
"			ZoomToHighlight(1);\n"
"		}\n"
"	}\n"
"}\n"
"\n"
"function MapMouseButton(Event)\n"
"{\n"
"	if(event.button == 1 || event.which == 1)\n"
"	{\n"
"		return 1;\n"
"	}\n"
"	else if(event.button == 3 || event.which == 3)\n"
"	{\n"
"		return 3;\n"
"	}\n"
"	else\n"
"	{\n"
"		return 0;\n"
"	}\n"
"}\n"
"\n"
"function MouseDragReset()\n"
"{\n"
"	MouseDragState = MouseDragOff;\n"
"	";

const size_t g_MicroProfileHtml_end_2_size = sizeof(g_MicroProfileHtml_end_2);
const char g_MicroProfileHtml_end_3[] =
"MouseDragTarget = 0;\n"
"	MouseDragKeyShift = 0;\n"
"	MouseDragKeyCtrl = 0;\n"
"	MouseDragButton = 0;\n"
"}\n"
"function MouseDragKeyUp()\n"
"{\n"
"	if((MouseDragKeyShift && !KeyShiftDown) || (MouseDragKeyCtrl && !KeyCtrlDown))\n"
"	{\n"
"		MouseHandleDragEnd();\n"
"		MouseDragReset();\n"
"	}\n"
"}\n"
"function MouseDrag(Source, Event)\n"
"{\n"
"	if(Source == MouseDragOff || (MouseDragTarget && MouseDragTarget != Event.target))\n"
"	{\n"
"		MouseDragReset();\n"
"		return;\n"
"	}\n"
"\n"
"	var LocalRect = Event.target.getBoundingClientRect();\n"
"	MouseDragX = Event.clientX - LocalRect.left;\n"
"	MouseDragY = Event.clientY - LocalRect.top;\n"
"	if(MouseDragState == MouseDragMove)\n"
"	{\n"
"		var dx = Math.abs(MouseDragX - MouseDragXStart);\n"
"		var dy = Math.abs(MouseDragY - MouseDragYStart);\n"
"		if((Source == MouseDragUp && MapMouseButton(Event) == MouseDragButton) ||\n"
"			(MouseDragKeyCtrl && !KeyCtrlDown) ||\n"
"			(MouseDragKeyShift && !KeyShiftDown))\n"
"		{\n"
"			MouseHandleDragEnd();\n"
"			MouseDragReset();\n"
"			return;\n"
"		}\n"
"		else\n"
"		{\n"
"			MouseHandleDrag();\n"
"		}\n"
"	}\n"
"	else if(MouseDragState == MouseDragOff)\n"
"	{\n"
"		if(Source == MouseDragDown || KeyShiftDown || KeyCtrlDown)\n"
"		{\n"
"			MouseDragTarget = Event.target;\n"
"			MouseDragButton = MapMouseButton(Event);\n"
"			MouseDragState = MouseDragDown;\n"
"			MouseDragXStart = MouseDragX;\n"
"			MouseDragYStart = MouseDragY;\n"
"			MouseDragKeyCtrl = 0;\n"
"			MouseDragKeyShift = 0;\n"
"\n"
"			if(KeyShiftDown || KeyCtrlDown)\n"
"			{\n"
"				MouseDragKeyShift = KeyShiftDown;\n"
"				MouseDragKeyCtrl = KeyCtrlDown;\n"
"				MouseDragState = MouseDragMove;\n"
"			}\n"
"		}\n"
"	}\n"
"	else if(MouseDragState == MouseDragDown)\n"
"	{\n"
"		if(Source == MouseDragUp)\n"
"		{\n"
"			MouseHandleDragClick();\n"
"			MouseDragReset();\n"
"		}\n"
"		else if(Source == MouseDragMove)\n"
"		{\n"
"			var dx = Math.abs(MouseDragX - MouseDragXStart);\n"
"			var dy = Math.abs(MouseDragY - MouseDragYStart);\n"
"			if(dx+dy>1)\n"
"			{\n"
"				MouseDragState = MouseDragMove;\n"
"			}\n"
"		}\n"
"	}\n"
"	MouseDragXLast = MouseDragX;\n"
"	MouseDragYLast = MouseDragY;\n"
"}\n"
"\n"
"function MouseMove(evt)\n"
"{\n"
"    evt.preventDefault();\n"
"    ZoomActive = 0;\n"
"    MouseDrag(MouseDragMove, evt);\n"
" 	MouseHistory = 0;\n"
"	MouseDetailed = 0;\n"
"	HistoryViewMouseX = HistoryViewMouseY = -1;\n"
"	var rect = evt.target.getBoundingClientRect();\n"
"	var x = evt.clientX - rect.left;\n"
"	var y = evt.clientY - rect.top;\n"
"	if(evt.target == CanvasDetailedView)\n"
"	{\n"
"		if(!MouseDragSelectRange())\n"
"		{\n"
"			RangeCpu = RangeInit();\n"
"		}\n"
"		DetailedViewMouseX = x;\n"
"		DetailedViewMouseY = y;\n"
"	}\n"
"	else if(evt.target = CanvasHistory)\n"
"	{\n"
"		var Rect = CanvasHistory.getBoundingClientRect();\n"
"		HistoryViewMouseX = x;\n"
"		HistoryViewMouseY = y;\n"
"	}\n"
"	Draw(1);\n"
"}\n"
"\n"
"function MouseSortClick()\n"
"{\n"
"	if(SortColumnMouseOverNext)\n"
"	{\n"
"		if(SortColumnMouseOverNext == SortColumnMouseOver)\n"
"		{\n"
"			SortColumnOrderFlip =  1 - SortColumnOrderFlip;\n"
"		}\n"
"		else\n"
"		{\n"
"			SortColumnOrderFlip = 0;\n"
"		}\n"
"\n"
"		SortColumnMouseOver = SortColumnMouseOverNext;\n"
"		SortColumnMouseOverNext = null;\n"
"		if(SortColumnMouseOver == StrAverage)\n"
"		{\n"
"			SortColumn = 1;\n"
"		}\n"
"		else if(SortColumnMouseOver == StrMax)\n"
"		{\n"
"			SortColumn = 2;\n"
"		}\n"
"		else if(SortColumnMouseOver == StrTotal)\n"
"		{\n"
"			SortColumn = 3;\n"
"		}			\n"
"		else if(SortColumnMouseOver == StrMin)\n"
"		{\n"
"			SortColumn = 4;\n"
"		}\n"
"		else if(SortColumnMouseOver == StrSpike)\n"
"		{\n"
"			SortColumn = 5;\n"
"		}\n"
"		else if(SortColumnMouseOver == StrCallAverage)\n"
"		{\n"
"			SortColumn = 6;\n"
"		}\n"
"		else if(SortColumnMouseOver == StrCount)\n"
"		{\n"
"			SortColumn = 7;\n"
"		}\n"
"		else if(SortColumnMouseOver == StrExclAverage)\n"
"		{\n"
"			SortColumn = 8;\n"
"		}\n"
"		else if(SortColumnMouseOver == StrExclMax)\n"
"		{\n"
"			SortColumn = 9;\n"
"		}\n"
"		else if(SortColumnMouseOver == StrGroup)\n"
"		{\n"
"			SortColumn = 0;\n"
"		}\n"
"		RequestRedraw();\n"
"	}\n"
"}\n"
"\n"
"function MouseButton(bPressed, evt)\n"
"{\n"
"    evt.preventDefault();\n"
"	MouseDrag(bPressed ? MouseDragDown : MouseDragUp, evt);\n"
"	if(!bPressed)\n"
"		MouseSortClick();\n"
"}\n"
"\n"
"function MouseOut(evt)\n"
"{\n"
"	MouseDrag(MouseDragOff, evt);\n"
"	KeyCtrlDown = 0;\n"
"	KeyShiftDown = 0;\n"
"	MouseDragButton = 0;\n"
"	nHoverToken = -1;\n"
"	RangeCpu = RangeInit();\n"
"}\n"
"\n"
"function MouseWheel(e)\n"
"{\n"
"    var e = window.event || e;\n"
"    var delta = (e.wheelDelta || e.detail * (-120));\n"
"    ZoomGraph((-4 * delta / 120.0) | 0);\n"
"    Draw(1);\n"
"}\n"
"function ShowFilterInput(bShow)\n"
"{\n"
"	if(bShow)\n"
"	{\n"
"		document.getElementById(\'filterinput\').style[\'display\'] = \'block\';\n"
"	}\n"
"	else\n"
"	{\n"
"		document.getElementById(\'filterinput\').style[\'display\'] = \'none\';\n"
"	}\n"
"}\n"
"\n"
"function SetFilterInput(group, timer)\n"
"{\n"
"	FilterInputGroupString = group;\n"
"	FilterInputTimerString = timer;\n"
"	FilterInputGroup.value = group?group:\'\';\n"
"	FilterInputTimer.value = timer?timer:\'\';\n"
"	FilterUpdate();\n"
"	if(group || timer)\n"
"	{\n"
"		ShowFilterInput(1);\n"
"	}\n"
"	else\n"
"	{\n"
"		ShowFilterInput(0);\n"
"	}\n"
"\n"
"}\n"
"\n"
"function ToggleFilterInput(escape)\n"
"{\n"
"	var ActiveElement = -1;\n"
"	for(var i = 0; i < FilterInputArray.length; ++i)\n"
"	{\n"
"		if(FilterInputArray[i] == document.activeElement)\n"
"		{\n"
"			ActiveElement = i;\n"
"		}\n"
"	}\n"
"	var OldActiveElement = ActiveElement;\n"
"	if(ActiveElement >= 0)\n"
"	{\n"
"		FilterInputArray[ActiveElement].blur();\n"
"	}\n"
"	ActiveElement++;\n"
"	if(!escape)\n"
"	{\n"
"		if(ActiveElement < FilterInputArray.length)\n"
"		{\n"
"			ShowFilterInput(1);\n"
"			FilterInputArray[ActiveElement].focus();\n"
"		}\n"
"	}\n"
"	else\n"
"	{\n"
"		if(-1 == OldActiveElement)\n"
"		{\n"
"			SetFilterInput();\n"
"		}\n"
"	}\n"
"}\n"
"\n"
"function KeyUp(evt)\n"
"{\n"
"	if(evt.keyCode == 18)\n"
"	{\n"
"		ToolTipFlip = 0;\n"
"	}\n"
"//	ShowFlashMessage(evt.keyCode + \' <<\', 100);\n"
"	if(!FilterSearchActive)\n"
"	{\n"
"		if(evt.keyCode == 112)\n"
"		{\n"
"			ShowHelp(1, 0);\n"
"		}\n"
"		if(evt.keyCode == 39)\n"
"		{\n"
"			MoveToNext(1);\n"
"		}\n"
"		if(evt.keyCode == 37)\n"
"		{\n"
"			MoveToNext(-1);\n"
"		}\n"
"		if(evt.keyCode == 90)\n"
"		{\n"
"			ToolTipCorner = 1-ToolTipCorner;\n"
"		}\n"
"		if(evt.keyCode == 32)\n"
"		{\n"
"			if(RangeSelect.Begin < RangeSelect.End)\n"
"			{\n"
"				ZoomTo(RangeSelect.Begin, RangeSelect.End);\n"
"				RangeSelect = RangeInit();\n"
"				MouseHandleDragEnd();\n"
"			}\n"
"		}\n"
"		if(evt.keyCode == 9)\n"
"		{\n"
"			evt.preventDefault();\n"
"			if(Mode == ModeDetailed)\n"
"			{\n"
"				var Token = nHoverToken;\n"
"				if(Token == -1 && RangeValid(RangeSelect) && RangeSelect.Index >= 0)\n"
"				{\n"
"					Token = RangeSelect.Index;\n"
"				}\n"
"				if(Token != -1 && Token < TimerInfo.length)\n"
"				{\n"
"					var start = TimerInfo[Token].worststart;\n"
"					var end = TimerInfo[Token].worstend;\n"
"					RangeSelect.Begin = start;\n"
"					RangeSelect.End = end;\n"
"					RangeSelect.Thread = TimerInfo[Token].worstthread;\n"
"					RangeSelect.Index = Token;\n"
"					ShowFlashMessage(\'Worst: \' + (end-start).toFixed(2) + \'ms\', 100);\n"
"					MoveTo(RangeSelect.Begin, RangeSelect.End, ThreadY[RangeSelect.Thread] + nOffsetY, ThreadY[RangeSelect.Thread+1] + nOffsetY);\n"
"					MouseHandleDragEnd();\n"
"				}\n"
"			}\n"
"			else if(Mode == ModeTimers)\n"
"			{\n"
"				ToggleFilterInput(0);\n"
"				evt.preventDefault();\n"
"			}\n"
"\n"
"		}\n"
"		if(evt.keyCode == 88)\n"
"		{\n"
"			ToggleMode();\n"
"		}\n"
"\n"
"	}		\n"
"	if(evt.keyCode == 17)\n"
"	{\n"
"		KeyCtrlDown = 0;\n"
"		MouseDragKeyUp();\n"
"	}\n"
"	else if(evt.keyCode == 16)\n"
"	{\n"
"		KeyShiftDown = 0;\n"
"		MouseDragKeyUp();\n"
"	}\n"
"\n"
"\n"
"	if(evt.keyCode == 27)\n"
"	{\n"
"		RangeSelect = RangeInit();\n"
"		SortColumn = 0;\n"
"		SortColumnMouseOver = \"\";\n"
"		if(Mode == ModeTimers)\n"
"		{\n"
"			ToggleFilterInput(1);\n"
"			evt.preventDefault();\n"
"		}\n"
"		if(FilterSearchActive)\n"
"		{\n"
"			if(FilterInput.value != \'\')\n"
"			{\n"
"				FilterInput.value = \'\';\n"
"			}\n"
"			else\n"
"			{\n"
"				FilterInputHide();\n"
"			}\n"
"		}\n"
"		else\n"
"		{\n"
"			FilterSearchArray = new Array();\n"
"		}\n"
"	}\n"
"\n"
"\n"
"	if(evt.keyCode == 13)\n"
"	{\n"
"		if(FilterSearchActive)\n"
"		{\n"
"			FilterInputCommit();\n"
"		}\n"
"		else\n"
"		{\n"
"			FilterInputShow();\n"
"		}\n"
"	}\n"
"\n"
"	Invalidate = 0;\n"
"}\n"
"function FilterInputUpdate()\n"
"{\n"
"	Invalidate = 0;	\n"
"	if(FilterSearchActive == 1)\n"
"	{\n"
"		FilterInputDiv.style[\'display\'] = \'inline\';\n"
"		FilterInput.focus();\n"
"	}\n"
"	else\n"
"	{\n"
"		FilterSearchSelection = -1;\n"
"		FilterInputDiv.style[\'display\'] = \'none\';\n"
"	}	\n"
"}\n"
"function FilterInputShow()\n"
"{\n"
"	FilterSearchActive = 1;\n"
"	FilterInputUpdate();\n"
"}\n"
"function FilterInputHide()\n"
"{\n"
"	FilterSearchActive = 0;\n"
"	FilterInputUpdate();\n"
"}\n"
"\n"
"function FilterInputCommit()\n"
"{\n"
"	if(FilterSearchSelection >= 0)\n"
"	{\n"
"		FilterSearchArray = new Array();\n"
"		FilterSearchPassIndex = FilterSearchSelection;\n"
"		FilterSearchStartTime = new Date();\n"
"	}\n"
"	FilterInputHide();\n"
"}\n"
"function CreateFilter(Filter)\n"
"{\n"
"	if(!Filter || Filter.length == 0)\n"
"	{\n"
"		return null;\n"
"	}\n"
"	Filter = Filter.split(\' \');\n"
"	\n"
"	var regexp = \"\";\n"
"	for(var i = 0; i < Filter.length; ++i)\n"
"	{\n"
"		regexp = regexp + \".*\" + Filter[i];\n"
"	}\n"
"	Filter = new Array();\n"
"	regexp = regexp + \".*\";\n"
"	Filter.push(new RegExp(regexp, \"i\"));\n"
"	return Filter;\n"
"}\n"
"function FilterKeyUp()\n"
"{\n"
"	FilterInputTimerString = FilterInputTimer.value;\n"
"	FilterInputGroupString = FilterInputGroup.value;\n"
"	FilterUpdate();\n"
"}\n"
"\n"
"function FilterUpdate()\n"
"{\n"
"	FilterTimer = CreateFilter(FilterInputTimerString);\n"
"	FilterGroup = CreateFilter(FilterInputGroupString);\n"
"}\n"
"\n"
"function KeyDown(evt)\n"
"{\n"
"	if(evt.keyCode == 17)\n"
"	{\n"
"		KeyCtrlDown = 1;\n"
"	}\n"
"	else if(evt.keyCode == 16)\n"
"	{\n"
"		KeyShiftDown = 1;\n"
"	}\n"
"	else if(evt.keyCode == 9)\n"
"	{\n"
"		evt.preventDefault();\n"
"	}\n"
"	if(evt.keyCode == 18) // z/tab to toggle tooltip\n"
"	{\n"
"		ToolTipFlip = 1;\n"
"	}\n"
"\n"
"\n"
"	Invalidate = 0;\n"
"}\n"
"\n"
"function ReadCookie()\n"
"{\n"
"	var result = document.cookie.match(/fisk=([^;]+)/);\n"
"	var NewMode = ModeDetailed;\n"
"	var ReferenceTimeString = \'33ms\';\n"
"	if(result && result.length > 0)\n"
"	{\n"
"		var Obj = JSON.parse(result[1]);\n"
"		if(Obj.Mode)\n"
"		{\n"
"			NewMode = Obj.Mode;\n"
"		}\n"
"		if(Obj.ReferenceTime)\n"
"		{\n"
"			ReferenceTimeString = Obj.ReferenceTime;\n"
"		}\n"
"		if(Obj.ThreadsAllActive || Obj.ThreadsAllActive == 0 || Obj.ThreadsAllActive == false)\n"
"		{\n"
"			ThreadsAllActive = Obj.ThreadsAllActive;\n"
"		}\n"
"		else\n"
"		{\n"
"			ThreadsAllActive = 1;\n"
"		}\n"
"		if(Obj.ThreadsActive)\n"
"		{\n"
"			ThreadsActive = Obj.ThreadsActive;\n"
"		}\n"
"		if(Obj.GroupsAllActive || Obj.GroupsAllActive == 0 || Obj.GroupsAllActive)\n"
"		{\n"
"			GroupsAllActive = Obj.GroupsAllActive;\n"
"		}\n"
"		else\n"
"		{\n"
"			GroupsAllActive = 1;\n"
"		}\n"
"		if(Obj.GroupsActive)\n"
"		{\n"
"			GroupsActive = Obj.GroupsActive;\n"
"		}\n"
"		if(Obj.nContextSwitchEnabled)\n"
"		{\n"
"			nContextSwitchEnabled = Obj.nContextSwitchEnabled; \n"
"		}\n"
"		else\n"
"		{\n"
"			nContextSwitchEnabled = 1;\n"
"		}\n"
"		if(Obj.GroupColors)\n"
"		{\n"
"			GroupColors = Obj.GroupColors;\n"
"		}\n"
"		else\n"
"		{\n"
"			GroupColors = 0;\n"
"		}\n"
"		if(Obj.nHideHelp)\n"
"		{\n"
"			nHideHelp = 1;\n"
"		}\n"
"		if(Obj.ColumnsEnabled)\n"
"		{\n"
"			ColumnsEnabled = Obj.ColumnsEnabled;\n"
"		}\n"
"		if(Obj.ToolTipCorner)\n"
"		{\n"
"			ToolTipCorner = Obj.ToolTipCorner;\n"
"		}\n"
"		TimersGroups = Obj.TimersGroups?Obj.TimersGroups:0;\n"
"	}\n"
"	SetContextSwitch(nContextSwitchEnabled);\n"
"	SetMode(NewMode, TimersGroups);\n"
"	SetReferenceTime(ReferenceTimeString);\n"
"	UpdateOptionsMenu();\n"
"	UpdateGroupColors();\n"
"}\n"
"function WriteCookie()\n"
"{\n"
"	var Obj = new Object();\n"
"	Obj.Mode = Mode;\n"
"	Obj.ReferenceTime = ReferenceTime + \'ms\';\n"
"	Obj.ThreadsActive = ThreadsActive;\n"
"	Obj.ThreadsAllActive = ThreadsAllActive;\n"
"	Obj.GroupsActive = GroupsActive;\n"
"	Obj.GroupsAllActive = GroupsAllActive;\n"
"	Obj.nContextSwitchEnabled = nContextSwitchEnabled;\n"
"	Obj.TimersGroups = TimersGroups?TimersGroups:0;\n"
"	Obj.GroupColors = GroupColors;\n"
"	Obj.ColumnsEnabled = ColumnsEnabled;\n"
"	Obj.ToolTipCorner = ToolTipCorner;\n"
"	if(nHideHelp)\n"
"	{\n"
"		Obj.nHideHelp = 1;\n"
"	}\n"
"	var date = new Date();\n"
"	date.setFullYear(2099);\n"
"	var cookie = \'fisk=\' + JSON.stringify(Obj) + \';expires=\' + date;\n"
"	document.cookie = cookie;\n"
"}\n"
"\n"
"function WindowRect(x,y,w,h)\n"
"{\n"
"	var s = {};\n"
"	s.x = x;\n"
"	s.y = y;\n"
"	s.w = w;\n"
"	s.h = h;\n"
"	return s;\n"
"}\n"
"\n"
"function MenuSize(w)\n"
"{\n"
"	return WindowRect(nWidth / 2 - w / 2, 5, w, nHeight);\n"
"}\n"
"\n"
"function TimerMenuSize()\n"
"{\n"
"	return MenuSize(200 + 5 + FontWidth); //fix menu size\n"
"}\n"
"function MoveFilterInputDiv(x, y, w)\n"
"{\n"
"	if(FilterInputDivPos.x != x || FilterInputDivPos.y != y || FilterInputDivPos.w != w)\n"
"	{\n"
"		FilterInputDivPos.x = x;\n"
"		FilterInputDivPos.y = y;\n"
"		FilterInputDivPos.w = w;\n"
"		FilterInputDiv.style[\'left\'] = x + \'px\';\n"
"		FilterInputDiv.style[\'top\'] = (y + (CanvasHistory.height / DPR)) + \'px\';\n"
"		FilterInput.style[\'width\'] = w + \'px\';\n"
"	}\n"
"}\n"
"\n"
"function DrawFilterSearch()\n"
"{\n"
"	FilterSearchSelection = -1;\n"
"	FilterSearchPassIndex = -1;\n"
"	FilterSearchSelectionMax = 0;\n"
"	if(!FilterSearchActive)\n"
"		return;\n"
"	nHoverToken = -1;\n"
"\n"
"	if(FilterInputSearchLast != FilterInput.value)\n"
"	{\n"
"		nOffsetFilterSearch = 0;\n"
"	}\n"
"	FilterInputSearchLast = FilterInput.value;\n"
"\n"
"	var FilterArray = CreateFilter(FilterInput.value);\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"	var nColorIndex = 0;\n"
"	var SizeInfo = TimerMenuSize();\n"
"	var Y = SizeInfo.y;\n"
"	var Width = TimerNameWidth + GroupNameWidth;\n"
"	SizeInfo.w = Width;\n"
"	var X = SizeInfo.x;\n"
"\n"
"	MoveFilterInputDiv(SizeInfo.x, SizeInfo.y, SizeInfo.w);\n"
"	var YStart = Y;\n"
"	Y += 35; //todo: measure somehow?\n"
"	var MouseX = DetailedViewMouseX;\n"
"	var MouseY = DetailedViewMouseY;\n"
"\n"
"	Y -= nOffsetFilterSearch;\n"
"	var Count = 0;\n"
"	for(var i = 0; i < TimerInfo.length; ++i)\n"
"	{\n"
"		var v = TimerInfo[i];\n"
"		{\n"
"			var Name = v.name;\n"
"			var ParentName = GroupInfo[v.group].name;\n"
"			if(FilterMatch(FilterArray, ParentName + \" \" + Name))\n"
"			{\n"
"				if(Y >= YStart)\n"
"				{\n"
"					Count++;\n"
"					var ParentName = GroupInfo[v.group].name;\n"
"					var ParentColor = \'white\';\n"
"					var bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight;\n"
"					var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
"					var TextY = Y+BoxHeight-FontAscent;\n"
"					context.fillStyle = bgcolor;\n"
"					context.fillRect(X, Y, Width, BoxHeight);\n"
"					context.fillStyle = ParentColor;\n"
"					context.fillText(ParentName, X + 2, TextY);\n"
"					context.fillStyle = g_Colors[v.cid];\n"
"					context.textAlign = \'right\';\n"
"					context.fillText(Name, X + Width - 2, TextY);\n"
"					context.textAlign = \'left\';\n"
"					if(bMouseIn)\n"
"					{\n"
"						FilterSearchSelection = i;\n"
"					}\n"
"				}\n"
"				Y += BoxHeight;\n"
"				if(Y > nHeight)\n"
"					break;\n"
"				nColorIndex = 1-nColorIndex;\n"
"			}\n"
"		}\n"
"	}\n"
"	FilterSearchSelectionMax = Count;\n"
"	SizeInfo.h = Y-SizeInfo.y;\n"
"	return SizeInfo;\n"
"}\n"
"\n"
"function CalcAverage()\n"
"{\n"
"	var Sum = 0;\n"
"	var Count = 0;\n"
"	for(nLog = 0; nLog < nNumLogs; nLog++)\n"
"	{\n"
"		StackPos = 0;\n"
"		for(var i = 0; i < Frames.length; i++)\n"
"		{\n"
"			var Frame_ = Frames[i];			\n"
"			var tt = Frame_.tt[nLog];\n"
"			var ts = Frame_.ts[nLog];\n"
"\n"
"			var count = tt.length;\n"
"			for(var j = 0; j < count; j++)\n"
"			{\n"
"				var type = tt[j];\n"
"				var time = ts[j];\n"
"				if(type == 1)\n"
"				{\n"
"					Stack[StackPos] = time;//store the frame which it comes from\n"
"					StackPos++;\n"
"				}\n"
"				else if(type == 0)\n"
"				{\n"
"					if(StackPos>0)\n"
"					{\n"
"\n"
"						StackPos--;\n"
"						var localtime = time - Stack[StackPos];\n"
"						Count++;\n"
"						Sum += localtime;\n"
"					}\n"
"				}\n"
"			}\n"
"		}\n"
"	}\n"
"	return Sum / Count;\n"
"\n"
"}\n"
"\n"
"function MakeLod(index, MinDelta, TimeArray, TypeArray, IndexArray, LogStart)\n"
"{\n"
"	if(LodData[index])\n"
"	{\n"
"		console.log(\"error!!\");\n"
"	}\n"
"	var o = new Object();\n"
"	o.MinDelta = MinDelta;\n"
"	o.TimeArray = TimeArray;\n"
"	o.TypeArray = TypeArray;\n"
"	o.IndexArray = IndexArray;\n"
"	o.LogStart = LogStart;\n"
"	LodData[index] = o;\n"
"}\n"
"\n"
"function PreprocessBuildSplitArray()\n"
"{\n"
"	var nNumLogs = Frames[0].ts.length;\n"
"\n"
"	ProfileEnter(\"PreprocessBuildSplitArray\");\n"
"	var SplitArrays = new Array(nNumLogs);\n"
"\n"
"	for(nLog = 0; nLog < nNumLogs; ++nLog)\n"
"	{\n"
"		console.log(\"source log \" + nLog + \" size \" + LodData[0].TypeArray[nLog].length);\n"
"	}\n"
"\n"
"\n"
"	for(nLog = 0; nLog < nNumLogs; nLog++)\n"
"	{\n"
"		var MaxDepth = 1;\n"
"		var StackPos = 0;\n"
"		var Stack = Array(20);\n"
"		var TypeArray = LodData[0].TypeArray[nLog];\n"
"		var TimeArray = LodData[0].TimeArray[nLog];\n"
"		var DeltaTimes = new Array(TypeArray.length);\n"
"\n"
"		for(var j = 0; j < TypeArray.length; ++j)\n"
"		{\n"
"			var type = TypeArray[j];\n"
"			var time = TimeArray[j];\n"
"			if(type == 1)\n"
"			{\n"
"				//push\n"
"				Stack[StackPos] = time;\n"
"				StackPos++;\n"
"			}\n"
"			else if(type == 0)\n"
"			{\n"
"				if(StackPos>0)\n"
"				{\n"
"					StackPos--;\n"
"					DeltaTimes[j] = time - Stack[StackPos];\n"
"				}\n"
"				else\n"
"				{\n"
"					DeltaTimes[j] = 0;\n"
"				}\n"
"			}\n"
"		}\n"
"		DeltaTimes.sort(function(a,b){return b-a;});\n"
"		var SplitArray = Array(NumLodSplits);\n"
"		var SplitIndex = DeltaTimes.length;\n"
"\n"
"		var j = 0;\n"
"		for(j = 0; j < NumLodSplits; ++j)\n"
"		{\n"
"			SplitIndex = Math.floor(SplitIndex / 2);\n"
"			while(SplitIndex > 0 && !DeltaTimes[SplitIndex])\n"
"			{\n"
"				SplitIndex--;\n"
"			}\n"
"			if(SplitIndex < SplitMin)\n"
"			{\n"
"				break;\n"
"			}\n"
"			//search.. if 0\n"
"			var SplitTime = DeltaTimes[SplitIndex];\n"
"			if(SplitTime>=0)\n"
"			{\n"
"				SplitArray[j] = SplitTime;\n"
"			}\n"
"			else\n"
"			{\n"
"				SplitArray[j] = SPLIT_LIMIT;\n"
"			}\n"
"			if(j>0)\n"
"			{\n"
"				console.assert(SplitArray[j-1] <= SplitArray[j], \"must be less\");\n"
"			}\n"
"\n"
"		}\n"
"		for(; j < NumLodSplits; ++j)\n"
"		{\n"
"			SplitArray[j] = SPLIT_LIMIT;\n"
"		}\n"
"\n"
"\n"
"		SplitArrays[nLog] = SplitArray;\n"
"	}\n"
"	ProfileLeave();\n"
"	return SplitArrays;\n"
"}\n"
"\n"
"function PreprocessBuildDurationArray()\n"
"{\n"
"	var nNumLogs = Frames[0].ts.length;\n"
"	ProfileEnter(\"PreprocessBuildDurationArray\");\n"
"	var DurationArrays = new Array(nNumLogs);\n"
"	for(nLog = 0; nLog < nNumLogs; ++nLog)\n"
"	{\n"
"		var MaxDepth = 1;\n"
"		var StackPos = 0;\n"
"		var Stack = Array(20);\n"
"		var StackIndex = Array(20);\n"
"		var TypeArray = LodData[0].TypeArray[nLog];\n"
"		var TimeArray = LodData[0].TimeArray[nLog];\n"
"		var DurationArray = Array(LodData[0].TypeArray[nLog].length);\n"
"		for(var j = 0; j < TypeArray.length; ++j)\n"
"		{\n"
"			var type = TypeArray[j];\n"
"			var time = TimeArray[j];\n"
"			if(type == 1)\n"
"			{\n"
"				//push\n"
"				Stack[StackPos] = time;\n"
"				StackIndex[StackPos] = j;\n"
"				StackPos++;\n"
"			}\n"
"			else if(type == 0)\n"
"			{\n"
"				if(StackPos>0)\n"
"				{\n"
"					StackPos--;\n"
"					var Duration = time - Stack[StackPos];\n"
"					DurationArray[StackIndex[StackPos]] = Duration;\n"
"					DurationArray[j] = Duration;\n"
"				}\n"
"				else\n"
"				{\n"
"					DurationArray[j] = 0;\n"
"				}\n"
"			}\n"
"		}\n"
"		for(var j = 0; j < StackPos; ++j)\n"
"		{\n"
"			DurationArray[j] = 0;\n"
"		}\n"
"		DurationArrays[nLog] = DurationArray;\n"
"	}\n"
"	ProfileLeave();\n"
"	return DurationArrays;\n"
"\n"
"}\n"
"function PreprocessLods()\n"
"{\n"
"	ProfileEnter(\"PreprocessLods\");\n"
"	var nNumLogs = Frames[0].ts.length;\n"
"	var SplitArrays = PreprocessBuildSplitArray();\n"
"	var DurationArrays = PreprocessBuildDurationArray();\n"
"	var Source = LodData[0];\n"
"	var SourceLogStart = Source.LogStart;\n"
"	var NumFrames = SourceLogStart.length;\n"
"\n"
"	for(var i = 0; i < NumLodSplits-1; ++i)\n"
"	{\n"
"		var DestLogStart = Array(SourceLogStart.length);\n"
"		for(var j = 0; j < DestLogStart.length; ++j)\n"
"		{\n"
"			DestLogStart[j] = Array(nNumLogs);\n"
"		}\n"
"		var MinDelta = Array(nNumLogs);\n"
"		var TimeArray = Array(nNumLogs);\n"
"		var IndexArray = Array(nNumLogs);\n"
"		var TypeArray = Array(nNumLogs);\n"
"\n"
"\n"
"\n"
"		for(nLog = 0; nLog < nNumLogs; ++nLog)\n"
"		{\n"
"			var SourceTypeArray = Source.TypeArray[nLog];\n"
"			var SourceTimeArray = Source.TimeArray[nLog];\n"
"			var SourceIndexArray = Source.IndexArray[nLog];\n"
"			var Duration = DurationArrays[nLog];\n"
"			console.assert(Duration.length == SourceTypeArray.length, \"must be equal!\");\n"
"			var SplitTime = SplitArrays[nLog][i];\n"
"\n"
"			MinDelta[nLog] = SplitTime;\n"
"			if(SplitTime < SPLIT_LIMIT)\n"
"			{\n"
"				var SourceCount = SourceTypeArray.length;\n"
"				var DestTypeArray = Array();\n"
"				var DestTimeArray = Array();\n"
"				var DestIndexArray = Array();\n"
"				var RemapArray = Array(SourceCount);\n"
"				var DiscardLast = 0;\n"
"\n"
"				for(var j = 0; j < SourceCount; ++j)\n"
"				{\n"
"					RemapArray[j] = DestTypeArray.length;\n"
"					if(Duration[j] >= SplitTime || (SourceTypeArray[j] == 3 && 0 == DiscardLast))\n"
"					{\n"
"						DiscardLast = 0;\n"
"						DestTypeArray.push(SourceTypeArray[j]);\n"
"						DestTimeArray.push(SourceTimeArray[j]);\n"
"						DestIndexArray.push(SourceIndexArray[j]);\n"
"					}\n"
"					else\n"
"					{\n"
"						DiscardLast = 1;\n"
"					}\n"
"				}\n"
"				TimeArray[nLog] = DestTimeArray;\n"
"				IndexArray[nLog] = DestIndexArray;\n"
"				TypeArray[nLog] = DestTypeArray;\n"
"				for(var j = 0; j < NumFrames; ++j)\n"
"				{\n"
"					var OldStart = SourceLogStart[j][nLog];\n"
"					var NewStart = RemapArray[OldStart];\n"
"					var FrameArray = DestLogStart[j];\n"
"					FrameArray[nLog] = NewStart;\n"
"				}\n"
"			}\n"
"			else\n"
"			{\n"
"\n"
"				for(var j = 0; j < NumFrames; ++j)\n"
"				{\n"
"					var FrameArray = DestLogStart[j];\n"
"	\n"
"					FrameArray[nLog] = 0;\n"
"				}\n"
"\n"
"			}\n"
"\n"
"		}\n"
"		MakeLod(i+1, MinDelta, TimeArray, TypeArray, IndexArray, DestLogStart);\n"
"	}\n"
"	ProfileLeave();\n"
"}\n"
"function PreprocessGlobalArray()\n"
"{\n"
"	ProfileEnter(\"PreprocessGlobalArray\");\n"
"	var nNumLogs = Frames[0].ts.length;\n"
"	var CaptureStart = Frames[0].framestart;\n"
"	var CaptureEnd = Frames[Frames.length-1].frameend;\n"
"	g_TypeArray = new Array(nNumLogs);\n"
"	g_TimeArray = new Array(nNumLogs);\n"
"	g_IndexArray = new Array(nNumLogs);\n"
"	var StackPos = 0;\n"
"	var Stack = Array(20);\n"
"	var LogStartArray = new Array(Frames.length);\n"
"	for(var i = 0; i < Frames.length; i++)\n"
"	{\n"
"		Frames[i].LogStart = new Array(nNumLogs);	\n"
"		LogStartArray[i] = Frames[i].LogStart;\n"
"\n"
"		Frames[i].LogEnd = new Array(nNumLogs);\n"
"	}\n"
"	var MinDelta = Array(nNumLogs);\n"
"	for(nLog = 0; nLog < nNumLogs; nLog++)\n"
"	{\n"
"		MinDelta[nLog] = 0;\n"
"		var Discard = 0;\n"
"		var TypeArray = new Array();\n"
"		var TimeArray = new Array();\n"
"		var IndexArray = new Array();\n"
"		for(var i = 0; i < Frames.length; i++)\n"
"		{\n"
"			var Frame_ = Frames[i];	\n"
"			Frame_.LogStart[nLog] = TimeArray.length;\n"
"			var CanDiscard = !ISGPU[nLog] || Frame_.frameendgpu > 0; //in case of no reference, we cannot discard gpu markers. This happens when there is no gpu/cpu tick reference\n"
"\n"
"			var FrameDiscard = (ISGPU[nLog] ? Frame_.frameendgpu : Frame_.frameend) + 33;//if timestamps are more than 33ms after current frame, we assume buffer has wrapped.\n"
"			var tt = Frame_.tt[nLog];\n"
"			var ts = Frame_.ts[nLog];\n"
"			var ti = Frame_.ti[nLog];\n"
"			var len = tt.length;\n"
"			var DiscardLast = 0;\n"
"			for(var xx = 0; xx < len; ++xx)\n"
"			{\n"
"				var Skip = (tt[i] == 3) ? DiscardLast : (CanDiscard && ts[xx] > FrameDiscard);\n"
"				if(Skip)\n"
"				{\n"
"					Discard++;\n"
"					DiscardLast = 1;\n"
"				}\n"
"				else\n"
"				{\n"
"					DiscardLast = 0;\n"
"					TypeArray.push(tt[xx]);\n"
"					TimeArray.push(ts[xx]);\n"
"					IndexArray.push(ti[xx]);\n"
"				}\n"
"			}\n"
"			Frame_.LogEnd[nLog] = TimeArray.length;\n"
"		}\n"
"		g_TypeArray[nLog] = TypeArray;\n"
"		g_TimeArray[nLog] = TimeArray;\n"
"		g_IndexArray[nLog] = IndexArray;\n"
"		if(Discard)\n"
"		{\n"
"			console.log(\'discarded \' + Discard + \' markers from \' + ThreadNames[nLog]);\n"
"		}\n"
"	}\n"
"	MakeLod(0, MinDelta, g_TimeArray, g_TypeArray, g_IndexArray, LogStartArray);\n"
"	ProfileLeave();\n"
"}\n"
"\n"
"function PreprocessFindFirstFrames()\n"
"{\n"
"	ProfileEnter(\"PreprocesFindFirstFrames\");\n"
"	//create arrays that show how far back we need to start search in order to get all markers.\n"
"	var nNumLogs = Frames[0].ts.length;\n"
"	for(var i = 0; i < Frames.length; i++)\n"
"	{\n"
"		Frames[i].FirstFrameIndex = new Array(nNumLogs);\n"
"	}\n"
"\n"
"	var StackPos = 0;\n"
"	var Stack = Array(20);\n"
"	g_MaxStack = Array(nNumLogs);\n"
"	\n"
"	for(nLog = 0; nLog < nNumLogs; nLog++)\n"
"	{\n"
"		var MaxStack = 0;\n"
"		StackPos = 0;\n"
"		for(var i = 0; i < Frames.length; i++)\n"
"		{\n"
"			var Frame_ = Frames[i];			\n"
"			var tt = Frame_.tt[nLog];\n"
"			var count = tt.length;\n"
"\n"
"			var FirstFrame = i;\n"
"			if(StackPos>0)\n"
"			{\n"
"				FirstFrame = Stack[0];\n"
"			}\n"
"			Frames[i].FirstFrameIndex[nLog] = FirstFrame;\n"
"\n"
"			for(var j = 0; j < count; j++)\n"
"			{\n"
"				var type = tt[j];\n"
"				if(type == 1)\n"
"				{\n"
"					Stack[StackPos] = i;//store the frame which it comes from\n"
"					StackPos++;\n"
"					if(StackPos > MaxStack)\n"
"					{\n"
"						MaxStack = StackPos;\n"
"					}\n"
"				}\n"
"				else if(type == 0)\n"
"				{\n"
"					if(StackPos>0)\n"
"					{\n"
"						StackPos--;\n"
"					}\n"
"				}\n"
"			}\n"
"		}\n"
"		g_MaxStack[nLog] = MaxStack;\n"
"	}\n"
"	ProfileLeave();\n"
"}\n"
"function PreprocessMeta()\n"
"{\n"
"	return;\n"
"	MetaLengths = Array(MetaNames.length);\n"
"	MetaLengthsAvg = Array(MetaNames.length);\n"
"	MetaLengthsMax = Array(MetaNames.length);\n"
"	for(var i = 0; i < MetaNames.length; ++i)\n"
"	{\n"
"		MetaLengths[i] = MetaNames[i].length+1;\n"
"		MetaLengthsAvg[i] = MetaNames[i].length+5;\n"
"		MetaLengthsMax[i] = MetaNames[i].length+5;\n"
"		if(MetaLengths[i]<12)\n"
"			MetaLengths[i] = 12;\n"
"		if(MetaLengthsAvg[i]<12)\n"
"			MetaLengthsAvg[i] = 12;\n"
"		if(MetaLengthsMax[i]<12)\n"
"			MetaLengthsMax[i] = 12;\n"
"	}\n"
"	for(var i = 0; i < TimerInfo.length; ++i)\n"
"	{\n"
"		var Timer = TimerInfo[i];\n"
"		for(var j = 0; j < MetaNames.length; ++j)\n"
"		{\n"
"			var Len = FormatMeta(Timer.meta[j],0).length + 2;\n"
"			var LenAvg = FormatMeta(Timer.meta[j],2).length + 2;\n"
"			var LenMax = FormatMeta(Timer.meta[j],0).length + 2;\n"
"			if(Len > MetaLengths[j])\n"
"			{\n"
"				MetaLengths[j] = Len;\n"
"			}\n"
"			if(LenAvg > MetaLengthsAvg[j])\n"
"			{\n"
"				MetaLengthsAvg[j] = LenAvg;\n"
"			}\n"
"			if(LenMax > MetaLengthsMax[j])\n"
"			{\n"
"				MetaLengthsMax[j] = LenMax;\n"
"			}\n"
"		}\n"
"	}\n"
"}\n"
"\n"
"function PreprocessWidths()\n"
"{\n"
"	var context = CanvasHistory.getContext(\'2d\');\n"
"	context.font = Font;\n"
"	TimerNameWidth = 0;\n"
"	GroupNameWidth = 0;\n"
"	for(var i = 0; i < TimerInfo.length; ++i)\n"
"	{\n"
"		var str = GroupInfo[TimerInfo[i].group].name + \"XXX\" + TimerInfo[i].name;\n"
"		var width = context.measureText(str).width;\n"
"		var widthname = context.measureText(TimerInfo[i].name).width;\n"
"		TimerInfo[i].wtotal = width;\n"
"		TimerInfo[i].w = widthname;\n"
"		TimerNameWidth = Math.max(TimerNameWidth, widthname);\n"
"	}\n"
"	for(var i = 0; i < GroupInfo.length; ++i)\n"
"	{\n"
"		var widthname = context.measureText(TimerInfo[i].name).width;\n"
"		GroupNameWidth = Math.max(GroupNameWidth, widthname);\n"
"	}\n"
"}\n"
"\n"
"function PreprocessTimeline()\n"
"{\n"
"	Timeline.Times = TimelineArray;\n"
"	Timeline.Ids = TimelineIdArray;\n"
"	Timeline.Colors = new Array(TimelineArray.length);\n"
"	Timeline.Names = TimelineNames;\n"
"	Timeline.Ends = new Array(TimelineArray.length);\n"
"	Timeline.Pairs = new Array(TimelineArray.length);\n"
"	Timeline.Tracks = new Array();\n"
"	Timeline.Positions = new Array();\n"
"	for(var i = 0; i < Timeline.Times.length; ++i)\n"
"	{\n"
"		Timeline.Positions[i] = -1;\n"
"		Timeline.Ends[i] = -1;\n"
"		Timeline.Pairs[i] = -1;\n"
"		var Color = TimelineColorArray[i]\n"
"		if(!Color || Color == \'\')\n"
"		{\n"
"			Color = \'#777777\'\n"
"		}\n"
"		Timeline.Colors[i] = GetColorIndex(Color);\n"
"		if(null == Timeline.Colors[i])\n"
"			debugger;\n"
"		Timeline.Colors[i] = GetColorIndex(Color);\n"
"	}\n"
"\n"
"\n"
"	var LinearizeTrack = function(Track)\n"
"	{\n"
"		var b = new Array();\n"
"		var e = new Array();\n"
"		// var n = new Array();\n"
"		var k = new Array();\n"
"		var h = Track.h;\n"
"		while(h != -1)\n"
"		{\n"
"			b.push(Track.b[h]);\n"
"			e.push(Track.e[h]);\n"
"			k.push(Track.k[h]);\n"
"\n"
"			h = Track.n[h];\n"
"		}\n"
"	}\n"
"\n"
"	var CreateTrack = function()\n"
"	{\n"
"		var Track = {};\n"
"		Track.b = new Array();\n"
"		Track.e = new Array();\n"
"		Track.n = new Array();\n"
"		Track.k = new Array();\n"
"		Track.h = -1;\n"
"		return Track;\n"
"	}\n"
"\n"
"\n"
"	var TryAddToTrack = function(Track, b, e, k)\n"
"	{\n"
"		var Invalid = 0;\n"
"		var prev = -1;\n"
"		var next = Track.h;\n"
"		while(next != -1)\n"
"		{\n"
"			var B = Track.b[next];\n"
"			var E = Track.e[next];\n"
"			if(Math.max(B, b) < Math.min(E, e))\n"
"			{\n"
"				Invalid = 1;\n"
"				break;\n"
"			}\n"
"			if(E < b)\n"
"			{\n"
"				//should be after next, continue\n"
"			}else if(e < B)\n"
"			{\n"
"				//insert at this spot\n"
"				break;\n"
"			}\n"
"			prev = next;\n"
"			next = Track.n[next];\n"
"		}\n"
"		if(!Invalid)\n"
"		{\n"
"			var idx = Track.b.length;\n"
"			Track.b.push(b);\n"
"			Track.e.push(e);\n"
"			Track.k.push(k);\n"
"			Track.n.push(next);\n"
"			if(prev == -1)\n"
"			{\n"
"				Track.h = idx;\n"
"			}\n"
"			else\n"
"			{\n"
"				var h = Track.n[prev];\n"
"				if(h != next)\n"
"				{\n"
"					debugger;\n"
"				}\n"
"				Track.n[prev] = idx;\n"
"			}\n"
"			return true;\n"
"		}\n"
"		else\n"
"		{\n"
"			return false;\n"
"		}\n"
"	};\n"
"\n"
"\n"
"	var AddToTrack = function(b, e, k)\n"
"	{\n"
"		var Tracks = Timeline.Tracks;\n"
"\n"
"		for(var i = 0; i < Tracks.length; ++i)\n"
"		{\n"
"			var Track = Tracks[i];\n"
"			if(TryAddToTrack(Track, b, e, k))\n"
"			{\n"
"				return i;\n"
"			}\n"
"		}\n"
"		var NewTrack = CreateTrack();\n"
"		var i = Timeline.Tracks.length;\n"
"		Timeline.Tracks.push(NewTrack);\n"
"		if(!TryAddToTrack(NewTrack, b, e, k))\n"
"		{\n"
"			debugger;\n"
"		}\n"
"		return i;\n"
"\n"
"	};\n"
"\n"
"\n"
"\n"
"\n"
"\n"
"	var Matching = {};\n"
"	var Pairs = Timeline.Pairs;\n"
"	var Ids = Timeline.Ids;\n"
"	var Ends = Timeline.Ends;\n"
"	var Times = Timeline.Times;\n"
"	if(Ids)\n"
"	{\n"
"		for(var i = 0; i < Ids.length; ++i)\n"
"		{\n"
"			Pairs[i] = -1;\n"
"			var ID = Ids[i];\n"
"			var match = Matching[ID];\n"
"			if(match)\n"
"			{\n"
"				if(match > Ids.length || match < 0)\n"
"					debugger;\n"
"				Pairs[match] = i;\n"
"				Pairs[i] = match;\n"
"				if(match > i)\n"
"					debugger;\n"
"				Ends[match] = Times[i];\n"
"				var Track = AddToTrack(Times[match], Ends[match], match);\n"
"				Timeline.Positions[match] = Track;\n"
"			}\n"
"			else\n"
"			{\n"
"				Matching[ID] = i;\n"
"			}\n"
"		}\n"
"	}\n"
"}\n"
"function Preprocess()\n"
"{\n"
"	var ProfileModeOld = ProfileMode;\n"
"	ProfileMode = 1;\n"
"	ProfileModeClear();\n"
"	ProfileEnter(\"Preprocess\");\n"
"	PreprocessCalculateAllTimers();\n"
"	PreprocessFindFirstFrames();\n"
"	PreprocessGlobalArray();\n"
"	PreprocessLods();\n"
"	PreprocessMeta();\n"
"	PreprocessContextSwitchCache();\n"
"	ProfileLeave();\n"
"	ProfileModeDump();\n"
"	ProfileMode = ProfileModeOld;\n"
"	PreprocessWidths();\n"
"	PreprocessTimeline();\n"
"	Initialized = 1;\n"
"}\n"
"\n"
"function ToggleColumn(idx, isMeta)\n"
"{\n"
"	ColumnsEnabled[idx] = !ColumnsEnabled[idx];\n"
"	UpdateColumnsMenu();\n"
"	WriteCookie();\n"
"	Invalidate = 0;\n"
"}\n"
"function UpdateColumnsMenu()\n"
"{\n"
"	var ulColumnMenu = document.getElementById(\'ColumnsSubMenu\');\n"
"	var Lis = ulColumnMenu.getElementsByTagName(\'li\');\n"
"	for(var i = 0; i < Lis.length; ++i)\n"
"	{\n"
"		if(ColumnsEnabled[i])\n"
"		{\n"
"			Lis[i].style[\'text-decoration\'] = \'underline\';\n"
"		}\n"
"		else\n"
"		{\n"
"			Lis[i].style[\'text-decoration\'] = \'none\';\n"
"		}\n"
"	}\n"
"}\n"
"\n"
"function ResetColumnWidth()\n"
"{\n"
"	if(ColumnsWidth)\n"
"	{\n"
"		for(var i = 0; i < ColumnsWidth.length; ++i)\n"
"		{\n"
"			ColumnsWidth[i] = 0;\n"
"		}\n"
"	}\n"
"}\n"
"\n"
"var mousewheelevt = (/Firefox/i.test(navigator.userAgent)) ? \"DOMMouseScroll\" : \"mousewheel\" //FF doesn\'t recognize mousewheel as of FF3.x\n"
"\n"
"CanvasDetailedView.addEventListener(\'mousemove\', MouseMove, false);\n"
"CanvasDetailedView.addEventListener(\'mousedown\', function(evt) { MouseButton(true, evt); });\n"
"CanvasDetailedView.addEventListener(\'mouseup\', function(evt) { MouseButton(false, evt); } );\n"
"CanvasDetailedView.addEventListener(\'mouseout\', MouseOut);\n"
"CanvasDetailedView.addEventListener(\"contextmenu\", function (e) { e.preventDefault(); }, false);\n"
"CanvasDetailedView.addEventListener(mousewheelevt, MouseWheel, false);\n"
"CanvasHistory.addEventListener(\'mousemove\', MouseMove);\n"
"CanvasHistory.addEventListener(\'mousedown\', function(evt) { MouseButton(true, evt); });\n"
"CanvasHistory.addEventListener(\'mouseup\', function(evt) { MouseButton(false, evt); } );\n"
"CanvasHistory.addEventListener(\'mouseout\', MouseOut);\n"
"CanvasHistory.addEventListener(\"contextmenu\", function (e) { e.preventDefault(); }, false);\n"
"CanvasHistory.addEventListener(mousewheelevt, MouseWheel, false);\n"
"FilterInputTimer.addEventListener(\'keyup\', FilterKeyUp);\n"
"FilterInputGroup.addEventListener(\'keyup\', FilterKeyUp);\n"
"window.addEventListener(\'keydown\', KeyDown);\n"
"window.addEventListener(\'keyup\', KeyUp);\n"
"window.addEventListener(\'resize\', ResizeCanvas, false);\n"
"\n"
"\n"
"InitGroups();\n"
"ReadCookie();\n"
"MeasureFont()\n"
"InitThreadMenu();\n"
"InitGroupMenu();\n"
"InitColumnMenu();\n"
"InitFrameInfo();\n"
"UpdateThreadMenu();\n"
"ResizeCanvas();\n"
"Preprocess();\n"
"OnPageReady();\n"
"Draw(1);\n"
"AutoRedraw();\n"
"\n"
"</script>\n"
"</body>\n"
"</html>      ";

const size_t g_MicroProfileHtml_end_3_size = sizeof(g_MicroProfileHtml_end_3);
const char* g_MicroProfileHtml_end[] = {
&g_MicroProfileHtml_end_0[0],
&g_MicroProfileHtml_end_1[0],
&g_MicroProfileHtml_end_2[0],
&g_MicroProfileHtml_end_3[0],
};
size_t g_MicroProfileHtml_end_sizes[] = {
sizeof(g_MicroProfileHtml_end_0),
sizeof(g_MicroProfileHtml_end_1),
sizeof(g_MicroProfileHtml_end_2),
sizeof(g_MicroProfileHtml_end_3),
};
size_t g_MicroProfileHtml_end_count = 4;
#endif //MICROPROFILE_EMBED_HTML

///end file generated from  microprofile.html
///start file generated from microprofilelive.html
#ifdef MICROPROFILE_EMBED_HTML
const char g_MicroProfileHtmlLive_begin_0[] =
"<!DOCTYPE HTML>\n"
"<html>\n"
"<head>\n"
"<title>MicroProfile Capture</title>\n"
"<style>\n"
"/* about css: http://bit.ly/1eMQ42U */\n"
"body {margin: 0px;padding: 0px; font: 12px Courier New;background-color:#343434; color:white;overflow:hidden;}\n"
"ul {list-style-type: none;margin: 0;padding: 0;}\n"
"li{display: inline; float:left;border:5px; position:relative;text-align:center;}\n"
"a {\n"
"    float:left;\n"
"    text-decoration:none;\n"
"    display: inline;\n"
"    text-align: center;\n"
"	padding:5px;\n"
"	padding-bottom:0px;\n"
"	padding-top:0px;\n"
"    color: #FFFFFF;\n"
"    background-color: #343434;\n"
"}\n"
"a:hover, a:active{\n"
"	background-color: #000000;\n"
"}\n"
"\n"
"ul ul {\n"
"    position:absolute;\n"
"    left:0;\n"
"    top:100%;\n"
"    margin-left:-999em;\n"
"}\n"
"li:hover ul {\n"
"    margin-left:0;\n"
"    margin-right:0;\n"
"}\n"
"ul li ul{ display:block;float:none;width:100%;}\n"
"ul li ul li{ display:block;float:none;width:100%;}\n"
"li li a{ display:block;float:none;width:100%;text-align:left;}\n"
"#nav li:hover div {margin-left:0;}\n"
".help {position:absolute;z-index:5;text-align:left;padding:2px;margin-left:-999em;background-color: #313131;width:300px;}\n"
".helpstart {position:absolute;z-index:5;text-align:left;padding:2px;background-color: #313131;width:300px;display:none}\n"
".root {z-index:1;position:absolute;top:0px;left:0px;}\n"
".filterinputsearchdiv{position:fixed; background-color: #313131;display:none;}\n"
".filterinputsearch{width:100px;}\n"
"</style>\n"
"</head>\n"
"<body style=\"\">\n"
"<div class=\"filterinputsearchdiv\" id=\"FilterInputDiv\">Filter<br><input type=\"text\" id=\"FilterInput\" class=\"filterinputsearch\"></div>\n"
"<div class=\"helpstart\" id=\"helpwindow\" style=\"left:20px;top:20px\">\n"
"History View:<br>\n"
"Right Click + Drag : Select Region<br>\n"
"Click + Drag: Move Selection<br>\n"
"Click Frame : Center on frame<br>\n"
"<hr>\n"
"Main View:<br>\n"
"space: Freeze capturing<br>\n"
"x : Toggle View<br>\n"
"/ : Rotate connection port % 3<br>\n"
"Ctrl + Drag: Pan<br>\n"
"Click + Drag: Pan<br>\n"
"Enter: Capture selection/Next N Frames\n"
"<hr>\n"
"<table style=\"width:100%\">\n"
"<tr>\n"
"<td width=\"50%\" align=\"left\"><a href=\'javascript:void(0)\' onclick=\"ShowHelp(0);\">Close</a></td>\n"
"</tr>\n"
"</table>\n"
"</div>\n"
"<canvas id=\"DetailedView\" height=\"100%\" style=\"background-color:#343434;margin:0px;padding:0px;\"></canvas>\n"
"<script>\n"
"\"use strict\"\n"
"\n"
"var FRAME_HISTORY_COLOR_CPU = \'#ff7f27\';\n"
"var FRAME_HISTORY_COLOR_GPU = \'#ffffff\';\n"
"\n"
"var Settings = {};\n"
"\n"
"var HistoryHeight = 100;\n"
"var CanvasDetailedView = document.getElementById(\'DetailedView\');\n"
"var CanvasDetailedOffscreen = document.createElement(\'canvas\');\n"
"var FilterInput = document.getElementById(\'FilterInput\');\n"
"var FilterInputDiv = document.getElementById(\'FilterInputDiv\');\n"
"var FilterInputDivPos = {\"x\":-1,\"y\":-1,\"w\":-1,\"h\":-1};\n"
"var FilterInputValueLast = \'\';\n"
"\n"
"var CanvasArray0 = [];\n"
"var CanvasArray1 = [];\n"
"var Views = [];\n"
"\n"
"var ViewIndex = 0;\n"
"\n"
"var nWidth = CanvasDetailedView.width;\n"
"var nHeight = CanvasDetailedView.height;\n"
"var nBackColors = [\'#292929\', \'#343434\' ];\n"
"var nBackColorsDark = [\'#292929\', \'#272727\' ];\n"
"var nBackColorOffset = \'#404040\';\n"
"var FontHeight = 10;\n"
"var FontHeightLarge = 12;\n"
"var FontWidth = 1;\n"
"var FontAscent = 3; //Set manually\n"
"var Font = \'Bold \' + FontHeight + \'px Courier New\';\n"
"var FontLarge = \'Bold \' + FontHeightLarge + \'px Courier New\';\n"
"var FontFlash = \'Bold \' + 35 + \'px Courier New\';\n"
"var BoxHeight = FontHeight + 2;\n"
"var MouseX = 0;\n"
"var MouseY = 0;\n"
"var MouseReleased = false;\n"
"var MouseMoveTime = new Date();\n"
"\n"
"var nBarsWidth = 80;\n"
"var nOffsetBarsX = 0;\n"
"var nOffsetBarsY = 0;\n"
"var nOffsetCountersY = 0;\n"
"var nOffsetMenuTimers = 0;\n"
"var nOffsetMenuGroup = 0;\n"
"\n"
"var nHoverCounter = -1;\n"
"\n"
"var MouseDragOff = 0;\n"
"var MouseDragDown = 1;\n"
"var MouseDragUp = 2;\n"
"var MouseDragMove = 3;\n"
"var MouseDragState = MouseDragOff;\n"
"var MouseDragTarget = 0;\n"
"var MouseDragButton = 0;\n"
"var MouseDragKeyShift = 0;\n"
"var MouseDragKeyCtrl = 0;\n"
"var MouseDragX = 0;\n"
"var MouseDragY = 0;\n"
"var MouseDragXLast = 0;\n"
"var MouseDragYLast = 0;\n"
"var MouseDragXStart = 0;\n"
"var MouseDragYStart = 0;\n"
"\n"
"var MouseDragActiveXStart = 0;\n"
"var MouseDragActiveXEnd = -1;\n"
"\n"
"var ToolTipCallback = null;\n"
"\n"
"var DPR = 0;\n"
"var C_HUGE = 1e10;\n"
"\n"
"var ActivePreset = \"Default\";\n"
"var ActivePresetRO = 0;\n"
"var PresetPending = 0;\n"
"var Presets = [];\n"
"var ReadOnlyPresets = [];\n"
"\n"
"Settings.ReferenceTime = 50.0;\n"
"var ReferencePresets = [5.0, 10.0, 15.0, 20, 30, 33.33, 50, 66.66,100.0,250.0,500,1000.0];\n"
"var ReferenceTimeTweak = -1;\n"
"\n"
"Settings.TargetTime = 30;\n"
"var TargetTimeTweak = -1;\n"
"\n"
"\n"
"var AggregateFrames = 60;\n"
"Settings.AggregateFrames = 60;\n"
"var AggregatePresets = [0, 10,20,30,60,90,120,500];\n"
"var AggregateHistorySize = 5;\n"
"var AggregateTweak = -1;\n"
"var AggregateCurrent = 0;\n"
"\n"
"var AutoCaptureEnabled = 0;\n"
"var AutoCaptureDefaultThreshold = 66;\n"
"Settings.AutoCaptureTheshold = AutoCaptureDefaultThreshold;\n"
"var AutoCaptureThesholdPresets = [1,3,5,10,15,30,50,66,90,100,250,500,1000];\n"
"var AutoCaptureTweak = -1;\n"
"var AutoCaptureSourceTweak = -1;\n"
"var AutoCaptureSourceIndex = -1;\n"
"\n"
"var CaptureFramesDefault = 30;\n"
"Settings.CaptureFrames = CaptureFramesDefault;\n"
"var CaptureFramesPresets = [5,10,15,30,50,66,90,100];\n"
"var CaptureTweak = -1;\n"
"\n"
"\n"
"var ProfileData = {};\n"
"var ProfileStackTime = {};\n"
"var ProfileStackName = {};\n"
"var ProfileMode = 0;\n"
"var ProfileRedraw0 = 0;\n"
"var ProfileRedraw1 = 0;\n"
"var ProfileRedraw2 = 0;\n"
"var ProfileFps = 0;\n"
"var ProfileMs = 0;\n"
"var ProfileFpsAggr = 0;\n"
"var ProfileFpsCount = 0;\n"
"var ProfileLastTimeStamp = new Date();\n"
"var PlotfArray = new Array();\n"
"\n"
"var ConnectionStr = [\"x\", \"|\", \"x\", \"-\" ];\n"
"var ConnectionIdx = 0;\n"
"var EnabledArray = [];\n"
"\n"
"\n"
"var FrameData = {};\n"
"var FrameCount = 256;\n"
"var FramePending = 0;\n"
"\n"
"var WSConnected = 0;\n"
"var WSIsOpen = 0;\n"
"var WSSeconds = 0;\n"
"var WSFail = 0;\n"
"var WS;\n"
"var WSHost = location.hostname ? location.hostname : \"localhost\";\n"
"var WSPort = location.port ? location.port : 1338;\n"
"var WSPath;\n"
"\n"
"var CaptureButtonX = 0;\n"
"var CaptureButtonY = 0;\n"
"var GroupsEnabled = 0;\n"
"var TimersEnabled = 0;\n"
"\n"
"\n"
"var MSG_TIMER_TREE = 1;\n"
"var MSG_ENABLED = 2;\n"
"var MSG_FRAME = 3;\n"
"var MSG_LOADSETTINGS = 4; \n"
"var MSG_PRESETS = 5;\n"
"var MSG_CURRENTSETTINGS = 6; \n"
"var MSG_COUNTERS = 7; \n"
"\n"
"var TYPE_NONE = 0;\n"
"var TYPE_TIMER = 1;\n"
"var TYPE_GROUP = 2;\n"
"var TYPE_CATEGORY = 3;\n"
"var TYPE_SETTING = 4;\n"
"var TYPE_COUNTER = 5;\n"
"\n"
"\n"
"var WSSend = 0;\n"
"var WSReceive = 0;\n"
"var WSSendBytes = 0;\n"
"var WSReceiveBytes = 0;\n"
"var WSOpenTime = 0;\n"
"\n"
"\n"
"var TimerArray = [];\n"
"var CounterArray = [];\n"
"var Empty = {\"id\":0, \"w\":0, \"depth\":0, \"sibling\":-1,\"parent\":-1,\"firstchild\":-1};\n"
"var WidthArray = [];\n"
"var WidthTree = 0;\n"
"Settings.ViewActive = 0;\n"
"Settings.ViewCompressed = 0;\n"
"Settings.AllowHighDPI = 1;\n"
"var ViewNames = [\"Graph\", \"Graph\", \"Bars\", \"Bars\", \"Bars\", \"Counters\"];\n"
"var ViewNames2 = [\"[split]\", \"[single]\", \"[table]\", \"[all]\", \"[single]\", \"\"];\n"
"\n"
"var VIEW_GRAPH_SPLIT = 0;\n"
"var VIEW_GRAPH = 1;\n"
"var VIEW_BAR = 2;\n"
"var VIEW_BAR_ALL = 3;\n"
"var VIEW_BAR_SINGLE = 4;\n"
"var VIEW_COUNTERS = 5;\n"
"var VIEW_SIZE = 6;\n"
"\n"
"\n"
"Settings.FancyGraph = 1;\n"
"Settings.AutomaticReference = 1;\n"
"\n"
"\n"
"var ReferenceHistory = 0;\n"
"var ReferenceGraph = 0;\n"
"var ReferenceBar = 0;\n"
"var ReferenceHistoryAutomatic = 0;\n"
"var ReferenceGraphAutomatic = 0;\n"
"var ReferenceBarAutomatic = 0;\n"
"\n"
"var SingleTimerBars = 0;\n"
"var History;\n"
"var MainView;\n"
"var X7Views;\n"
"var X7LegendView;\n"
"var X7BarColumnRemap = [0,1,2,3,4,5,6];\n"
"var X7BarColumnMask = -1;\n"
"var X7LegendOffset = 25;\n"
"var X7BarLastView = -1;\n"
"var X7BarFirstView = -1;\n"
"\n"
"\n"
"var ViewBarMaxMsTextLength = 0;\n"
"\n"
"Settings.SortColumn = 0;\n"
"Settings.SortColumnOrderFlip = 0;\n"
"Settings.SortColumnMouseOver = \"\";\n"
"var SortColumnMouseOverNext = \"\";\n"
"\n"
"\n"
"var KeyShiftDown = 0;\n"
"var KeyCtrlDown = 0;\n"
"\n"
"var IsFrozen = 0;\n"
"\n"
"var PresetToLoad;\n"
"var PresetToLoadRO = 0;\n"
"var HelpFade;\n"
"\n"
"\n"
"TimerArray.push(Empty); // 0 is root of tree\n"
"\n"
"var StrTime = \"Time\";\n"
"var StrGroup = \"Group\";\n"
"var StrThread = \"Thread\";\n"
"var StrTimer = \"Timer\";\n"
"var StrAverage = \"Average\";\n"
"var StrMax = \"Max\";\n"
"var StrTotal = \"Total\";\n"
"var StrMin = \"Min\";\n"
"var StrSpike = \"Spike%\";\n"
"var StrCallAverage = \"Call Average\";\n"
"var StrCount = \"Count\";\n"
"var StrExclAverage = \"Excl Average\";\n"
"var StrExclMax = \"Excl Max\";\n"
"var StrExclMin = \"Excl Max\";\n"
"\n"
"\n"
"\n"
"var CounterNameWidth = 100;\n"
"var CounterValueWidth = 100;\n"
"var CounterLimitWidth = 100;\n"
"\n"
"var FormatCounterDefault = 0;\n"
"var FormatCounterBytes = 1;\n"
"var FormatCounterBytesExt = [\"b\",\"kb\",\"mb\",\"gb\",\"tb\",\"pb\",\"eb\",\"zb\",\"yb\"];\n"
"\n"
"var BarColumnNamesTable = [StrAverage, StrMax, StrTotal, StrMin, StrSpike, StrCallAverage, StrCount, StrExclAverage, StrExclMax];\n"
"var BarColumnNamesMulti = [StrTime, StrAverage, StrMax, StrMin, StrExclAverage, StrExclMax, StrExclMin];\n"
"var BarColumnNamesSingle = [StrAverage, StrMax, StrMin, StrExclAverage, StrExclMax, StrExclMin, StrCallAverage];\n"
"\n"
"function GetBarColumnNames()\n"
"{\n"
"	if(Settings.ViewActive == VIEW_BAR_ALL)\n"
"	{\n"
"		return BarColumnNamesMulti;\n"
"	}\n"
"	else if(Settings.ViewActive == VIEW_BAR_SINGLE)\n"
"	{\n"
"		return BarColumnNamesSingle;\n"
"	}\n"
"	else\n"
"	{\n"
"		return BarColumnNamesTable;\n"
"	}\n"
"}\n"
"function GetBarColumnEnabled()\n"
"{\n"
"	if(Settings.ViewActive == VIEW_BAR_ALL)\n"
"	{\n"
"		return Settings.BarColumnEnabledMulti;\n"
"	}\n"
"	else if(Settings.ViewActive == VIEW_BAR_SINGLE)\n"
"	{\n"
"		return Settings.BarColumnEnabledSingle;\n"
"	}\n"
"	else\n"
"	{\n"
"		return Settings.BarColumnEnabledTable;\n"
"	}\n"
"}\n"
"\n"
"Settings.BarColumnEnabledTable = new Array(BarColumnNamesTable.length);\n"
"Settings.BarColumnEnabledSingle = new Array(BarColumnNamesSingle.length);\n"
"Settings.BarColumnEnabledMulti = new Array(BarColumnNamesMulti.length);\n"
"var ColumnsWidth = new Array(BarColumnNamesTable.length);\n"
"function ClearEnabled(E)\n"
"{\n"
"	for(var i = 0; i < E.length; ++i)\n"
"	{\n"
"		E[i] = 1;\n"
"		ColumnsWidth[i] = 10;\n"
"	}\n"
"}\n"
"ClearEnabled(Settings.BarColumnEnabledTable);\n"
"ClearEnabled(Settings.BarColumnEnabledSingle);\n"
"ClearEnabled(Settings.BarColumnEnabledMulti);\n"
"\n"
"function Plotf(str)\n"
"{\n"
"	PlotfArray.push(str)\n"
"}\n"
"function PlotfClear()\n"
"{\n"
"	PlotfArray = new Array();\n"
"}\n"
"\n"
"function ProfileModeClear()\n"
"{\n"
"	if(ProfileMode)\n"
"	{\n"
"\n"
"		for(var idx in ProfileData)\n"
"		{\n"
"			if(idx == \"Plot\")\n"
"				continue;\n"
"			var Timer = ProfileData[idx];\n"
"			Timer.Count = 0;\n"
"			Timer.Time = 0;\n"
"		}\n"
"\n"
"		// ProfileData = new Object();\n"
"		ProfileStackTime = new Array();\n"
"		ProfileStackName = new Array();\n"
"	}\n"
"}\n"
"function ProfileEnter(Name)\n"
"{\n"
"	if(ProfileMode)\n"
"	{\n"
"		ProfileStackTime.push(new Date());\n"
"		ProfileStackName.push(Name);\n"
"	}\n"
"}\n"
"function ProfileLeave()\n"
"{\n"
"	if(ProfileMode)\n"
"	{\n"
"		var Time = new Date();\n"
"		var Delta = Time - ProfileStackTime.pop();\n"
"		var Name = ProfileStackName.pop();\n"
"		var Obj = ProfileData[Name];\n"
"		if(!Obj)\n"
"		{\n"
"			Obj = new Object();\n"
"			Obj.Count = 0;\n"
"			Obj.Name = Name;\n"
"			Obj.Time = 0;\n"
"			Obj.AggrCount = 0;\n"
"			Obj.AggrTime = 0;\n"
"			Obj.AvgTime = 0;\n"
"			ProfileData[Name] = Obj;\n"
"		}\n"
"		Obj.Time += Delta;\n"
"		Obj.Count += 1;\n"
"	}\n"
"}\n"
"\n"
"function ProfilePlot(s)\n"
"{\n"
"	if(ProfileMode)\n"
"	{\n"
"		var A = ProfileData.Plot;\n"
"		if(!A)\n"
"		{\n"
"			ProfileData.Plot = Array();\n"
"			A = ProfileData.Plot;\n"
"		}\n"
"		if(A.length<10)\n"
"		{\n"
"			A.push(s);\n"
"		}\n"
"	}\n"
"}\n"
"function ProfileModeDump()\n"
"{\n"
"	for(var idx in ProfileData)\n"
"	{\n"
"		var Timer = ProfileData[idx];\n"
"		console.log(Timer.Name + \" \" + Timer.Time + \"ms \" + Timer.Count);\n"
"	}\n"
"\n"
"}\n"
"function ProfileModeDraw(Canvas)\n"
"{\n"
"	if(ProfileMode)\n"
"	{\n"
"		ProfileFpsCount ++ ;\n"
"		var AggrFrames = 60;\n"
"		var StringArray = [];\n"
"		function FormatTime(f)\n"
"		{\n"
"			return (\"         \" + f.toFixed(2)).slice(-8);\n"
"		}\n"
"		function FormatStr(t, count, avg)\n"
"		{\n"
"			var str = FormatTime(t) + \"ms #\" + count + \"\" + FormatTime(avg) + \"ms\";\n"
"			return str;\n"
"		}\n"
"		for(var idx in ProfileData)\n"
"		{\n"
"			if(idx == \"Plot\")\n"
"				continue;\n"
"			var Timer = ProfileData[idx];\n"
"			Timer.AggrCount += Timer.Count;\n"
"			Timer.AggrTime += Timer.Time;\n"
"			if(ProfileFpsCount == AggrFrames)\n"
"			{\n"
"				Timer.AvgTime = Timer.AggrTime / AggrFrames;\n"
"				Timer.AggrCount = 0;\n"
"				Timer.AggrTime = 0;\n"
"			}\n"
"			StringArray.push(Timer.Name);\n"
"			StringArray.push(FormatStr(Timer.Time, Timer.Count, Timer.AvgTime));\n"
"			// StringArray.push(\"#\");\n"
"			// StringArray.push(\"\" + Timer.Count);\n"
"		}\n"
"		var Time = new Date();\n"
"		var Delta = Time - ProfileLastTimeStamp;\n"
"		ProfileLastTimeStamp = Time;\n"
"		StringArray.push(\"Frame Delta\");\n"
"		StringArray.push(Delta + \"ms\");\n"
"		{\n"
"			ProfileFpsAggr += Delta;\n"
"\n"
"			if(ProfileFpsCount == AggrFrames)\n"
"			{\n"
"				ProfileMs = ProfileFpsAggr / AggrFrames;\n"
"				ProfileFps = 1000 / (ProfileFpsAggr / AggrFrames);\n"
"				ProfileFpsAggr = 0;\n"
"				ProfileFpsCount = 0;\n"
"			}\n"
"			StringArray.push(\"Avg FPS\");\n"
"			StringArray.push(\"\" + ProfileFps.toFixed(2));\n"
"			StringArray.push(\"Avg MS\");\n"
"			StringArray.push(\"\" + ProfileMs.toFixed(2));\n"
"		}\n"
"		for(var i = 0; i < ProfileData.Plot; ++i)\n"
"		{\n"
"			StringArray.push(\"\");\n"
"			StringArray.push(ProfileData.Plot[i]);\n"
"		}\n"
"		ProfileData.Plot = Array();\n"
"		DrawToolTip(StringArray, Canvas, 0, 200);\n"
"	}\n"
"}\n"
"\n"
"\n"
"\n"
"function MeasureFont()\n"
"{\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"	context.font = Font;\n"
"	FontWidth = context.measureText(\'W\').width;\n"
"\n"
"}\n"
"function ResizeCanvasDPR(w, h, c)\n"
"{\n"
"	DPR = Settings.AllowHighDPI ? window.devicePixelRatio : 0;\n"
"	if(DPR)\n"
"	{\n"
"		c.style.width = w + \'px\'; \n"
"		c.style.height = h + \'px\';\n"
"		c.width = w * DPR;\n"
"		c.height = h * DPR;\n"
"		c.getContext(\'2d\').scale(DPR,DPR);\n"
"	}\n"
"	else\n"
"	{\n"
"		DPR = 1;\n"
"		c.width = w;\n"
"		c.height = h;\n"
"	}\n"
"\n"
"}\n"
"\n"
"function ResizeCanvasDPR2(w, h, c)\n"
"{\n"
"	DPR = window.devicePixelRatio;\n"
"	if(DPR)\n"
"	{\n"
"		c.style.width = w + \'px\'; \n"
"		c.style.height = h + \'px\';\n"
"		c.width = w * DPR;\n"
"		c.height = h * DPR;\n"
"		c.getContext(\'2d\').scale(DPR,DPR);\n"
"	}\n"
"	else\n"
"	{\n"
"		c.width = w;\n"
"		c.height = h;\n"
"	}\n"
"\n"
"}\n"
"function ResizeView(View, x, y, w, h)\n"
"{\n"
"	View.x = x;\n"
"	View.y = y;\n"
"	View.w = w;\n"
"	View.h = h;\n"
"	var c0 = View.Canvas[0];\n"
"	var c1 = View.Canvas[1];\n"
"	ResizeCanvasDPR(w, h, c0);\n"
"	ResizeCanvasDPR(w, h, c1);\n"
"	c0.getContext(\'2d\').clearRect(0, 0, w, h);\n"
"	c1.getContext(\'2d\').clearRect(0, 0, w, h);\n"
"	View.OffscreenData[0] = c0.getContext(\'2d\').getImageData(0, 0, c0.width, c0.height);\n"
"	View.OffscreenData[1] = c1.getContext(\'2d\').getImageData(0, 0, c1.width, c1.height);\n"
"\n"
"}\n"
"function CreateView(x, y, w, h, name, DisplayFunc, visible, index)\n"
"{\n"
"	var idx = Views.length;\n"
"	var c0 = CanvasArray0[idx];\n"
"	var c1 = CanvasArray1[idx];\n"
"	if(!c0)\n"
"	{\n"
"		c0 = document.createElement(\'canvas\');\n"
"		CanvasArray0[idx] = c0;\n"
"	}\n"
"	if(!c1)\n"
"	{\n"
"		c1 = document.createElement(\'canvas\');\n"
"		CanvasArray1[idx] = c1;\n"
"	}\n"
"	var View = {};\n"
"	View.x = x;\n"
"	View.y = y;\n"
"	View.w = w;\n"
"	View.h = h;\n"
"	View.Canvas = [c0, c1];\n"
"	View.OffscreenData = [null, null];\n"
"	View.visible = visible;\n"
"	View.index = index;\n"
"	ResizeCanvasDPR(w, h, c0);\n"
"	ResizeCanvasDPR(w, h, c1);\n"
"\n"
"	c0.getContext(\'2d\').clearRect(0, 0, w, h);\n"
"	c1.getContext(\'2d\').clearRect(0, 0, w, h);\n"
"	View.OffscreenData[0] = c0.getContext(\'2d\').getImageData(0, 0, c0.width, c0.height);\n"
"	View.OffscreenData[1] = c1.getContext(\'2d\').getImageData(0, 0, c1.width, c1.height);\n"
"	View.BackBuffer = 0;\n"
"	View.DisplayFunc = DisplayFunc;\n"
"	Views.push(View);\n"
"	return View;\n"
"}\n"
"\n"
"function CreateViews(Width, Height, ViewCompressed)\n"
"{\n"
"	Views = [];\n"
"	var HistoryH = ViewCompressed ? 0 : HistoryHeight;\n"
"	History = CreateView(0, 0, Width, HistoryHeight, \"History\", DrawHistory, true, 0);\n"
"	History.visible = !ViewCompressed;\n"
"	MainView = CreateView(0, HistoryH, Width, Height-HistoryH, \"Main\", DrawGraphSplit, true);\n"
"	X7Views = [];\n"
"	var w = Width / 7;\n"
"	var x = 0;\n"
"	X7Views.push(CreateView(w*0, HistoryH, w, Height - HistoryH, \"x5_0\", DrawBars, false, 0) );\n"
"	X7Views.push(CreateView(w*1, HistoryH, w, Height - HistoryH, \"x5_1\", DrawBars, false, 1) );\n"
"	X7Views.push(CreateView(w*2, HistoryH, w, Height - HistoryH, \"x5_2\", DrawBars, false, 2) );\n"
"	X7Views.push(CreateView(w*3, HistoryH, w, Height - HistoryH, \"x5_3\", DrawBars, false, 3) );\n"
"	X7Views.push(CreateView(w*4, HistoryH, w, Height - HistoryH, \"x5_4\", DrawBars, false, 4) );\n"
"	X7Views.push(CreateView(w*5, HistoryH, w, Height - HistoryH, \"x5_3\", DrawBars, false, 5) );\n"
"	X7Views.push(CreateView(w*6, HistoryH, w, Height - HistoryH, \"x5_3\", DrawBars, false, 6) );\n"
"	X7LegendView = CreateView(0, Height-X7LegendOffset, Width, X7LegendOffset, \"x7_legend\", DrawBarsLegend, false, 0);\n"
"\n"
"}\n"
"\n"
"function ResizeCanvas() \n"
"{\n"
"	nWidth = window.innerWidth;\n"
"	nHeight = window.innerHeight;\n"
"	DPR = Settings.AllowHighDPI ? window.devicePixelRatio : 0;\n"
"	ResizeCanvasDPR(nWidth, nHeight, CanvasDetailedView);\n"
"	ResizeCanvasDPR(nWidth, nHeight, CanvasDetailedOffscreen);\n"
"\n"
"	if(DPR)\n"
"	{\n"
"		CanvasDetailedView.style.width = nWidth + \'px\'; \n"
"		CanvasDetailedView.style.height = nHeight + \'px\';\n"
"		CanvasDetailedView.width = nWidth * DPR;\n"
"		CanvasDetailedView.height = nHeight * DPR;\n"
"		CanvasDetailedView.getContext(\'2d\').scale(DPR,DPR);\n"
"\n"
"		CanvasDetailedOffscreen.style.width = nWidth + \'px\';\n"
"		CanvasDetailedOffscreen.style.height = nHeight + \'px\';\n"
"		CanvasDetailedOffscreen.width = nWidth * DPR;\n"
"		CanvasDetailedOffscreen.height = nHeight * DPR;\n"
"		CanvasDetailedOffscreen.getContext(\'2d\').scale(DPR,DPR);\n"
"\n"
"	}\n"
"	else\n"
"	{\n"
"		DPR = 1;\n"
"		CanvasDetailedView.width = nWidth;\n"
"		CanvasDetailedView.height = nHeight;\n"
"		CanvasDetailedOffscreen.width = nWidth;\n"
"		CanvasDetailedOffscreen.height = nHeight;\n"
"	}\n"
"	MeasureFont();\n"
"	CreateViews(nWidth, nHeight, Settings.ViewCompressed);\n"
"	ActivateView(Settings.ViewActive);\n"
"}\n"
"\n"
"\n"
"function FormatTime(Time)\n"
"{\n"
"	return Time.toFixed(2);\n"
"}\n"
"var hh = 0;\n"
"\n"
"\n"
"function DrawBarsLegend(View, LocalMouseX, LocalMouseY, SubIndex)\n"
"{\n"
"	ProfileEnter(\"DrawBar\");\n"
"	var TimerMap = FrameData.TimerMap;\n"
"	if(!TimerMap)\n"
"		return;\n"
"	if(Settings.ViewCompressed)\n"
"		return;\n"
"	var Canvas = View.Canvas[View.BackBuffer];\n"
"	var context = Canvas.getContext(\'2d\');\n"
"	context.clearRect(0, 0, View.w, View.h);\n"
"	var X = 0;\n"
"	var Y = View.h/2;\n"
"	var XSpace = 5;\n"
"	var XSpace2 = XSpace * 2;\n"
"	function DrawEntry(T)\n"
"	{\n"
"		X += XSpace2*2;\n"
"		context.fillStyle = T.color;\n"
"		context.fillRect(X-XSpace,Y-XSpace,XSpace2,XSpace2);\n"
"		X += XSpace + 2;\n"
"		context.fillStyle = \'white\';\n"
"		var w = context.measureText(T.name).width;\n"
"		context.fillText(T.name, X, Y + FontHeight/2);\n"
"		X += w;		\n"
"	}\n"
"\n"
"	if(SingleTimerBars == 0)\n"
"	{\n"
"		for(var key in TimerMap)\n"
"		{\n"
"			var idx = GetTimer(key);\n"
"			var T = TimerArray[idx];\n"
"			if(T.e)\n"
"			{\n"
"				DrawEntry(T);\n"
"			}\n"
"		}\n"
"	}\n"
"	else if(EnabledArray.length > 0)\n"
"	{\n"
"		var idx = EnabledArray[0];\n"
"		var T = TimerArray[idx];\n"
"		DrawEntry(T);\n"
"	}		\n"
"}\n"
"\n"
"function DrawBars(View, LocalMouseX, LocalMouseY, SubIndex)\n"
"{\n"
"	var TimerMap = FrameData.TimerMap;\n"
"	if(!TimerMap)\n"
"		return;\n"
"	if(!SubIndex)\n"
"		SubIndex = 0;\n"
"\n"
"	ProfileEnter(\"DrawBar\");\n"
"	var Canvas = View.Canvas[View.BackBuffer];\n"
"	var context = Canvas.getContext(\'2d\');\n"
"\n"
"	context.clearRect(0, 0, View.w, View.h);\n"
"	var bgcolor = nBackColors[ViewIndex%2];\n"
"	context.fillStyle = bgcolor;\n"
"	context.fillRect(0, 0, View.w, View.h);\n"
"	var Title = \"?\";\n"
"	var TitleName = null;\n"
"	var nNumBars = 0;\n"
"	var BarNames = [];\n"
"	var BarTimes = [];\n"
"	var BarColors = [];\n"
"	var AggregateIndex = Settings.AggregateFrames <= 0 ? AggregateHistorySize-1 : AggregateHistorySize-2; //fix med \n"
"	var GetTime = null;\n"
"	var SubIndex = X7BarColumnRemap[SubIndex];\n"
"\n"
"	if(SingleTimerBars == 0)\n"
"	{\n"
"		if(SubIndex == 0)\n"
"		{\n"
"			Title = \"Time\";\n"
"			GetTime = function(FD){ return FD.FrameTime; };\n"
"		}\n"
"		else if(SubIndex == 1)\n"
"		{\n"
"			Title = \"Average\";\n"
"			GetTime = function(FD){ return FD.TimeAvg[AggregateIndex]; };\n"
"		}\n"
"		else if(SubIndex == 2)\n"
"		{\n"
"			Title = \"Max\";\n"
"			GetTime = function(FD){ return FD.TimeMax[AggregateIndex]; };\n"
"		}\n"
"		else if(SubIndex == 3)\n"
"		{\n"
"			Title = \"Min\";\n"
"			GetTime = function(FD){ return FD.TimeMin[AggregateIndex]; };\n"
"		}\n"
"		else if(SubIndex == 4)\n"
"		{\n"
"			Title = \"Exclusive Avg\";\n"
"			GetTime = function(FD){ return FD.TimeExclAvg[AggregateIndex]; };\n"
"		}\n"
"		else if(SubIndex == 5)\n"
"		{\n"
"			Title = \"Exclusive Max\";\n"
"			GetTime = function(FD){ return FD.TimeExclMax[AggregateIndex]; };\n"
"		}\n"
"		else if(SubIndex == 6)\n"
"		{\n"
"			Title = \"Exclusive Min\";\n"
"			GetTime = function(FD){ return FD.TimeExclMin[AggregateIndex]; };\n"
"\n"
"		}\n"
"		for(var key in TimerMap)\n"
"		{\n"
"			var idx = GetTimer(key);\n"
"			var T = TimerArray[idx];\n"
"			if(T.e)\n"
"			{\n"
"				nNumBars++;\n"
"				var FD = TimerMap[key];\n"
"				var Time = GetTime(FD);\n"
"				BarNames.push(T.name);\n"
"				BarTimes.push(Time);\n"
"				BarColors.push(T.color);\n"
"			}\n"
"		}\n"
"\n"
"	}\n"
"	else if(EnabledArray.length > 0)\n"
"	{\n"
"		var idx = EnabledArray[0];\n"
"		var T = TimerArray[idx];\n"
"		var FD =  GetFrameData(T.id);\n"
"		var Property = null;\n"
"		if(SubIndex == 0)\n"
"		{\n"
"			Title = \"Average\";\n"
"			Property = \"TimeAvg\";\n"
"		}\n"
"		else if(SubIndex == 1)\n"
"		{\n"
"			Title = \"Max\";\n"
"			Property = \"TimeMax\";\n"
"		}\n"
"		else if(SubIndex == 2)\n"
"		{\n"
"			Title = \"Min\";\n"
"			Property = \"TimeMin\";\n"
"		}\n"
"		else if(SubIndex == 3)\n"
"		{\n"
"			Title = \"Exclusive Average\";\n"
"			Property = \"TimeExclAvg\";\n"
"		}\n"
"		else if(SubIndex == 4)\n"
"		{\n"
"			Title = \"Exclusive Max\";\n"
"			Property = \"TimeExclMax\"\n"
"		}\n"
"		else if(SubIndex == 5)\n"
"		{\n"
"			Title = \"Exclusive Min\";\n"
"			Property = \"TimeExclMin\"\n"
"		}\n"
"		else if(SubIndex == 6)\n"
"		{\n"
"			Title = \"Call Average\";\n"
"			Property = \"TimeCallAvg\"\n"
"		}\n"
"		TitleName = T.name;\n"
"		for(var i = 0; i < AggregateHistorySize; ++i)\n"
"		{\n"
"			nNumBars++;\n"
"			var A = FD[Property];\n"
"			var Time = A[i];\n"
"			BarTimes.push(Time);\n"
"			BarColors.push(T.color);\n"
"		}\n"
"	}\n"
"\n"
"\n"
"	if(!nNumBars)\n"
"	{\n"
"		ProfileLeave();\n"
"		return;\n"
"	}\n"
"\n"
"	var h = View.h;\n"
"	var w = View.w;\n"
"	var MsTextExtraSpace = Math.cos(3.14/4.0) * (ViewBarMaxMsTextLength);\n"
"	var DrawXLeft = Settings.ViewCompressed ? 3 : 15;\n"
"	DrawXLeft = Math.max(DrawXLeft, MsTextExtraSpace);\n"
"	var DrawXRight = Settings.ViewCompressed ? 3: 10;\n"
"	var DrawY = 35 * 2;\n"
"	if(Settings.ViewCompressed)\n"
"	{\n"
"		DrawY = (MsTextExtraSpace) + 35;\n"
"	}\n"
"	var DrawWidth = w - DrawXLeft - DrawXRight;\n"
"	var DrawHeight = h - DrawY;\n"
"	var SpaceWidth = 5;\n"
"	var BarWidth = (DrawWidth-SpaceWidth*(nNumBars-1))/ nNumBars;\n"
"	for(var x = 0; x < 2; ++x)\n"
"	{\n"
"		if(BarWidth < 14)\n"
"		{\n"
"			SpaceWidth -= 1;\n"
"			BarWidth = (DrawWidth-SpaceWidth*(nNumBars-1))/ nNumBars;\n"
"		}\n"
"	}\n"
"	if(BarWidth > 50)\n"
"		BarWidth = 50;\n"
"	var BarHeight = DrawHeight - 5;\n"
"\n"
"	var ReferenceTime = ReferenceBar;\n"
"\n"
"	var fHeightScale = h / ReferenceTime;\n"
"	var MouseDragging = 0;\n"
"	var fWidth = w / FrameCount;\n"
"	var Keys = [];\n"
"	var X = DrawXLeft;\n"
"	var offset = 0;\n"
"	context.textAlign = \'center\'\n"
"	context.fillStyle = \'#ffffff\';\n"
"	context.fillText(Title, w / 2.0, FontHeight);\n"
"	context.textAlign = \'left\';\n"
"	context.fillStyle = \'wheat\';\n"
"	var BaseY = 20;\n"
"	if(SubIndex == X7BarFirstView)\n"
"	{\n"
"		context.fillText(ReferenceTime.toFixed(2) + \'ms\', 0, BaseY - 5 + DrawHeight - BarHeight);\n"
"	}\n"
"	else if(SubIndex == X7BarLastView)\n"
"	{\n"
"		context.textAlign = \'right\';\n"
"		context.fillText(ReferenceTime.toFixed(2) + \'ms\', w, BaseY - 5 + DrawHeight - BarHeight);\n"
"	}\n"
"	context.textAlign = \'right\';\n"
"	var BarFont = FontLarge;\n"
"	var DrawNames = true;\n"
"	if(BarWidth < 14)\n"
"	{\n"
"		DrawNames = BarWidth > 4;\n"
"		var FontXX = \'Bold \' + Math.floor(BarWidth) + \'px Courier New\';\n"
"		BarFont = FontXX;\n"
"\n"
"	}\n"
"	context.font = BarFont;\n"
"	for(var i = 0; i < BarTimes.length; ++i)\n"
"	{\n"
"		var TimeText = FormatTime(Time);\n"
"		var w = context.measureText(TimeText).width;\n"
"		ViewBarMaxMsTextLength = Math.max(w, ViewBarMaxMsTextLength);\n"
"	\n"
"\n"
"	}\n"
"	for(var i = 0; i < BarTimes.length; ++i)\n"
"	{\n"
"		var Time = BarTimes[i];\n"
"		var TimeText = FormatTime(Time);\n"
"		ReferenceBarAutomatic = Math.max(Time, ReferenceBarAutomatic);\n"
"		var Color = BarColors[i];\n"
"		var fPrc = Time / ReferenceTime;\n"
"		if(fPrc > 1.0)\n"
"			fPrc = 1.0\n"
"		var BarH = fPrc * BarHeight;\n"
"\n"
"		var X0 = X;\n"
"		var Y0 = BaseY + DrawHeight - BarH;\n"
"		context.fillStyle = Color;\n"
"		context.fillRect(X0, Y0, BarWidth, BarH);\n"
"		context.fillStyle = \'#ffffff\';\n"
"		var MouseOver = LocalMouseX > X0 && LocalMouseX < X0 + BarWidth;\n"
"		if(MouseOver || (Settings.ViewCompressed&&DrawNames))\n"
"		{\n"
"			context.save();\n"
"			context.translate(X0 + BarWidth * 0.5, BaseY + DrawHeight - 2);\n"
"			context.rotate(-3.14/2.0);\n"
"			context.font = BarFont;\n"
"			context.textAlign = \'left\';\n"
"			context.textBaseline = \'middle\';\n"
"			var m = context.measureText(BarNames[i]);\n"
"			context.fillStyle = \'black\';\n"
"			context.fillText(BarNames[i], -1, -1);\n"
"			context.fillStyle = \'white\';\n"
"			context.fillText(BarNames[i], 0, 0);\n"
"			context.textAlign = \'right\';\n"
"			context.restore();\n"
"		}\n"
"		context.save();\n"
"		var XText = X+BarWidth;\n"
"		var YText = BaseY + DrawHeight + FontHeight;		\n"
"		context.translate(XText, YText);\n"
"		context.rotate(-3.14/4.0);\n"
"		context.font = BarFont;\n"
"		context.fillText(TimeText, 0, 0);\n"
"		context.restore();\n"
"\n"
"		X += BarWidth + SpaceWidth;\n"
"	}\n"
"	context.font = Font;\n"
"	ProfileLeave();\n"
"}\n"
"\n"
"\n"
"function DrawBarView(View, LocalMouseX, LocalMouseY, SubIndex)\n"
"{\n"
"	ProfileEnter(\"DrawBarView\");\n"
"	var Canvas = View.Canvas[View.BackBuffer];\n"
"	var context = Canvas.getContext(\'2d\');\n"
"	var Height = BoxHeight;\n"
"	var Width = nWidth;\n"
"	var Y = Height;\n"
"	var XBase = 0;\n"
"	var nColorIndex = 0;\n"
"	var bMouseIn = 0;\n"
"	var RcpReferenceTime = 1.0 / Settings.ReferenceTime;\n"
"	var CountWidth = 12 * FontWidth;\n"
"	var InnerBoxHeight = BoxHeight-2;\n"
"	var TimerLen = 8;\n"
"	var TimerWidth = TimerLen * FontWidth;\n"
"	var nWidthBars = nBarsWidth+2;\n"
"	var nWidthMs = TimerWidth+2+10;\n"
"	var NameWidth = 200;\n"
"	var R = 0;\n"
"\n"
"\n"
"	context.clearRect(0, 0, View.w, View.h);\n"
"	context.fillStyle = \'white\';\n"
"	context.font = Font;\n"
"\n"
"\n"
"	function HeaderMouseHandle(XBegin, X, Header)\n"
"	{\n"
"		var bMouseIn = LocalMouseY >= 0 && LocalMouseY < BoxHeight && LocalMouseX < X && LocalMouseX > XBegin;\n"
"		if(bMouseIn)\n"
"		{\n"
"			SortColumnMouseOverNext = Header;\n"
"		}\n"
"	}\n"
"	function HeaderString(Header)\n"
"	{\n"
"		if(Header == Settings.SortColumnMouseOver)\n"
"		{\n"
"			return Header + (Settings.SortColumnOrderFlip ? \'<\' : \'>\');\n"
"		}\n"
"		else\n"
"		{\n"
"			return Header;\n"
"		}\n"
"\n"
"	}\n"
"	function DrawHeaderSplit(Header)\n"
"	{\n"
"		if(Settings.BarColumnEnabledTable[R])\n"
"		{\n"
"			context.fillStyle = \'white\';\n"
"			context.fillText(HeaderString(Header), X, Height-FontAscent);\n"
"			var XBegin = X;\n"
"			X += nWidthBars;\n"
"			context.fillStyle = nBackColorOffset;\n"
"			X += ColumnsWidth[R];\n"
"\n"
"			if(X >= NameWidth)\n"
"			{\n"
"				context.fillRect(X-3, 0, 1, nHeight);\n"
"			}\n"
"			HeaderMouseHandle(XBegin, X, Header);\n"
"		}\n"
"		R++;\n"
"	}\n"
"	function DrawHeaderSplitSingle(Header)\n"
"	{\n"
"		if(Settings.BarColumnEnabledTable[R])\n"
"		{\n"
"			context.fillStyle = \'white\';\n"
"			context.fillText(HeaderString(Header), X, Height-FontAscent);\n"
"			var XBegin = X;\n"
"			X += ColumnsWidth[R];\n"
"			context.fillStyle = nBackColorOffset;\n"
"			if(X >= NameWidth)\n"
"			{\n"
"				context.fillRect(X-3, 0, 1, nHeight);\n"
"			}\n"
"			HeaderMouseHandle(XBegin, X, Header);\n"
"		}\n"
"		R++;\n"
"	}\n"
"	function DrawHeaderSplitLeftRight(HeaderLeft, HeaderRight, Width)\n"
"	{\n"
"		var HeaderLeftS = HeaderString(HeaderLeft);\n"
"		var HeaderRightS = HeaderString(HeaderRight);\n"
"		context.textAlign = \'left\';\n"
"		context.fillStyle = \'white\';\n"
"		context.fillText(HeaderLeftS, X, Height-FontAscent);\n"
"		var wLeft = context.measureText(HeaderLeftS).width;\n"
"		var XBegin = X;\n"
"		X += Width;\n"
"		context.textAlign = \'right\';\n"
"		context.fillText(HeaderRightS, X-5, Height-FontAscent);\n"
"		context.textAlign = \'left\';\n"
"		context.fillStyle = nBackColorOffset;\n"
"		if(X >= NameWidth)\n"
"		{\n"
"			context.fillRect(X-3, 0, 1, nHeight);\n"
"		}\n"
"		HeaderMouseHandle(XBegin, XBegin + wLeft, HeaderLeft);\n"
"		HeaderMouseHandle(XBegin + wLeft, X, HeaderRight);\n"
"\n"
"	}\n"
"	function DrawTimer(Value, Color)\n"
"	{\n"
"		if(Settings.BarColumnEnabledTable[R])\n"
"		{\n"
"			var Prc = Value * RcpReferenceTime;\n"
"			var YText = Y+Height-FontAscent;\n"
"			if(Prc > 1)\n"
"			{\n"
"				Prc = 1;\n"
"			}\n"
"			context.textAlign = \'left\';\n"
"			context.fillStyle = Color;\n"
"			context.fillRect(X+1, Y+1, Prc * nBarsWidth, InnerBoxHeight);\n"
"			X += nWidthBars;\n"
"			context.fillStyle = \'white\';\n"
"			var TimerText = Value.toFixed(2);\n"
"			var W = context.measureText(TimerText).width + FontWidth;\n"
"			ColumnsWidth[R] = Math.max(W, ColumnsWidth[R]);\n"
"			X += ColumnsWidth[R];\n"
"			context.textAlign = \'right\';\n"
"			context.fillText(TimerText, X - FontWidth, YText);\n"
"			context.textAlign = \'left\';\n"
"		}\n"
"		R++;\n"
"	}\n"
"	function DrawCount(Str)\n"
"	{\n"
"		if(Settings.BarColumnEnabledTable[R])\n"
"		{\n"
"			X += ColumnsWidth[R];\n"
"			context.fillStyle = \'white\';\n"
"			context.textAlign = \'right\';\n"
"			var YText = Y+Height-FontAscent;\n"
"			context.fillText(Str, X-6, YText);\n"
"			var W = Math.max(80, context.measureText(Str).width + FontWidth * 2);\n"
"			ColumnsWidth[R] = Math.max(W, ColumnsWidth[R]);\n"
"\n"
"		}\n"
"		R++;\n"
"	\n"
"	}\n"
"	function DrawMeta(Value, Width, Dec, YText)\n"
"	{\n"
"		Value = FormatMeta(Value, Dec);\n"
"		X += (FontWidth*Width);\n"
"		context.textAlign = \'right\';\n"
"		context.fillText(Value, X-FontWidth, YText);\n"
"		context.textAlign = \'left\';\n"
"	}\n"
"\n"
"	function DrawTimerRow(idx, showgroup)\n"
"	{\n"
"		R = 0;\n"
"		var Timer = TimerArray[idx];\n"
"		var key = Timer.id;\n"
"		var FD = TimerMap[key];\n"
"		var AggregateIndex = Settings.AggregateFrames <= 0 ? AggregateHistorySize-1 : AggregateHistorySize-2; //fix med \n"
"	\n"
"\n"
"		var Average = FD.TimeAvg[AggregateIndex];\n"
"		var Max = FD.TimeMax[AggregateIndex];\n"
"		var Min = FD.TimeMin[AggregateIndex];\n"
"		var ExclusiveMax = FD.TimeExclMax[AggregateIndex];\n"
"		var ExclusiveAverage = FD.TimeExclAvg[AggregateIndex];\n"
"		var Total = FD.TimeTotal[AggregateIndex];\n"
"		var CallCount = FD.CallCount[AggregateIndex];\n"
"		var CallAverage = CallCount > 0 ? (Total / CallCount) : 0;	\n"
"		var Spike = (Average == 0 || Max == 0) ? 0 : (100*Max/Average);	\n"
"		var YText = Y+Height-FontAscent;\n"
"		X = NameWidth + XBase;\n"
"\n"
"		nColorIndex = 1-nColorIndex;\n"
"		bMouseIn = LocalMouseY >= Y && LocalMouseY < Y + BoxHeight;\n"
"		context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
"		context.fillRect(0, Y, Width, FontHeight+2);\n"
"\n"
"		DrawTimer(Average, Timer.color);\n"
"		DrawTimer(Max,Timer.color);\n"
"		DrawTimer(Total,Timer.color);\n"
"		DrawTimer(Min,Timer.color);\n"
"		DrawCount(Spike.toFixed(2) + \'%\');\n"
"		DrawTimer(CallAverage,Timer.color);\n"
"		DrawCount(\'\' + CallCount);\n"
"		DrawTimer(ExclusiveAverage,Timer.color);\n"
"		DrawTimer(ExclusiveMax,Timer.color);\n"
"\n"
"\n"
"\n"
"\n"
"		context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
"		context.fillRect(0, Y, NameWidth, Height);\n"
"		context.textAlign = \'right\';\n"
"		context.fillStyle = Timer.color;\n"
"		context.fillText(Timer.name, NameWidth - 5, YText);\n"
"		context.textAlign = \'left\';\n"
"		context.fillStyle = \'white\';\n"
"		var ParentName = TimerArray[Timer.parent].name;\n"
"		context.fillText(ParentName, 1, YText);\n"
"	}\n"
"	function FilterMatch(FilterArray, value)\n"
"	{\n"
"		if(!FilterArray)\n"
"			return true;\n"
"		for(var i = 0; i < FilterArray.length; ++i)\n"
"		{\n"
"			var res = value.search(FilterArray[i]);\n"
"			if(res<0)\n"
"				return false;\n"
"		}\n"
"		return true;\n"
"	}\n"
"	var TimerMap = FrameData.TimerMap;\n"
"	if(!TimerMap)\n"
"	{\n"
"		return;\n"
"	}\n"
"\n"
"	var wfirst = 100;\n"
"	var OrderArray = new Array();\n"
"	var nTotalRows = 0;\n"
"	for(var key in TimerMap)\n"
"	{\n"
"		var idx = GetTimer(key);\n"
"		var T = TimerArray[idx];\n"
"		if(T.e)\n"
"		{\n"
"			OrderArray.push(idx);\n"
"			wfirst = wfirst < T.wtotal ? T.wtotal : wfirst;\n"
"			nTotalRows++;\n"
"		}\n"
"	}\n"
"	NameWidth = wfirst + 20;\n"
"\n"
"\n"
"	var nTotalRowPixels = nTotalRows * Height;\n"
"	var nFrameRows = nHeight - HistoryHeight - BoxHeight;\n"
"	if(nTotalRowPixels > nFrameRows)\n"
"	{\n"
"		if(nOffsetBarsY + nFrameRows > nTotalRowPixels)\n"
"		{\n"
"			nOffsetBarsY = nTotalRowPixels - nFrameRows;\n"
"		}\n"
"	}\n"
"	else\n"
"	{\n"
"		nOffsetBarsY = 0;\n"
"	}\n"
"	Y = Y - nOffsetBarsY;\n"
"	XBase = XBase - nOffsetBarsX;\n"
"\n"
"	if(Settings.SortColumn)\n"
"	{\n"
"		if(Settings.SortColumn<0)\n"
"		{\n"
"			var KeyFunc = null;\n"
"			switch(Settings.SortColumn)\n"
"			{\n"
"				case -2: KeyFunc = function (a) { return TimerArray[a].name; }; break;\n"
"				case -1: KeyFunc = function (a) { return TimerArray[TimerArray[a].parent].name; }; break;\n"
"			}\n"
"			var Flip = Settings.SortColumnOrderFlip == 1 ? -1 : 1;\n"
"			OrderArray.sort(function(a,b) { \n"
"				var s1 = KeyFunc(a);\n"
"				var s2 = KeyFunc(b);\n"
"				return Flip * s1.localeCompare(s2); \n"
"			});\n"
"		}\n"
"		else\n"
"		{\n"
"			var KeyFunc = null;\n"
"			switch(Settings.SortColumn)\n"
"			{\n"
"				case 1: KeyFunc = function (a) { return TimerArray[a].average; }; break;\n"
"				case 2: KeyFunc = function (a) { return TimerArray[a].max; }; break;\n"
"				case 3: KeyFunc = function (a) { return TimerArray[a].total; }; break;\n"
"				case 4: KeyFunc = function (a) { return TimerArray[a].min; }; break;\n"
"				case 5: KeyFunc = function (a) { return TimerArray[a].spike; }; break;\n"
"				case 6: KeyFunc = function (a) { return TimerArray[a].callaverage; }; break;\n"
"				case 7: KeyFunc = function (a) { return TimerArray[a].callcount; }; break;\n"
"				case 8: KeyFunc = function (a) { return TimerArray[a].exclaverage; }; break;\n"
"				case 9: KeyFunc = function (a) { return TimerArray[a].exclmax; }; break;\n"
"			}\n"
"			var Flip = Settings.SortColumnOrderFlip == 1 ? -1 : 1;\n"
"			OrderArray.sort(function(a,b) { return Flip * (KeyFunc(b) - KeyFunc(a)); } );\n"
"		}\n"
"	}\n"
"\n"
"	for(var i = 0; i < OrderArray.length; ++i)\n"
"	{\n"
"		var idx = OrderArray[i];\n"
"		var T = TimerArray[idx];\n"
"		DrawTimerRow(idx, 1);\n"
"		Y += Height;\n"
"	}\n"
"	var X = 0;\n"
"	context.fillStyle = nBackColorOffset;\n"
"	context.fillRect(0, 0, Width, Height);\n"
"	context.fillStyle = \'white\';\n"
"	SortColumnMouseOverNext = null;\n"
"	X = NameWidth + XBase;\n"
"	R = 0;\n"
"	DrawHeaderSplit(StrAverage);\n"
"	DrawHeaderSplit(StrMax);\n"
"	DrawHeaderSplit(StrTotal);\n"
"	DrawHeaderSplit(StrMin);\n"
"	DrawHeaderSplitSingle(StrSpike);\n"
"	DrawHeaderSplit(StrCallAverage);\n"
"	DrawHeaderSplitSingle(StrCount);\n"
"	DrawHeaderSplit(StrExclAverage);\n"
"	DrawHeaderSplit(StrExclMax);\n"
"	X = 0;\n"
"	context.fillStyle = nBackColorOffset;\n"
"	context.fillRect(0, 0, NameWidth, Height);\n"
"	context.fillStyle = \'white\';\n"
"\n"
"	DrawHeaderSplitLeftRight(StrGroup, StrTimer, NameWidth);\n"
"	ProfileLeave();\n"
"}\n"
"\n"
"function DrawGraphSplit(View, LocalMouseX, LocalMouseY, SubIndex)\n"
"{\n"
"	DrawGraph(View, LocalMouseX, LocalMouseY, SubIndex, 1);\n"
"}\n"
"function DrawGraphSingle(View, LocalMouseX, LocalMouseY, SubIndex)\n"
"{\n"
"	DrawGraph(View, LocalMouseX, LocalMouseY, SubIndex, 0);\n"
"}\n"
"\n"
"function DrawGraph(View, LocalMouseX, LocalMouseY, SubIndex, Split)\n"
"{\n"
"	var Timer";

const size_t g_MicroProfileHtmlLive_begin_0_size = sizeof(g_MicroProfileHtmlLive_begin_0);
const char g_MicroProfileHtmlLive_begin_1[] =
"Map = FrameData.TimerMap;\n"
"	if(!TimerMap)\n"
"		return;\n"
"\n"
"	ProfileEnter(\"DrawGraph\");\n"
"	var Canvas = View.Canvas[View.BackBuffer];\n"
"	var context = Canvas.getContext(\'2d\');\n"
"	context.clearRect(0, 0, View.w, View.h);\n"
"\n"
"	var h = View.h;\n"
"	var w = View.w;\n"
"	var fHeightScale = h / ReferenceGraph;\n"
"	var MouseDragging = 0;\n"
"	var fWidth = w / (FrameCount);\n"
"	var HighlightFrame = -1;\n"
"	var GraphKey = null;\n"
"	var GraphBest = 0;\n"
"	var MouseTime = ReferenceGraph * (1-(LocalMouseY / h));\n"
"\n"
"	if(LocalMouseX >= 0 && LocalMouseY >= 0 && LocalMouseX < w && LocalMouseY < h && SubMenuActive == -1)\n"
"	{\n"
"		var index = Math.floor(FrameCount * LocalMouseX / w);\n"
"		HighlightFrame = index;\n"
"		for(var key in TimerMap)\n"
"		{\n"
"			var idx = GetTimer(key);\n"
"			var T = TimerArray[idx];\n"
"			var TimerState = TimerMap[key];\n"
"			var Time = TimerState.Time;\n"
"			if(Time[index] >= MouseTime && (GraphBest == 0 || Time[index] <= GraphBest))\n"
"			{\n"
"				GraphKey = key;\n"
"				GraphBest = Time[index];\n"
"			}\n"
"		}\n"
"		ToolTipCallback = function(canvas, x, y)\n"
"		{\n"
"			if(Split)\n"
"			{\n"
"				var TimerMap = FrameData.TimerMap;\n"
"				var context = canvas.getContext(\'2d\');\n"
"				context.font = Font;\n"
"				var XPos = x - 20;\n"
"				for(var key in TimerMap)\n"
"				{\n"
"					var idx = GetTimer(key);\n"
"					var T = TimerArray[idx];\n"
"					var TimerState = TimerMap[key];\n"
"					var Time = TimerState.Time;\n"
"					if(TimerState.tooltipysoft)\n"
"					{\n"
"						var RATE = 0.05;\n"
"						if(Math.abs(TimerState.tooltipysoft - TimerState.tooltipy) > 6)\n"
"						{\n"
"							TimerState.tooltipysoft = TimerState.tooltipy * RATE + TimerState.tooltipysoft * (1-RATE);\n"
"						}\n"
"					}\n"
"					else\n"
"					{\n"
"						TimerState.tooltipysoft = TimerState.tooltipy;\n"
"					}\n"
"					var Y = TimerState.tooltipysoft;\n"
"					var str = \'\' + FormatTime(Time[index]) + \'ms\';\n"
"					var w = context.measureText(str, XPos, Y).width;\n"
"					var X = Math.max(0, XPos - w);\n"
"					context.fillStyle = \'black\';\n"
"					context.fillRect(X - 1, Y-1 , w+2, BoxHeight+2);\n"
"					context.fillStyle = \'white\';\n"
"					context.textAlign = \'right\';\n"
"					context.fillText(str, X + w, Y+BoxHeight-2);\n"
"\n"
"				}\n"
"				context.textAlign = \'left\';\n"
"			}\n"
"			else\n"
"			{\n"
"				var StringArray = [];\n"
"				var TimerMap = FrameData.TimerMap;\n"
"				for(var key in TimerMap)\n"
"				{\n"
"					var idx = GetTimer(key);\n"
"					var T = TimerArray[idx];\n"
"					var TimerState = TimerMap[key];\n"
"					var Time = TimerState.Time;\n"
"					StringArray.push(\'\' + T.name);\n"
"					StringArray.push(\'\' + FormatTime(Time[index]) + \'ms\') ;\n"
"				}\n"
"				return StringArray;	\n"
"			}\n"
"		}\n"
"\n"
"	}\n"
"	if(GraphKey&&0)\n"
"	{\n"
"		//solid graph\n"
"		var idx = GetTimer(GraphKey);\n"
"		var T = TimerArray[idx];\n"
"		var TimerState = TimerMap[GraphKey];\n"
"		var Time = TimerState.Time;\n"
"		var color = TimerArray[idx].color;\n"
"		var X = w - Time.length*fWidth;\n"
"		var Y = h;\n"
"		context.globalAlpha = 0.1;\n"
"		context.strokeStyle = color;\n"
"		context.fillStyle = color;\n"
"		context.beginPath();\n"
"		context.moveTo(X,Y);\n"
"		for(var i = 0; i < Time.length; ++i)\n"
"		{\n"
"			Y = h - Time[i] * fHeightScale;\n"
"			context.lineTo(X, Y);\n"
"			X += fWidth;\n"
"		}\n"
"		context.lineTo(X, h);\n"
"		context.closePath();\n"
"		context.fill();\n"
"		context.globalAlpha = 1;\n"
"		context.stroke();\n"
"	}\n"
"	if(Split)\n"
"	{\n"
"		var NumGraphs = 0;\n"
"		for(var key in TimerMap)\n"
"		{\n"
"			NumGraphs++;\n"
"		}\n"
"		if(NumGraphs)\n"
"		{\n"
"			var hstart = 0;\n"
"			var gh = h / NumGraphs;\n"
"			var Keys = [];\n"
"			var cidx = 1;\n"
"			for(var key in TimerMap)\n"
"			{\n"
"				var idx = GetTimer(key);\n"
"				var TimerState = TimerMap[key];\n"
"				var Reference = Settings.AutomaticReference ? TimerState.historymaxsoft : ReferenceGraph;\n"
"				var fHeightScale2 = gh / Reference;\n"
"\n"
"				var Time = TimerState.Time;\n"
"				var color = TimerArray[idx].color;\n"
"				var X = w - Time.length*fWidth;\n"
"				var Y = hstart + gh;\n"
"				var YStart = Y;\n"
"				context.globalAlpha = 1;\n"
"				context.fillStyle = nBackColorsDark[cidx];\n"
"				cidx = 1-cidx;\n"
"				context.fillRect(0, hstart, w, gh);\n"
"				context.strokeStyle = color;\n"
"				context.fillStyle = color;\n"
"				context.beginPath();\n"
"				context.moveTo(X,Y);\n"
"				for(var i = 0; i < Time.length; ++i)\n"
"				{\n"
"					Y = Math.max(YStart - Time[i] * fHeightScale2, hstart);\n"
"					context.lineTo(X, Y);\n"
"					X += fWidth;\n"
"				}\n"
"				context.stroke();\n"
"				if(Settings.FancyGraph)\n"
"				{\n"
"					context.lineTo(X, YStart);\n"
"					context.globalAlpha = 0.05;\n"
"					context.fill();\n"
"					context.globalAlpha = 1;\n"
"				}\n"
"				context.fillStyle = \'wheat\';\n"
"				context.textAlign=\'right\';\n"
"				context.fillText(FormatTime(Reference) + \'ms\', nWidth, hstart + FontHeight);\n"
"				context.textAlign=\'left\';\n"
"				context.fillText(TimerArray[idx].name, 0, hstart + FontHeight);\n"
"\n"
"				if(HighlightFrame >= 0)\n"
"				{\n"
"					var X = w - Time.length * fWidth + fWidth * HighlightFrame;\n"
"					var Y = YStart - Math.min(Time[HighlightFrame], Reference) * fHeightScale2;\n"
"					context.strokeStyle = color;\n"
"					context.beginPath();\n"
"					var CrossX = X;\n"
"					var CrossY = Y;\n"
"					context.moveTo(CrossX-2, CrossY-2);\n"
"					context.lineTo(CrossX+2, CrossY+2);\n"
"					context.moveTo(CrossX+2, CrossY-2);\n"
"					context.lineTo(CrossX-2, CrossY+2);\n"
"					context.stroke();\n"
"					TimerState.tooltipy = Math.min(YStart - BoxHeight, Y) + View.y;\n"
"				}\n"
"				hstart += gh;\n"
"			}\n"
"		}\n"
"	}\n"
"	else\n"
"	{\n"
"		var Keys = [];\n"
"		for(var key in TimerMap)\n"
"		{\n"
"			var idx = GetTimer(key);\n"
"			var TimerState = TimerMap[key];\n"
"			var Time = TimerState.Time;\n"
"			var color = TimerArray[idx].color;\n"
"			var X = w - Time.length*fWidth;\n"
"			var Y = h;\n"
"			context.strokeStyle = color;\n"
"			context.fillStyle = color;\n"
"\n"
"			context.beginPath();\n"
"			context.moveTo(X,Y);\n"
"			for(var i = 0; i < Time.length; ++i)\n"
"			{\n"
"				Y = h - Time[i] * fHeightScale;\n"
"				context.lineTo(X, Y);\n"
"				X += fWidth;\n"
"			}\n"
"			context.stroke();\n"
"			if(Settings.FancyGraph)\n"
"			{\n"
"				context.lineTo(X, h);\n"
"				context.globalAlpha = 0.05;\n"
"				context.fill();\n"
"				context.globalAlpha = 1;\n"
"			}\n"
"		}\n"
"		if(HighlightFrame >= 0)\n"
"		{\n"
"			for(var key in TimerMap)\n"
"			{\n"
"				var idx = GetTimer(key);\n"
"				var TimerState = TimerMap[key];\n"
"				var Time = TimerState.Time;\n"
"				var color = TimerArray[idx].color;\n"
"				var X = w - Time.length*fWidth + fWidth * HighlightFrame;\n"
"				var Y = h - Time[HighlightFrame] * fHeightScale;\n"
"				context.strokeStyle = color;\n"
"				context.beginPath();\n"
"				var CrossX = X;\n"
"				var CrossY = Y;\n"
"				context.moveTo(CrossX-2, CrossY-2);\n"
"				context.lineTo(CrossX+2, CrossY+2);\n"
"				context.moveTo(CrossX+2, CrossY-2);\n"
"				context.lineTo(CrossX-2, CrossY+2);\n"
"				context.stroke();\n"
"			}\n"
"		}\n"
"		context.fillStyle = \'wheat\';\n"
"		context.textAlign=\'right\';\n"
"		context.fillText(FormatTime(ReferenceGraph) + \'ms\', nWidth, FontHeight);\n"
"		context.textAlign=\'left\';\n"
"	}\n"
"\n"
"	ProfileLeave();\n"
"}\n"
"\n"
"function LerpColor(v)\n"
"{\n"
"	var R_0 = 0;\n"
"	var G_0 = 1;\n"
"	var B_0 = 0;\n"
"\n"
"	var R_1 = 1;\n"
"	var G_1 = 0.5;\n"
"	var B_1 = 0;\n"
"\n"
"	var R_2 = 1;\n"
"	var G_2 = 0;\n"
"	var B_3 = 0;\n"
"	var R;\n"
"	var G;\n"
"	if(v < 0.5)\n"
"	{\n"
"		v *= 2;\n"
"		var v0 = (1-v)\n"
"		R = R_0 * v0 + R_1 * v;\n"
"		G = G_0 * v0 + G_1 * v;\n"
"\n"
"	}\n"
"	else\n"
"	{\n"
"		v = (v-0.5) * 2;\n"
"		var v0 = (1-v)\n"
"		R = R_1 * v0 + R_2 * v;\n"
"		G = G_1 * v0 + G_2 * v;\n"
"	}\n"
"	R *= 255;\n"
"	G *= 255;\n"
"	return \"rgb(\" + R.toFixed(0) + \",\" + G.toFixed(0) + \",0)\";\n"
"\n"
"}\n"
"\n"
"function DrawRange(context, X, XEnd, Y, YEnd, ColorBack, ColorFront)\n"
"{\n"
"	if(X < XEnd)\n"
"	{\n"
"		var W = XEnd - X;\n"
"		var H = YEnd - Y;\n"
"		context.globalAlpha = 0.1;\n"
"		context.fillStyle = ColorBack;\n"
"		context.fillRect(X, Y, W, H);\n"
"		context.globalAlpha = 1;\n"
"		context.strokeStyle = ColorFront;\n"
"		context.beginPath();\n"
"		context.moveTo(X, 0);\n"
"		context.lineTo(X, H);\n"
"		context.moveTo(X+W, 0);\n"
"		context.lineTo(X+W, H);\n"
"		// context.closePath();\n"
"		context.stroke();\n"
"	}\n"
"}\n"
"\n"
"\n"
"function DrawHistory(View, LocalMouseX, LocalMouseY)\n"
"{\n"
"	ProfileEnter(\"DrawHistory\");\n"
"	var Canvas = View.Canvas[View.BackBuffer];\n"
"	var context = Canvas.getContext(\'2d\');\n"
"	context.clearRect(0, 0, View.w, View.h);\n"
"	if(!FrameData.Time)\n"
"		return;\n"
"	var fHeight = View.h;\n"
"	var fWidth = nWidth / FrameCount;\n"
"	var fHeightScale = fHeight / ReferenceHistory;\n"
"	var fX = 0;\n"
"	var FrameIndex = -1;\n"
"	var MouseDragging = 0;\n"
"	var GreenTime = (Settings.TargetTime * 0.9);\n"
"	var RedBegin = (Settings.TargetTime * 1.1);\n"
"	var LerpDist = 1.0 / (RedBegin - GreenTime);\n"
"	var id0 = -1;\n"
"	var id1 = -1;\n"
"	\n"
"	if(MouseDragActiveXEnd > MouseDragActiveXStart)\n"
"	{\n"
"		var idx0 = Math.ceil(FrameCount * MouseDragActiveXStart / nWidth);\n"
"		var idx1 = Math.floor(FrameCount * MouseDragActiveXEnd / nWidth);\n"
"		idx0 = Clamp(idx0, 0, FrameCount-1);\n"
"		idx1 = Clamp(idx1, 0, FrameCount-1);\n"
"		id0 = FrameData.Ids[idx0];\n"
"		id1 = FrameData.Ids[idx1];\n"
"	}\n"
"\n"
"\n"
"	var ToolTipFrame = -1;\n"
"	for(var i = 0; i < FrameCount; i++)\n"
"	{\n"
"		var fMs = FrameData.Time[i];\n"
"		var fPrc = (fMs - GreenTime) * LerpDist;\n"
"		fPrc = Clamp(fPrc, 0, 1);\n"
"		var color = LerpColor(fPrc);\n"
"		var fid = FrameData.Ids[i];\n"
"		if(fid >= id0 && fid <= id1)\n"
"		{\n"
"			color = \'cyan\';\n"
"		}else if(FrameData.Frozen[i])\n"
"		{\n"
"			color = \'purple\';\n"
"		}\n"
"\n"
"\n"
"		var fH = fHeightScale * fMs;\n"
"		var bMouse = LocalMouseX > fX && LocalMouseX < fX + fWidth+1 && MouseY <= HistoryHeight;\n"
"		if(bMouse && !MouseDragging)\n"
"		{\n"
"			context.fillStyle = FRAME_HISTORY_COLOR_GPU;\n"
"			ToolTipFrame = i;\n"
"		}\n"
"		else\n"
"		{\n"
"			context.fillStyle = color;\n"
"		}\n"
"		context.fillRect(fX, fHeight - fH, fWidth-1, fH);\n"
"		fX += fWidth;\n"
"	}\n"
"\n"
"\n"
"	DrawRange(context, MouseDragActiveXStart, MouseDragActiveXEnd, 0, HistoryHeight, \'#59d0ff\', \'#00ddff\');\n"
"\n"
"\n"
"	var fH = fHeight - fHeightScale * Settings.TargetTime;\n"
"	context.fillStyle = \'wheat\';\n"
"	context.strokeStyle = \'wheat\';\n"
"	context.beginPath();\n"
"	context.moveTo(0, fH);\n"
"	context.lineTo(nWidth, fH);\n"
"	// context.closePath();\n"
"	context.stroke();\n"
"	var YText;\n"
"	if(fH > HistoryHeight * 0.25)\n"
"	{\n"
"		YText = fH - FontAscent;\n"
"	}\n"
"	else\n"
"	{\n"
"		YText = fH + FontHeight;\n"
"	}\n"
"\n"
"	context.fillText(Settings.TargetTime + \'ms\', 3, YText);\n"
"	context.textAlign=\'right\';\n"
"	context.fillText(FormatTime(ReferenceHistory) + \'ms\', nWidth, FontHeight);\n"
"	context.textAlign=\'left\';\n"
"\n"
"\n"
"\n"
"	if(ToolTipFrame >= 0)\n"
"	{\n"
"		var fMs = FrameData.Time[ToolTipFrame];\n"
"		var Frozen = FrameData.Frozen[ToolTipFrame];\n"
"		ToolTipCallback = function()\n"
"		{\n"
"			var StringArray = [];\n"
"			StringArray.push(\"Frame\");\n"
"			StringArray.push(\"\" + ToolTipFrame);\n"
"			StringArray.push(\"Time\");\n"
"			StringArray.push(\"\" + fMs.toFixed(3));\n"
"			if(Frozen)\n"
"			{\n"
"				StringArray.push(\"Frozen & Unreliable\");\n"
"				StringArray.push(\"\");\n"
"			}\n"
"			return StringArray;\n"
"		}\n"
"	}\n"
"\n"
"\n"
"	ProfileLeave();\n"
"\n"
"}\n"
"function MouseInRect(Rect)\n"
"{\n"
"	return MouseInside(Rect.x, Rect.y, Rect.w, Rect.h);\n"
"}\n"
"function MouseInside(X, Y, W, H)\n"
"{\n"
"	return MouseX >= X && MouseX <= X + W && MouseY >= Y && MouseY <= Y + H;\n"
"}\n"
"\n"
"var MessageText = \"\";\n"
"var MessageTimeout = -1;\n"
"var MessageTimeoutLast = new Date();\n"
"function SetMessage(text, TimeOut)\n"
"{\n"
"	if(TimeOut)\n"
"	{\n"
"		MessageTimeout = TimeOut;\n"
"	}\n"
"	else\n"
"	{\n"
"		MessageTimeout = -1;\n"
"	}\n"
"	MessageText = text;\n"
"}\n"
"function ClearMessage(Message)\n"
"{\n"
"	if(Message == MessageText)\n"
"	{\n"
"		MessageText = \"\";\n"
"		MessageTimeout = -1;\n"
"	}\n"
"}\n"
"\n"
"function DrawMessage()\n"
"{\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"	var Now = new Date();\n"
"	var Delta = Now - MessageTimeoutLast;\n"
"	if(MessageTimeout>0)\n"
"	{\n"
"		MessageTimeout -= Delta;\n"
"		if(MessageTimeout<= 0)\n"
"		{\n"
"			MessageText = \"\";\n"
"			MessageTimeout = -1;\n"
"		}\n"
"\n"
"	}\n"
"	MessageTimeoutLast = Now;\n"
"\n"
"	var Text = MessageText;\n"
"	var X = nWidth / 2;\n"
"\n"
"	var Y = nHeight / 2;\n"
"	context.font = FontFlash;\n"
"	context.textAlign = \'center\';\n"
"	context.fillStyle = \'red\';\n"
"\n"
"	function MSG(a)\n"
"	{\n"
"		context.fillText(a, X, Y);\n"
"		Y -= 60;\n"
"	}\n"
"	if(!HelpFade)\n"
"		HelpFade = new Date()\n"
"	var HelpFadeTime = new Date() - HelpFade;\n"
"	if(HelpFadeTime < 2000)\n"
"	{\n"
"		var Alpha = 1 - (HelpFadeTime/2000);\n"
"		context.globalAlpha = Alpha;\n"
"		context.fillText(\"Press \'h\' for help\", X, 200);\n"
"		context.globalAlpha = 1;\n"
"	}\n"
"\n"
"	if(Text != \"\")\n"
"	{\n"
"		MSG(Text);\n"
"	}\n"
"	if(IsFrozen)\n"
"	{\n"
"		MSG(\"FROZEN[space]\");\n"
"	}\n"
"\n"
"	PresetPending++; //hack: wait 20 frames before showing enable messages to prevent it from showing when loading settings. [[[test]]]\n"
"	if(WSIsOpen && PresetPending > 20)\n"
"	{\n"
"		if(GroupsEnabled == 0)\n"
"		{\n"
"			MSG(\"Paused: Enable groups in \'Control\' menu to unpause\");\n"
"		}\n"
"		if(TimersEnabled == 0 && Settings.ViewActive != VIEW_COUNTERS)\n"
"		{\n"
"			MSG(\"Select Timers in \'Timers\' menu\");\n"
"		}\n"
"	}\n"
"	context.textAlign = \'left\';\n"
"	context.font = Font;\n"
"}\n"
"function DrawCaptureButton(context)\n"
"{\n"
"	if(!ShowMenu())\n"
"	{\n"
"		return;\n"
"	}\n"
"\n"
"	var CaptureRange = MouseDragActiveXStart < MouseDragActiveXEnd ? \"Selection\" : (\"\"+Settings.CaptureFrames);\n"
"	var CaptureText = \"Capture[\" + CaptureRange + \"]\";\n"
"	var w = 10 + context.measureText(CaptureText).width;\n"
"	var X = nWidth / 2 - w / 2;\n"
"	var XCenter = nWidth / 2;\n"
"	var Y = nHeight - 30;\n"
"	var bMouseInCapture = MouseInside(X, Y, w, 4 + FontHeight);\n"
"	context.textAlign = \'center\';\n"
"	context.fillStyle = bMouseInCapture ? nBackColors[1] : \'black\';\n"
"	context.fillRect(X, Y, w, 4 + FontHeight);\n"
"	context.fillStyle = \'#ffffff\';\n"
"	context.fillText(CaptureText, XCenter, Y + FontHeight);\n"
"\n"
"\n"
"	X += w + 2;\n"
"	var MenuText = \"^\";\n"
"	var w2 = 10 + context.measureText(MenuText).width;\n"
"	var bMouseInCaptureMenu = MouseInside(X, Y, w2, 4 + FontHeight);\n"
"	context.fillStyle = bMouseInCaptureMenu ? nBackColors[1] : \'black\';\n"
"	context.fillRect(X, Y, w2, 4 + FontHeight);\n"
"\n"
"	context.fillStyle = \'#ffffff\';\n"
"	context.fillText(MenuText, X + w2*0.5, Y + FontHeight);\n"
"	context.textAlign = \'left\';\n"
"	if(MouseReleased)\n"
"	{\n"
"		if(bMouseInCapture)\n"
"		{\n"
"			Capture();\n"
"		}\n"
"	}\n"
"	else\n"
"	{\n"
"		if(bMouseInCaptureMenu)\n"
"		{\n"
"			CaptureButtonX = X + w2;\n"
"			CaptureButtonY = Y;\n"
"			EnableMenu(SubMenuCapture);\n"
"		}	\n"
"	}\n"
"\n"
"}\n"
"function UpdateX7Views()\n"
"{\n"
"	if(Settings.ViewActive == VIEW_BAR_SINGLE || Settings.ViewActive == VIEW_BAR_ALL)\n"
"	{\n"
"		var NumSubViews = 0;\n"
"		var BarColumnEnabled = GetBarColumnEnabled();\n"
"		X7BarFirstView = -1;\n"
"		X7BarLastView = -1;\n"
"		var ViewMask = 0;\n"
"		for(var i = 0; i < BarColumnEnabled.length; ++i)\n"
"		{\n"
"			if(BarColumnEnabled[i])\n"
"			{\n"
"				if(X7BarFirstView == -1)\n"
"					X7BarFirstView = i;\n"
"				X7BarColumnRemap[NumSubViews++] = i;\n"
"				ViewMask = ViewMask | (1 << i);\n"
"				X7BarLastView = i;\n"
"			}\n"
"		}\n"
"		if(ViewMask != X7BarColumnMask)\n"
"		{\n"
"			console.log(\"resizing views\");\n"
"			var w = NumSubViews ? nWidth / NumSubViews : 1;\n"
"			for(var i = 0; i < X7Views.length; ++i)\n"
"			{\n"
"				X7Views[i].visible = i < NumSubViews;\n"
"				if(i < NumSubViews)\n"
"				{\n"
"					var HistoryH = Settings.ViewCompressed ? 0 : HistoryHeight;\n"
"					ResizeView(X7Views[i], w*i, HistoryH, w, nHeight - HistoryH);\n"
"				}\n"
"			}\n"
"			X7BarColumnMask = ViewMask;\n"
"		}\n"
"		X7LegendView.visible = true;\n"
"		ReferenceBarAutomatic = 0;\n"
"	}\n"
"}\n"
"function DrawViews()\n"
"{\n"
"	Plotf(\"DrawViews\");\n"
"	UpdateX7Views();\n"
"	ProfileEnter(\"UpdateViews\");\n"
"	ViewIndex = 0;\n"
"	for(var i = 0; i < Views.length; ++i)\n"
"	{\n"
"		var View = Views[i];\n"
"		if(View.visible)\n"
"		{\n"
"			var LocalMouseX = MouseX - View.x;\n"
"			var LocalMouseY = MouseY - View.y;\n"
"			View.DisplayFunc(View, LocalMouseX, LocalMouseY, View.index);\n"
"			var Canvas = View.Canvas[View.BackBuffer];\n"
"			var Context = Canvas.getContext(\'2d\');\n"
"			ViewIndex++;\n"
"		}\n"
"	}\n"
"	ProfileLeave();\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"	context.clearRect(0, 0, nWidth, nHeight);\n"
"	ProfileEnter(\"BlitViews\");\n"
"	// var DPR = window.devicePixelRatio;\n"
"	for(var i = 0; i < Views.length; ++i)\n"
"	{\n"
"		var View = Views[i];\n"
"		if(View.visible)\n"
"		{\n"
"			context.drawImage(View.Canvas[View.BackBuffer], Math.floor(View.x), Math.floor(View.y), View.w, View.h);\n"
"		}\n"
"	}\n"
"\n"
"	DrawCaptureButton(context);\n"
"\n"
"	ProfileLeave();\n"
"\n"
"}\n"
"var SubMenuGroup = 0;\n"
"var SubMenuTimers = 1;\n"
"var SubMenuSettings = 2;\n"
"var SubMenuViews = 3;\n"
"var SubMenuPresets = 4;\n"
"var SubMenuColumns = 5;\n"
"var SubMenuCapture = 6;\n"
"var SubMenuActive = -1;\n"
"var SubMenuTimeoutBase = 0.7;\n"
"var SubMenuMouseX = 0;\n"
"var SubMenuMouseY = 0;\n"
"var SubMenuTimeout = new Date();\n"
"var MenuItems = [];\n"
"var FilterInputTimersValue = \'\';\n"
"var FilterInputGroupsValue = \'\';\n"
"\n"
"function MakeMenuItem(name, f)\n"
"{\n"
"	var Item = {};\n"
"	Item.name = name\n"
"	Item.f = f;\n"
"	Item.w = name.length;\n"
"	Item.x = 0;\n"
"	Item.y = 0;\n"
"	return Item;\n"
"}\n"
"function EnableMenu(m)\n"
"{\n"
"	if(m != SubMenuActive)\n"
"	{\n"
"		if(SubMenuActive == SubMenuTimers)\n"
"		{\n"
"			FilterInputTimersValue = FilterInput.value;\n"
"		}\n"
"		else if(SubMenuActive == SubMenuGroup)\n"
"		{\n"
"			FilterInputGroupsValue = FilterInput.value;\n"
"		}\n"
"		SubMenuActive = m;\n"
"		SubMenuTimeout = new Date();\n"
"\n"
"		if(SubMenuActive == SubMenuTimers)\n"
"		{\n"
"			FilterInput.value = FilterInputTimersValue;\n"
"		}\n"
"		else if(SubMenuActive == SubMenuGroup)\n"
"		{\n"
"			FilterInput.value = FilterInputGroupsValue;\n"
"		}\n"
"		FilterInputValueLast = FilterInput.value;\n"
"	}\n"
"	if(m == -1)\n"
"	{\n"
"		SubMenuTimeout = 0;\n"
"	}\n"
"\n"
"	if(SubMenuActive == SubMenuTimers || SubMenuActive == SubMenuGroup)\n"
"	{\n"
"		FilterInputDiv.style[\'display\'] = \'inline\';\n"
"		FilterInput.focus();\n"
"	}\n"
"	else\n"
"	{\n"
"		FilterInputDiv.style[\'display\'] = \'none\';\n"
"	}\n"
"}\n"
"\n"
"function Clamp(v, low, high)\n"
"{\n"
"	return v < low ? low : (v > high ? high : v);\n"
"}\n"
"function Capture()\n"
"{\n"
"	var ext = \'\' + Settings.CaptureFrames;\n"
"	if(MouseDragActiveXEnd > MouseDragActiveXStart)\n"
"	{\n"
"		var idx0 = Math.ceil(FrameCount * MouseDragActiveXStart / nWidth);\n"
"		var idx1 = Math.floor(FrameCount * MouseDragActiveXEnd / nWidth);\n"
"		idx0 = Clamp(idx0, 0, FrameCount-1);\n"
"		idx1 = Clamp(idx1, 0, FrameCount-1);\n"
"		var id0 = FrameData.Ids[idx0];\n"
"		var id1 = FrameData.Ids[idx1];\n"
"		ext = \'r/\'+id0+\'/\'+id1;\n"
"	}\n"
"	var url = \'http://\' + WSHost + \':\' + WSPort + \'/\' + ext;\n"
"	window.open(url);\n"
"}\n"
"function InitMenu()\n"
"{\n"
"	MenuItems = [];\n"
"	MenuItems.push(MakeMenuItem(\"Control\", function(){EnableMenu(SubMenuGroup); } ));\n"
"	MenuItems.push(MakeMenuItem(\"Timers\", function(){EnableMenu(SubMenuTimers); } ));\n"
"	MenuItems.push(MakeMenuItem(\"Settings\", function(){ EnableMenu(SubMenuSettings); } ));\n"
"	MenuItems.push(MakeMenuItem(\"Views\", function(){ EnableMenu(SubMenuViews); } ));\n"
"	MenuItems.push(MakeMenuItem(\"Presets\", function(){ EnableMenu(SubMenuPresets); } ));\n"
"	MenuItems.push(MakeMenuItem(\"Columns\", function(){ EnableMenu(SubMenuColumns); } ));\n"
"}\n"
"function DrawTopMenu()\n"
"{\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"	var X = 2;\n"
"	var Y = 0;\n"
"	var MouseInY = MouseY < BoxHeight;\n"
"	for(var i = 0; i < MenuItems.length; ++i)\n"
"	{\n"
"		if(i == SubMenuColumns)\n"
"		{\n"
"			if(Settings.ViewActive == VIEW_GRAPH_SPLIT || \n"
"				Settings.ViewActive == VIEW_GRAPH || \n"
"				Settings.ViewActive == VIEW_COUNTERS)\n"
"			{\n"
"				continue;\n"
"			}\n"
"		}\n"
"		var Item = MenuItems[i];\n"
"		var w = context.measureText(Item.name).width + 4;\n"
"		var MouseIn = MouseInY && MouseX >= X && MouseX < X + w;\n"
"		var color = MouseIn ? nBackColors[1] : \"black\";\n"
"		Item.x = X;\n"
"		Item.y = Y + BoxHeight;\n"
"		if(MouseIn)\n"
"		{\n"
"			context.fillStyle = \'white\';\n"
"			context.fillRect(X-2, Y, w+4, BoxHeight);\n"
"			// Enable\n"
"			EnableMenu(i);\n"
"		}\n"
"		context.fillStyle = color;\n"
"		context.fillRect(X, Y, w, BoxHeight);\n"
"		context.fillStyle = \"white\";\n"
"		context.fillText(Item.name, X+2, Y+BoxHeight-FontAscent);\n"
"		if(MouseIn && MouseReleased)\n"
"		{\n"
"			Item.f();\n"
"		}\n"
"		X += w + 6;\n"
"	}\n"
"}\n"
"\n"
"function AggregateMenuSize()\n"
"{\n"
"	var w = 250 + 5 + FontWidth;\n"
"	return WindowRect(nWidth / 2 - w / 2,HistoryHeight + 50, w, nHeight);\n"
"}\n"
"\n"
"function TimerMenuSize()\n"
"{\n"
"	return MenuSize(WidthArray[TYPE_TIMER] + WidthArray[TYPE_GROUP] + 5 + FontWidth);\n"
"}\n"
"function GroupMenuSize()\n"
"{\n"
"	return MenuSize(WidthTree);\n"
"}\n"
"\n"
"function MenuSize(w)\n"
"{\n"
"	return WindowRect(nWidth / 2 - w / 2, HistoryHeight + 50,w, nHeight);\n"
"}\n"
"\n"
"function CreateFilter(Filter)\n"
"{\n"
"	if(!Filter || Filter.length == 0)\n"
"	{\n"
"		return null;\n"
"	}\n"
"	Filter = Filter.split(\' \');\n"
"	\n"
"	var regexp = \"\";\n"
"	for(var i = 0; i < Filter.length; ++i)\n"
"	{\n"
"		regexp = regexp + \".*\" + Filter[i];\n"
"	}\n"
"	Filter = new Array();\n"
"	regexp = regexp + \".*\";\n"
"	Filter.push(new RegExp(regexp, \"i\"));\n"
"	return Filter;\n"
"}\n"
"\n"
"function FilterMatch(FilterArray, value)\n"
"{\n"
"	if(!FilterArray)\n"
"		return true;\n"
"	for(var i = 0; i < FilterArray.length; ++i)\n"
"	{\n"
"		var res = value.search(FilterArray[i]);\n"
"		if(res<0)\n"
"			return false;\n"
"	}\n"
"	return true;\n"
"}\n"
"\n"
"function AddPreset(Name)\n"
"{\n"
"	var O = {};\n"
"	O.p = [Name];\n"
"	O.r = [];\n"
"	AddPresets(O);\n"
"}\n"
"function AddPresets(Obj)\n"
"{\n"
"	var Names = Obj.p;\n"
"	var ReadOnlyNames = Obj.r;\n"
"	for(var i = 0; i < Names.length; ++i)\n"
"	{\n"
"		if(Presets.indexOf(Names[i]) == -1)\n"
"		{\n"
"			Presets.push(Names[i]);\n"
"		}\n"
"	}\n"
"	for(var i = 0; i < ReadOnlyNames.length; ++i)\n"
"	{\n"
"		if(ReadOnlyPresets.indexOf(ReadOnlyNames[i]) == -1)\n"
"		{\n"
"			ReadOnlyPresets.push(ReadOnlyNames[i]);\n"
"		}\n"
"	}\n"
"}\n"
"function GetFullName(T)\n"
"{\n"
"	var parent = T.parent;\n"
"	var ParentName = \"unknown\";\n"
"	var Name = T.name;\n"
"	if(parent && parent < TimerArray.length)\n"
"	{\n"
"		ParentName = TimerArray[parent].name;\n"
"	}\n"
"	return ParentName + \"/\" + Name;\n"
"}\n"
"\n"
"function EnableByName(name, type)\n"
"{\n"
"	for(var i = 0;i < TimerArray.length; ++i)\n"
"	{\n"
"		var t = TimerArray[i];\n"
"		if(t.idtype == type && GetFullName(t) == name)\n"
"		{\n"
"			WSSendMessage(\"c\" + t.id);\n"
"		}\n"
"	}\n"
"}\n"
"\n"
"\n"
"function OnLoadPreset(NewSettings, Apply, RO)\n"
"{\n"
"	if(Apply)\n"
"	{\n"
"		WSSendMessage(\"d\");\n"
"		PresetPending = 0;\n"
"	}\n"
"	ActivePreset = NewSettings.PresetName;\n"
"	ActivePresetRO = RO ? 1 : 0;\n"
"	console.log(\'loading preset \' + ActivePresetRO);\n"
"	var EnableCount = 0;\n"
"	for(var idx in NewSettings)\n"
"	{\n"
"		if(idx == \'Timers\')\n"
"		{\n"
"			if(Apply)\n"
"			{\n"
"				var Timers = NewSettings[idx];\n"
"				for(var i = 0; i < Timers.length; ++i)\n"
"				{\n"
"					var FullName = Timers[i];\n"
"					EnableCount++;\n"
"					EnableByName(FullName, TYPE_TIMER);\n"
"				}\n"
"			}\n"
"		}\n"
"		else if(idx == \'Groups\')\n"
"		{\n"
"			if(Apply)\n"
"			{\n"
"				var Groups = NewSettings[idx];\n"
"				for(var i = 0; i < Groups.length; ++i)\n"
"				{\n"
"					var FullName = Groups[i];\n"
"					EnableByName(FullName, TYPE_GROUP);\n"
"				}\n"
"			}\n"
"		}\n"
"		else\n"
"		{\n"
"			Settings[idx] = NewSettings[idx];\n"
"		}\n"
"	}\n"
"	if(Settings.ViewActive >= 0)\n"
"	{\n"
"		ResizeCanvas();\n"
"	}\n"
"}\n"
"\n"
"function LoadPreset(Name, RO)\n"
"{\n"
"	Name = Name.replace(\",\",\"_\");\n"
"	WSSendMessage((RO?\"m\":\"l\")+Name);\n"
"}\n"
"\n"
"function SavePreset(Name)\n"
"{\n"
"	Name = Name.replace(\",\",\"_\");\n"
"	AddPreset(Name);\n"
"	var Timers = [];\n"
"	var Groups = [];\n"
"	for(var i = 0; i < TimerArray.length; ++i)\n"
"	{\n"
"		var t = TimerArray[i];\n"
"		var idtype = TimerArray[i].idtype;\n"
"		if(t.e)\n"
"		{\n"
"			if(idtype == TYPE_TIMER)\n"
"			{\n"
"				Timers.push(GetFullName(t));\n"
"			}\n"
"			else if(idtype == TYPE_GROUP)\n"
"			{\n"
"				Groups.push(GetFullName(t));\n"
"			}\n"
"		}\n"
"	}\n"
"\n"
"	Settings.Timers = Timers;\n"
"	Settings.Groups = Groups;\n"
"	Settings.PresetName = Name;\n"
"	var JsonSettings = JSON.stringify(Settings);\n"
"	console.log(\'settings stored \' + JsonSettings);\n"
"	WSSendMessage(\"s\"+Name+\",\"+JsonSettings);\n"
"	ActivePreset = Name;\n"
"	ActivePresetRO = 0;\n"
"}\n"
"function DrawMenuPresets()\n"
"{\n"
"	var Selection = null;\n"
"	var SizeInfo = {};\n"
"	SizeInfo.h = BoxHeight * (Presets.length * 2 + 1);\n"
"	if(ReadOnlyPresets.length)\n"
"	{\n"
"		SizeInfo.h += BoxHeight * (Presets.length + 1);\n"
"	}\n"
"	var x = MenuItems[SubMenuPresets].x;\n"
"	var y = MenuItems[SubMenuPresets].y;\n"
"\n"
"	var Width = 50;\n"
"	var WLeft = MeasureArray(0, [\"Save \", \"Load \", \"Save As ..\", \"Builtin\" ]);\n"
"	Width = MeasureArray(Width, Presets);\n"
"	var Width = 35 + Width + WLeft;\n"
"	SizeInfo.w = Width;\n"
"	SizeInfo.x = x;\n"
"	SizeInfo.y = y;\n"
"	\n"
"	var M = CreateMenuState(SizeInfo);\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"	context.fillRect(M.x, M.y, Width, SizeInfo.h);\n"
"\n"
"\n"
"	for(var i = 0; i < Presets.length; ++i)\n"
"	{\n"
"		var Active = (ActivePresetRO == 0 && ActivePreset == Presets[i]) ? 1 : 0;\n"
"		if(DrawMenuElement(M, Active, \"Load\", Presets[i], \'white\', 0))\n"
"		{\n"
"			LoadPreset(Presets[i]);\n"
"		}\n"
"	}\n"
"	DrawMenuElement(M, 0, \"---\", \"\", \'white\', 0);\n"
"	if(DrawMenuElement(M, 0, \"Save As..\", \"\", \'white\', 0))\n"
"	{\n"
"		var str = ShowPrompt(\'Enter Preset Name\', \'\');\n"
"		if(str.length>1)\n"
"		{\n"
"			SavePreset(str);\n"
"		}\n"
"\n"
"	}\n"
"\n"
"	for(var i = 0; i < Presets.length; ++i)\n"
"	{\n"
"		var Active = (ActivePresetRO == 0 && ActivePreset == Presets[i]) ? 1 : 0;\n"
"		if(DrawMenuElement(M, Active, \"Save\", Presets[i], \'white\', 0))\n"
"		{\n"
"			SavePreset(Presets[i]);\n"
"		}\n"
"	}\n"
"	if(ReadOnlyPresets && ReadOnlyPresets.length > 0)\n"
"	{\n"
"		DrawMenuElement(M, 0, \"---\", \"\", \'white\', 0);\n"
"		for(var i = 0; i < ReadOnlyPresets.length; ++i)\n"
"		{\n"
"			var Active = (ActivePresetRO && ActivePreset == ReadOnlyPresets[i]) ? 1 : 0;\n"
"			if(DrawMenuElement(M, Active, \"Builtin\", ReadOnlyPresets[i], \'white\', 0))\n"
"			{\n"
"				LoadPreset(ReadOnlyPresets[i], 1);\n"
"			}\n"
"		}\n"
"	}\n"
"	SizeInfo.h = M.y - SizeInfo.y;\n"
"	return SizeInfo;\n"
"}\n"
"\n"
"function DrawMenuColumns()\n"
"{\n"
"	var Selection = null;\n"
"	var SizeInfo = {};\n"
"	var BarColumnNames = GetBarColumnNames();\n"
"	var BarColumnEnabled = GetBarColumnEnabled();\n"
"	SizeInfo.h = BoxHeight * (BarColumnNames.length);\n"
"	var x = MenuItems[SubMenuColumns].x;\n"
"	var y = MenuItems[SubMenuColumns].y;\n"
"\n"
"	var Width = MeasureArray(0, BarColumnNames);\n"
"	SizeInfo.w = Width;\n"
"	SizeInfo.x = x;\n"
"	SizeInfo.y = y;\n"
"	\n"
"	var M = CreateMenuState(SizeInfo);\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"	context.fillRect(M.x, M.y, Width, SizeInfo.h);\n"
"\n"
"\n"
"	for(var i = 0; i < BarColumnNames.length; ++i)\n"
"	{\n"
"		var Active = ActivePreset == Presets[i] ? 1 : 0;\n"
"		if(DrawMenuElement(M, BarColumnEnabled[i], BarColumnNames[i], \"\", \'white\', 0))\n"
"		{\n"
"			BarColumnEnabled[i] = !BarColumnEnabled[i];\n"
"			for(var j = 0; j < ColumnsWidth.length; ++j)\n"
"			{\n"
"				ColumnsWidth[i] = 20;\n"
"			}\n"
"		}\n"
"	}\n"
"\n"
"	SizeInfo.h = M.y - SizeInfo.y;\n"
"	return SizeInfo;\n"
"\n"
"}\n"
"\n"
"\n"
"function ToggleView()\n"
"{\n"
"	Settings.ViewActive = (Settings.ViewActive+1) % VIEW_SIZE;\n"
"	ActivateView(Settings.ViewActive);\n"
"}\n"
"\n"
"function ActivateView(idx)\n"
"{\n"
"	for(var i = 1; i < Views.length; ++i)\n"
"	{\n"
"		Views[i].visible = false;\n"
"	}\n"
"	if(idx == VIEW_GRAPH_SPLIT)\n"
"	{\n"
"		MainView.DisplayFunc = DrawGraphSplit;\n"
"		MainView.visible = true;\n"
"	}\n"
"	else if(idx == VIEW_GRAPH)\n"
"	{\n"
"		MainView.DisplayFunc = DrawGraphSingle;\n"
"		MainView.visible = true;\n"
"	}\n"
"	else if(idx == VIEW_BAR)\n"
"	{\n"
"		MainView.DisplayFunc = DrawBarView;\n"
"		MainView.visible = true;\n"
"	}\n"
"	else if(idx == VIEW_COUNTERS)\n"
"	{\n"
"		MainView.DisplayFunc = DrawCounterView;\n"
"		MainView.visible = true;\n"
"	}\n"
"	else if(idx == VIEW_BAR_SINGLE || idx == VIEW_BAR_ALL)\n"
"	{\n"
"		for(var i = 0; i < X7Views.length; ++i)\n"
"		{\n"
"			X7Views[i].visible = true;\n"
"		}\n"
"		SingleTimerBars = idx == VIEW_BAR_SINGLE;\n"
"	}\n"
"	Settings.ViewActive = idx;\n"
"	X7BarColumnMask = -1;\n"
"	ViewBarMaxMsTextLength  = 0;\n"
"	var hest = 3;\n"
"}\n"
"function DrawMenuViews()\n"
"{\n"
"	var ViewClick = function(idx, name)\n"
"	{\n"
"		ActivateView(idx);\n"
"	};\n"
"	var x = MenuItems[SubMenuViews].x;\n"
"	var y = MenuItems[SubMenuViews].y;\n"
"	return DrawMenuGeneric(ViewNames, Settings.ViewActive, ViewClick, x, y, ViewNames2);\n"
"}\n"
"\n"
"function TweakValue(Value, Tweak, amount, Min, Max)\n"
"{\n"
"	var V = 0.98;\n"
"	if(Tweak<0)\n"
"	{\n"
"		for(var x = 0; x < Math.abs(Tweak); ++x)\n"
"		{\n"
"			var newValue = Math.floor(Value*V);\n"
"			if(newValue == Value)\n"
"			{\n"
"				Value--;\n"
"			}\n"
"			else\n"
"			{\n"
"				Value = newValue;\n"
"			}\n"
"		}\n"
"	}\n"
"	else\n"
"	{\n"
"		var RcpV = 1.0 / V;\n"
"\n"
"		for(var x = 0; x < Tweak; ++x)\n"
"		{\n"
"			var newValue = Math.ceil(Value*RcpV);\n"
"			if(newValue == Value)\n"
"			{\n"
"				Value++;\n"
"			}\n"
"			else\n"
"			{\n"
"				Value = newValue;\n"
"			}\n"
"		}\n"
"	}\n"
"	if(Min!=null && Value < Min)\n"
"		Value = Min;\n"
"	if(Max!=null && Value > Max)\n"
"		Value = Max;\n"
"	return Value;\n"
"\n"
"}\n"
"\n"
"function NextValue(Presets, Value, Dir)\n"
"{\n"
"	var idx = 0;	\n"
"	if(Dir > 0)\n"
"	{\n"
"		for(idx = 0;idx < Presets.length; ++idx)\n"
"		{\n"
"			if(Presets[idx] > Value)\n"
"			{\n"
"				break;\n"
"			}\n"
"		}\n"
"	}\n"
"	else\n"
"	{\n"
"		for(idx = Presets.length; idx >= 0; idx -= 1)\n"
"		{\n"
"			if(Presets[idx] < Value)\n"
"			{\n"
"				break;\n"
"			}\n"
"		}\n"
"	}\n"
"	idx = (idx + Presets.length) % Presets.length;\n"
"	return Presets[idx];\n"
"}\n"
"function AutoCaptureRoll(Direction, Tweak, SetDirect)\n"
"{\n"
"	if(SetDirect)\n"
"	{\n"
"		Settings.AutoCaptureTheshold = SetDirect;\n"
"	}\n"
"	else if(Tweak)\n"
"	{\n"
"		Settings.AutoCaptureTheshold = TweakValue(Settings.AutoCaptureTheshold, Tweak, 0.98, 1, 500);\n"
"	}\n"
"	else if(Direction)\n"
"	{\n"
"		Settings.AutoCaptureTheshold = NextValue(AutoCaptureThesholdPresets, Settings.AutoCaptureTheshold, Direction);\n"
"	}\n"
"}\n"
"\n"
"function CaptureRoll(Direction, Tweak, SetDirect)\n"
"{\n"
"	if(SetDirect)\n"
"	{\n"
"		Settings.CaptureFrames = SetDirect;\n"
"	}\n"
"	else if(Tweak)\n"
"	{\n"
"		Settings.CaptureFrames = TweakValue(Settings.CaptureFrames, Tweak, 0.98, 5, 300);\n"
"\n"
"	}\n"
"	else if(Direction)\n"
"	{\n"
"		Settings.CaptureFrames = NextValue(CaptureFramesPresets, Settings.CaptureFrames, Direction);\n"
"	}\n"
"}\n"
"function GetAutoCaptureString()\n"
"{\n"
"	if(AutoCaptureSourceIndex >= 0)\n"
"	{\n"
"		if(AutoCaptureSourceIndex >= EnabledArray.length)\n"
"		{\n"
"			AutoCaptureSourceIndex = -1;\n"
"			AutoCaptureSourceIndex = -1;\n"
"		}\n"
"		else\n"
"		{\n"
"			var idx = EnabledArray[AutoCaptureSourceIndex];\n"
"			return TimerArray[idx].name;\n"
"		}\n"
"	}\n"
"	return \"Frame Time\";\n"
"}\n"
"\n"
"function AutoCaptureSourceRoll(Direction, Tweak, SetDirect)\n"
"{\n"
"	if(SetDirect)\n"
"	{\n"
"\n"
"	}else if(Tweak||Direction)\n"
"	{\n"
"		if(!Direction)\n"
"			Direction = Tweak;\n"
"		if(Direction<0)\n"
"		{\n"
"			AutoCaptureSourceIndex--;\n"
"			if(AutoCaptureSourceIndex<-1)\n"
"			{\n"
"				AutoCaptureSourceIndex = EnabledArray.length-1;\n"
"			}\n"
"		}\n"
"		else\n"
"		{\n"
"			AutoCaptureSourceIndex++;\n"
"			if(AutoCaptureSourceIndex >= EnabledArray.length)\n"
"			{\n"
"				AutoCaptureSourceIndex = -1;\n"
"			}\n"
"		}\n"
"\n"
"	}\n"
"}\n"
"\n"
"function ShowPrompt(Title, Value, Type)\n"
"{\n"
"	var v;\n"
"	if(Type == \'int\')\n"
"	{\n"
"		var newValue = prompt(\'\' + Title, \'\' + Value);\n"
"		v = parseInt(newValue);\n"
"	}\n"
"	else if(Type == \'float\')\n"
"	{\n"
"		var newValue = prompt(\'\' + Title, \'\' + Value);\n"
"		v = parseFloat(newValue);\n"
"	}\n"
"	else\n"
"	{\n"
"		var v = prompt(\'\' + Title, \'\' + Value);\n"
"		return v;\n"
"	}\n"
"	if(isNaN(v))\n"
"	{\n"
"		return Value;\n"
"	}\n"
"	else\n"
"	{\n"
"		return v;\n"
"	}\n"
"\n"
"}\n"
"function MeasureArray(v, A, f)\n"
"{\n"
"	var context = CanvasDetailedView.getContext(\'2d\');	\n"
"	for(var i = 0; i < A.length; ++i)\n"
"	{\n"
"		var s = A[i];\n"
"		if(f)\n"
"			s=f(s);\n"
"		var l = context.measureText(s).width;\n"
"		v = v < l ? l : v;\n"
"	}\n"
"	return v;\n"
"}\n"
"\n"
"function CreateMenuState(SizeInfo)\n"
"{\n"
"	var MenuState = {};\n"
"	for(var i in SizeInfo)\n"
"	{\n"
"		MenuState[i] = SizeInfo[i];\n"
"	}\n"
"	MenuState.cidx = 0;\n"
"	return MenuState;\n"
"}\n"
"\n"
"function DrawMenuElement(M, Selected, Name, Value, color)\n"
"{\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"\n"
"	var bMouseIn = MouseY >= M.y && MouseY < M.y + BoxHeight;\n"
"	var YText = M.y + BoxHeight - FontAscent;\n"
"\n"
"	var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[M.cidx];\n"
"	context.fillStyle = Selected?\'white\':bgcolor;\n"
"	context.fillRect(M.x-2, M.y, M.w + 4, BoxHeight);\n"
"	context.fillStyle = bgcolor;\n"
"	context.fillRect(M.x, M.y, M.w, BoxHeight);\n"
"	context.fillStyle = color;\n"
"	context.fillText(Name, M.x, YText);\n"
"	context.textAlign = \'right\';\n"
"	context.fillText(\'\' + Value, M.x + M.w - 2, YText);\n"
"	context.textAlign = \'left\';\n"
"	M.cidx = 1-M.cidx;\n"
"	M.y += BoxHeight;\n"
"	return bMouseIn && MouseReleased;\n"
"}\n"
"function DrawMenuRoll(M, Name, RollValue, RollExt, RollFunction, Tweak, Type)\n"
"{\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"\n"
"	var YText = M.y + BoxHeight - FontAscent;\n"
"	var SizeMinus = context.measureText(\'-\').width;\n"
"	var SizePlus = context.measureText(\'+\').width;\n"
"\n"
"	var bMouseIn = MouseY >= M.y && MouseY < M.y + BoxHeight;\n"
"	var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[M.cidx];\n"
"	context.fillStyle = bgcolor;\n"
"	context.fillRect(M.x-2, M.y, M.w+4, BoxHeight);\n"
"	context.fillStyle = \'white\';\n"
"	context.fillText(Name, M.x, YText);\n"
"	context.textAlign = \'right\';\n"
"	var XTemp = M.x + M.w - 3;\n"
"\n"
"	if(KeyShiftDown && bMouseIn)\n"
"	{\n"
"		if(Tweak>=0)\n"
"		{\n"
"			RollFunction(0, MouseX-Tweak);\n"
"		}\n"
"		Tweak = MouseX;\n"
"		bMouseIn = false;\n"
"	}\n"
"	else\n"
"	{\n"
"		Tweak = -1;\n"
"	}\n"
"\n"
"	var MouseReleasedUsed = false;\n"
"	if(bMouseIn && MouseX >= XTemp - SizePlus && MouseX <= XTemp)\n"
"	{\n"
"		context.fillStyle = \'red\';\n"
"		if(MouseReleased)\n"
"		{\n"
"			RollFunction(1);\n"
"			MouseReleasedUsed = true;\n"
"		}\n"
"	}\n"
"	else\n"
"	{\n"
"		context.fillStyle = \'white\';\n"
"	}\n"
"	context.fillText(\'+\', XTemp, YText);\n"
"	XTemp -= SizePlus + 3;\n"
"\n"
"\n"
"\n"
"	if(bMouseIn && MouseX >= XTemp - SizeMinus && MouseX <= XTemp)\n"
"	{\n"
"		context.fillStyle = \'red\';\n"
"		if(MouseReleased)\n"
"		{\n"
"			RollFunction(-1);\n"
"			MouseReleasedUsed = true;				\n"
"		}\n"
"	}\n"
"	else\n"
"	{\n"
"		context.fillStyle = \'white\';\n"
"	}\n"
"\n"
"	context.fillText(\'-\', XTemp, YText);\n"
"	XTemp -= SizeMinus + 3;\n"
"	var RollText = \'\'+RollValue + RollExt;\n"
"	var RollWidth = context.measureText(RollText).width;\n"
"	context.fillStyle = \'white\';\n"
"\n"
"	context.fillText(RollText, XTemp, YText);\n"
"	XTemp -= RollWidth;\n"
"	\n"
"	context.textAlign = \'left\';\n"
"\n"
"	M.cidx = 1-M.cidx;\n"
"\n"
"	M.y += BoxHeight;\n"
"	if(Type && MouseReleased && bMouseIn && !MouseReleasedUsed)\n"
"	{\n"
"		var V = ShowPrompt(Name, RollValue, Type);\n"
"		RollFunction(0,0,V);\n"
"	}\n"
"	return Tweak;\n"
"\n"
"}\n"
"\n"
"\n"
"\n"
"\n"
"function DrawMenuCapture()\n"
"{\n"
"	var Selection = null;\n"
"	var SizeInfo = {};\n"
"	SizeInfo.h = 4 * BoxHeight;\n"
"	var Strings = [\"AutoCapture Enabled\", \"AutoCapture Threshold\", \"AutoCapture Source\", \"Capture Length\"];\n"
"	var wLeft = MeasureArray(0, Strings);\n"
"	var wRight = 50;\n"
"	wRight = MeasureArray(wRight, [\"Frame Time\"]);\n"
"	wRight = MeasureArray(wRight, EnabledArray, function(a){return TimerArray[a].name; } );\n"
"	var Width = wLeft + 35 + wRight;\n"
"	SizeInfo.w = Width;\n"
"	SizeInfo.x = CaptureButtonX - SizeInfo.w;\n"
"	SizeInfo.y = CaptureButtonY - SizeInfo.h;\n"
"	\n"
"	var M = CreateMenuState(SizeInfo);\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"	context.fillRect(M.x, M.y, Width, SizeInfo.h);\n"
"	if(DrawMenuElement(M, 0, \"AutoCapture Enabled\", AutoCaptureEnabled ? \"on\" : \"off\", \'white\', 0))\n"
"	{\n"
"		AutoCaptureEnabled = !AutoCaptureEnabled;\n"
"	}\n"
"	AutoCaptureSourceTweak = DrawMenuRoll(M, \"AutoCapture Source\", GetAutoCaptureString(), \'\', AutoCaptureSourceRoll, AutoCaptureSourceTweak);\n"
"	AutoCaptureTweak = DrawMenuRoll(M, \"AutoCapture Threshold\", Settings.AutoCaptureTheshold, \'ms\', AutoCaptureRoll, AutoCaptureTweak, \'int\');\n"
"	CaptureTweak = DrawMenuRoll(M, \"Capture Length\",  Settings.CaptureFrames, \'\', CaptureRoll, CaptureTweak, \'int\');\n"
"\n"
"	SizeInfo.h = M.y - SizeInfo.y;\n"
"	return SizeInfo;\n"
"\n"
"}\n"
"function WindowRect(x,y,w,h)\n"
"{\n"
"	var s = {};\n"
"	s.x = x;\n"
"	s.y = y;\n"
"	s.w = w;\n"
"	s.h = h;\n"
"	return s;\n"
"}\n"
"function GetA";

const size_t g_MicroProfileHtmlLive_begin_1_size = sizeof(g_MicroProfileHtmlLive_begin_1);
const char g_MicroProfileHtmlLive_begin_2[] =
"ggregateString()\n"
"{\n"
"	if(0 == Settings.AggregateFrames)\n"
"		return \'infinite\';\n"
"	else\n"
"		return Settings.AggregateFrames + \'\';\n"
"}\n"
"\n"
"function AggregateRoll(Direction, Tweak, SetDirect)\n"
"{\n"
"	if(SetDirect || SetDirect == 0)\n"
"	{\n"
"		if(SetDirect <= 0 || SetDirect == \'infinite\')\n"
"		{\n"
"			Settings.AggregateFrames = 0;\n"
"		}\n"
"		else\n"
"		{\n"
"			Settings.AggregateFrames = SetDirect;\n"
"		}\n"
"	}\n"
"	else if(Tweak)\n"
"	{\n"
"		Settings.AggregateFrames = TweakValue(Settings.AggregateFrames, Tweak, 0.98, 0, 500);\n"
"\n"
"	}\n"
"	else if(Direction)\n"
"	{\n"
"		Settings.AggregateFrames = NextValue(AggregatePresets, Settings.AggregateFrames, Direction);\n"
"	}\n"
"}\n"
"function ReferenceRoll(Direction, Tweak, SetDirect)\n"
"{\n"
"	if(SetDirect)\n"
"	{\n"
"		Settings.ReferenceTime = SetDirect;\n"
"	}\n"
"	else if(Tweak)\n"
"	{\n"
"		Settings.ReferenceTime = TweakValue(Settings.ReferenceTime, Tweak, 0.98, 5, 1000);\n"
"\n"
"	}\n"
"	else if(Direction)\n"
"	{\n"
"		Settings.ReferenceTime = NextValue(ReferencePresets, Settings.ReferenceTime, Direction);\n"
"	}\n"
"}\n"
"function TargetRoll(Direction, Tweak, SetDirect)\n"
"{\n"
"	if(SetDirect)\n"
"	{\n"
"		Settings.TargetTime = SetDirect;\n"
"	}\n"
"	else if(Tweak)\n"
"	{\n"
"		Settings.TargetTime = TweakValue(Settings.TargetTime, Tweak, 0.98, 5, 1000);\n"
"\n"
"	}\n"
"	else if(Direction)\n"
"	{\n"
"		Settings.TargetTime = NextValue(ReferencePresets, Settings.TargetTime, Direction);\n"
"	}\n"
"}\n"
"\n"
"function DrawMenuSettings()\n"
"{\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"	var nColorIndex = 0;\n"
"	var SizeInfo = AggregateMenuSize();\n"
"	SizeInfo.x = MenuItems[SubMenuSettings].x;\n"
"	SizeInfo.y = MenuItems[SubMenuSettings].y;\n"
"\n"
"	SizeInfo.w = 200;\n"
"	var M = CreateMenuState(SizeInfo);\n"
"\n"
"	AggregateTweak = DrawMenuRoll(M, \"Aggregate Frames\", GetAggregateString(), \'\', AggregateRoll, AggregateTweak, \'int\');\n"
"	ReferenceTimeTweak = DrawMenuRoll(M, \"Reference Time\", Settings.ReferenceTime, \'\', ReferenceRoll, ReferenceTimeTweak, \'int\');\n"
"	TargetTimeTweak = DrawMenuRoll(M, \"Target Time\", Settings.TargetTime, \'\', TargetRoll, TargetTimeTweak, \'int\');\n"
"	if(DrawMenuElement(M, Settings.FancyGraph, \"Fancy Graph\", Settings.FancyGraph, \'white\'))\n"
"	{\n"
"		Settings.FancyGraph = 1-Settings.FancyGraph;\n"
"	}\n"
"	if(DrawMenuElement(M, Settings.AutomaticReference, \"Automatic Reference Time\", Settings.AutomaticReference, \'white\'))\n"
"	{\n"
"		Settings.AutomaticReference = 1-Settings.AutomaticReference;\n"
"	}\n"
"	if(DrawMenuElement(M, Settings.ViewCompressed, \"Compressed View\", Settings.ViewCompressed, \'white\'))\n"
"	{\n"
"		Settings.ViewCompressed = 1-Settings.ViewCompressed;\n"
"		ResizeCanvas();\n"
"	}\n"
"\n"
"	if(Settings.AggregateFrames <= 0)\n"
"	{\n"
"		if(DrawMenuElement(M, 0, \"Clear Aggregate\", \"Current[\" + AggregateCurrent + \"]\", \'white\'))\n"
"		{\n"
"			WSSendMessage(\"r\");\n"
"		}\n"
"	}\n"
"	if(DrawMenuElement(M, Settings.AllowHighDPI, \"Allow High DPI\", Settings.AllowHighDPI, \'white\'))\n"
"	{\n"
"		Settings.AllowHighDPI = 1 - Settings.AllowHighDPI;\n"
"		ResizeCanvas();\n"
"	}\n"
"\n"
"\n"
"	SizeInfo.h = M.y - SizeInfo.y;\n"
"	return SizeInfo;\n"
"\n"
"}\n"
"\n"
"\n"
"function MoveFilterInputDiv(x, y, w)\n"
"{\n"
"	if(FilterInputDivPos.x != x || FilterInputDivPos.y != y || FilterInputDivPos.w != w)\n"
"	{\n"
"		FilterInputDivPos.x = x;\n"
"		FilterInputDivPos.y = y;\n"
"		FilterInputDivPos.w = w;\n"
"		FilterInputDiv.style[\'left\'] = x + \'px\';\n"
"		FilterInputDiv.style[\'top\'] = y + \'px\';\n"
"		FilterInput.style[\'width\'] = w + \'px\';\n"
"	}\n"
"}\n"
"function DrawMenuTimer()\n"
"{\n"
"	if(FilterInputValueLast != FilterInput.value)\n"
"	{\n"
"		nOffsetMenuTimers = 0;\n"
"	}\n"
"	FilterInputValueLast = FilterInput.value;\n"
"	var FilterArray = CreateFilter(FilterInput.value);\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"	var nColorIndex = 0;\n"
"	var SizeInfo = TimerMenuSize();\n"
"	SizeInfo.x = MenuItems[SubMenuTimers].x;\n"
"	SizeInfo.y = MenuItems[SubMenuTimers].y;\n"
"	var Y = SizeInfo.y;\n"
"	var Width = SizeInfo.w;\n"
"	var Selection = null;\n"
"	var X = SizeInfo.x;\n"
"	MoveFilterInputDiv(SizeInfo.x, SizeInfo.y, SizeInfo.w);\n"
"	Y += 35;\n"
"\n"
"	var bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight;\n"
"	var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
"	var TextY = Y+BoxHeight-FontAscent;\n"
"	var YClear = Y;\n"
"	var TextYClear = TextY;\n"
"	var bgcolorClear = bgcolor;\n"
"	var YStart = Y;\n"
"\n"
"	var MouseTaken = bMouseIn;\n"
"	if(bMouseIn && MouseReleased)\n"
"	{\n"
"		WSSendMessage(\"x\");\n"
"	}\n"
"\n"
"	Y += BoxHeight;\n"
"	nColorIndex = 1-nColorIndex;\n"
"\n"
"	Y -= nOffsetMenuTimers;\n"
"\n"
"	for(var i = 0; i < TimerArray.length; ++i)\n"
"	{\n"
"		var v = TimerArray[i];\n"
"		if(v.idtype == TYPE_TIMER)\n"
"		{\n"
"			var Name = v.name;\n"
"			var ParentName = TimerArray[v.parent].name;\n"
"			if(FilterMatch(FilterArray, ParentName + \" \" + Name))\n"
"			{\n"
"				if(Y > YStart)\n"
"				{\n"
"					var ParentColor = TimerArray[v.parent].e ? \'white\' : \'grey\';\n"
"					bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight && !MouseTaken;\n"
"					bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
"					TextY = Y+BoxHeight-FontAscent;\n"
"					context.fillStyle = v.e?\'white\':bgcolor;\n"
"					context.fillRect(X-2, Y, Width+4, BoxHeight);\n"
"					context.fillStyle = bgcolor;\n"
"					context.fillRect(X, Y, Width, BoxHeight);\n"
"					context.fillStyle = ParentColor;\n"
"					context.fillText(ParentName, X + 2, TextY);\n"
"					context.fillStyle = v.color;\n"
"					context.textAlign = \'right\';\n"
"					context.fillText(Name, X + Width - 2, TextY);\n"
"					context.textAlign = \'left\';\n"
"					if(bMouseIn)\n"
"					{\n"
"						Selection = v.id;\n"
"					}\n"
"				}\n"
"				Y += BoxHeight;\n"
"				nColorIndex = 1-nColorIndex;\n"
"			}\n"
"		}\n"
"	}\n"
"\n"
"	context.fillStyle = bgcolorClear;\n"
"	context.fillRect(X-2, YClear, Width+4, BoxHeight);\n"
"	context.fillText(ParentName, X + 2, TextYClear);\n"
"	context.fillStyle = \'white\';\n"
"	context.textAlign = \'center\';\n"
"	context.fillText(\"[clear]\", X + 2 + Width * 0.5, TextYClear);\n"
"	context.textAlign = \'left\';\n"
"\n"
"\n"
"\n"
"	if(Selection && MouseReleased && !MouseTaken)\n"
"	{\n"
"		WSSendMessage(\"c\" + Selection);\n"
"	}\n"
"	SizeInfo.h = Y-SizeInfo.y;\n"
"	return SizeInfo;\n"
"}\n"
"function DrawMenuGeneric(Elements, Active, OnClick, x, y, Elements2)\n"
"{\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"	var nColorIndex = 0;\n"
"	if(Elements2.length != Elements.length)\n"
"	{\n"
"		Elements2 = null;\n"
"	}\n"
"\n"
"	var h = FontHeight * Elements.length;\n"
"	var w = 20;\n"
"	var w2 = 0;\n"
"	for(var i = 0; i < Elements.length; ++i)\n"
"	{\n"
"		var m = context.measureText(Elements[i]).width;\n"
"		w = w > m ? w : m;\n"
"		if(Elements2)\n"
"		{\n"
"			m = context.measureText(Elements2[i]).width;\n"
"			w2 = w2 > m ? w2 : m;\n"
"		}\n"
"	}\n"
"	w += 10 + w2;\n"
"	var SizeInfo = MenuSize(w);\n"
"	SizeInfo.x = x;\n"
"	SizeInfo.y = y;\n"
"	var X = x;\n"
"	var Y = y;\n"
"\n"
"\n"
"	for(var i = 0; i < Elements.length; ++i)\n"
"	{\n"
"		var Selected = Active == i;\n"
"		var Name = Elements[i];\n"
"		var bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight;\n"
"		var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
"		var TextY = Y+BoxHeight-FontAscent;\n"
"		context.fillStyle = Selected?\'white\':bgcolor;\n"
"		context.fillRect(X-2, Y, w+4, BoxHeight);\n"
"		context.fillStyle = bgcolor;\n"
"		context.fillRect(X, Y, w, BoxHeight);\n"
"		context.fillStyle = \'white\';\n"
"		context.fillText(Name, X + 2, TextY);\n"
"		if(Elements2)\n"
"		{\n"
"			context.textAlign = \"right\";\n"
"			context.fillText(Elements2[i], X + w , TextY);\n"
"			context.textAlign = \"left\";\n"
"		}\n"
"		context.fillText(Name, X + 2, TextY);\n"
"		if(bMouseIn && MouseReleased)\n"
"		{\n"
"			OnClick(i, Name);\n"
"		}\n"
"		Y += BoxHeight;\n"
"		nColorIndex = 1-nColorIndex;\n"
"	}\n"
"	SizeInfo.h = Y - SizeInfo.y;\n"
"	return SizeInfo;\n"
"}\n"
"\n"
"function DrawMenuGroup()\n"
"{\n"
"	if(FilterInputValueLast != FilterInput.value)\n"
"	{\n"
"		nOffsetMenuGroup = 0;\n"
"	}\n"
"	FilterInputValueLast = FilterInput.value;\n"
"\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"	var nColorIndex = 0;\n"
"	var Selection = null;\n"
"	var SizeInfo = GroupMenuSize();\n"
"	SizeInfo.x = MenuItems[SubMenuGroup].x;\n"
"	SizeInfo.y = MenuItems[SubMenuGroup].y;\n"
"	var Y = SizeInfo.y;\n"
"	var X = SizeInfo.x;\n"
"	var Width = SizeInfo.w;\n"
"	var FilterArray = CreateFilter(FilterInput.value);\n"
"	MoveFilterInputDiv(SizeInfo.x-2, SizeInfo.y, SizeInfo.w-1);\n"
"	var YStart = Y+20;\n"
"	Y += 35;\n"
"	Y -= nOffsetMenuGroup;\n"
"\n"
"\n"
"	function DrawMenuElement(Selected, Name, color, Indent)\n"
"	{\n"
"		var bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight;\n"
"		var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
"		context.fillStyle = Selected?\'white\':bgcolor;\n"
"		context.fillRect(X-2, Y, Width+4, BoxHeight);\n"
"		context.fillStyle = bgcolor;\n"
"		context.fillRect(X, Y, Width, BoxHeight);\n"
"		context.fillStyle = color;\n"
"		if(!Indent) Indent = 0;\n"
"		context.fillText(Name, X + Indent*FontWidth, Y+BoxHeight-FontAscent);\n"
"		nColorIndex = 1-nColorIndex;\n"
"		Y += BoxHeight;\n"
"		return bMouseIn;\n"
"	}\n"
"	function DrawMenuRecursive(Index, Indent, categorymatch)\n"
"	{\n"
"		ProfileEnter(\"DrawMenuRecursive\");		\n"
"		var v = TimerArray[Index];\n"
"		if(v.idtype == TYPE_TIMER || v.idtype == TYPE_COUNTER)\n"
"		{\n"
"			return;\n"
"		}\n"
"		if(v.idtype == TYPE_GROUP && !categorymatch)\n"
"		{\n"
"			if(!FilterMatch(FilterArray, v.name))\n"
"			{\n"
"				return;\n"
"			}\n"
"		}\n"
"		var catmatch = 0;\n"
"		if(v.idtype == TYPE_CATEGORY)\n"
"		{\n"
"			if(FilterMatch(FilterArray, v.name))\n"
"			{\n"
"				catmatch = 1;\n"
"			}\n"
"		}\n"
"		var Closed = 0;\n"
"		if(Index > 0)\n"
"		{\n"
"			if(Y > YStart)\n"
"			{\n"
"				if(DrawMenuElement(v.e, v.name, v.color, Indent))\n"
"				{\n"
"					Selection = v.id;\n"
"				}\n"
"			}\n"
"			else\n"
"			{\n"
"				Y += BoxHeight;\n"
"			}\n"
"		}\n"
"\n"
"		if(!Closed)\n"
"		{\n"
"			var ChildIndex = v.firstchild;\n"
"			while(ChildIndex != -1)\n"
"			{\n"
"				DrawMenuRecursive(ChildIndex, Indent + 1, catmatch);\n"
"				ChildIndex = TimerArray[ChildIndex].sibling;\n"
"			}\n"
"		}\n"
"		ProfileLeave();\n"
"	}\n"
"	DrawMenuRecursive(0, -1);\n"
"	if(Selection && MouseReleased)\n"
"	{\n"
"		WSSendMessage(\"c\" + Selection);\n"
"	}\n"
"	SizeInfo.h = Y - SizeInfo.y;\n"
"	return SizeInfo;\n"
"}\n"
"\n"
"function ShowMenu()\n"
"{\n"
"	if(!Settings.ViewCompressed)\n"
"		return true;\n"
"	else\n"
"	{\n"
"		var Time = new Date();\n"
"		var Delta = Time - MouseMoveTime;\n"
"		console.log(\'delta time is \' + Delta);\n"
"		return Delta < 2000;\n"
"	}\n"
"}\n"
"\n"
"function DrawMenu()\n"
"{\n"
"	if(WSConnected && WS && WS.readyState == 1)\n"
"	{\n"
"		var context = CanvasDetailedView.getContext(\'2d\');\n"
"		var nColorIndex = 0;\n"
"		var Y = 50;\n"
"		var Width = 300;\n"
"		var Selection = null;\n"
"		if(!ShowMenu())\n"
"		{\n"
"			return;\n"
"		}\n"
"		ProfileEnter(\"DrawMenu\");\n"
"		DrawTopMenu();\n"
"		var MenuRect = WindowRect(0,0,nWidth,nHeight);\n"
"		if(SubMenuActive != -1)\n"
"		{\n"
"			MouseMoveTime = new Date();\n"
"		}\n"
"		if(SubMenuActive == SubMenuGroup)\n"
"		{\n"
"			MenuRect = DrawMenuGroup();\n"
"		}\n"
"		else if(SubMenuActive == SubMenuTimers)\n"
"		{\n"
"			MenuRect = DrawMenuTimer();\n"
"		}\n"
"		else if(SubMenuActive == SubMenuSettings)\n"
"		{\n"
"			MenuRect = DrawMenuSettings();\n"
"		}\n"
"		else if(SubMenuActive == SubMenuViews)\n"
"		{\n"
"			MenuRect = DrawMenuViews();\n"
"		}\n"
"		else if(SubMenuActive == SubMenuPresets)\n"
"		{\n"
"			MenuRect = DrawMenuPresets();\n"
"		}\n"
"		else if(SubMenuActive == SubMenuColumns)\n"
"		{\n"
"			MenuRect = DrawMenuColumns();\n"
"		}\n"
"		else if(SubMenuActive == SubMenuCapture)\n"
"		{\n"
"			MenuRect = DrawMenuCapture();\n"
"		}\n"
"\n"
"		var Grow = 10;\n"
"		MenuRect.x -= Grow;\n"
"		MenuRect.y -= Grow;\n"
"		MenuRect.h += 2*Grow;\n"
"		MenuRect.w += 2*Grow;\n"
"		var MouseMoved = MouseX != SubMenuMouseX || MouseY != SubMenuMouseY;\n"
"	\n"
"		if(MouseInRect(MenuRect) || !MouseMoved)\n"
"		{\n"
"			SubMenuTimeout = new Date();\n"
"			SubMenuMouseX = MouseX;\n"
"			SubMenuMouseY = MouseY;\n"
"		}\n"
"		else\n"
"		{\n"
"			var Time = new Date() - SubMenuTimeout;\n"
"			var Dest = SubMenuTimeoutBase * 1000;\n"
"			if(Time > Dest)\n"
"			{\n"
"				EnableMenu(-1);\n"
"			}\n"
"		}\n"
"		if(0)//debugging of menu extents. dont delete\n"
"		{\n"
"			context.strokeStyle = \'red\';\n"
"			context.beginPath();\n"
"			context.moveTo(MenuRect.x,MenuRect.y);\n"
"			context.lineTo(MenuRect.x + MenuRect.w,MenuRect.y);\n"
"			context.lineTo(MenuRect.x + MenuRect.w,MenuRect.y+MenuRect.h);\n"
"			context.lineTo(MenuRect.x,MenuRect.y+MenuRect.h);\n"
"			context.lineTo(MenuRect.x,MenuRect.y);\n"
"			// context.closePath();\n"
"			context.stroke();\n"
"		}\n"
"		ProfileLeave();\n"
"	}\n"
"}\n"
"\n"
"function DrawConnectionStatus()\n"
"{\n"
"	if(WSConnected && WS && WS.readyState == 1)\n"
"	{\n"
"		if(!ProfileMode)\n"
"			return;\n"
"	}\n"
"	var Strings = new Array();\n"
"	Strings.push(\"Status\");\n"
"	if(WSConnected && WS && WS.readyState == 1)\n"
"	{\n"
"		Strings.push(\"[X]\");\n"
"	}\n"
"	else\n"
"	{\n"
"		ConnectionIdx = (ConnectionIdx + 1 ) % ConnectionStr.length;\n"
"		Strings.push(\"[\" + ConnectionStr[ConnectionIdx]+\"]\");\n"
"	}\n"
"	Strings.push(\"Port\");\n"
"	Strings.push(\"\" + WSPort);\n"
"	Strings.push(\"Path\");\n"
"	Strings.push(\"\" + WSPath);\n"
"	Strings.push(\"Sends\");\n"
"	Strings.push(\"\" + WSSend);\n"
"	Strings.push(\"Receives\");\n"
"	Strings.push(\"\" + WSReceive);\n"
"	Strings.push(\"SendBytes\");\n"
"	Strings.push(\"\" + WSSendBytes);\n"
"	Strings.push(\"ReceiveBytes\");\n"
"	Strings.push(\"\" + WSReceiveBytes);\n"
"	Strings.push(\"Seconds\");\n"
"	Strings.push(\"\" + WSSeconds);\n"
"	DrawToolTip(Strings, CanvasDetailedView, 50000, 0);\n"
"}\n"
"function DrawActiveToolTip()\n"
"{\n"
"	if(SubMenuActive == -1)\n"
"	{\n"
"		if(ToolTipCallback && SubMenuActive == -1)\n"
"		{\n"
"			var Strings = ToolTipCallback(CanvasDetailedView, MouseX, MouseY);\n"
"			if(Strings)\n"
"			{\n"
"				DrawToolTip(Strings, CanvasDetailedView, MouseX, MouseY);\n"
"			}\n"
"		}\n"
"	}\n"
"	ToolTipCallback = null;\n"
"}\n"
"function UpdateSettings()\n"
"{\n"
"	if(Settings.AutomaticReference)\n"
"	{\n"
"		if( Math.abs(ReferenceGraph - ReferenceGraphAutomatic) > 0.02 ||\n"
"			Math.abs(ReferenceHistory - ReferenceHistoryAutomatic) > 0.02)\n"
"		{\n"
"			RequestDraw();\n"
"		}\n"
"		ReferenceGraph = 0.9 * ReferenceGraph + 0.1 * ReferenceGraphAutomatic;\n"
"		ReferenceHistory = 0.9 * ReferenceHistory + 0.1 * ReferenceHistoryAutomatic;\n"
"		ReferenceBar = 0.9 * ReferenceBar + 0.1 * ReferenceBarAutomatic;\n"
"		var TimerMap = FrameData.TimerMap;\n"
"		if(!TimerMap)\n"
"			return;\n"
"\n"
"\n"
"		for(var key in TimerMap)\n"
"		{\n"
"			var TimerState = TimerMap[key];\n"
"			if(!TimerState.historymaxsoft)\n"
"			{\n"
"				TimerState.historymaxsoft = TimerState.historymax;\n"
"			}\n"
"			else\n"
"			{\n"
"				TimerState.historymaxsoft = 0.9 * TimerState.historymaxsoft + 0.1 * TimerState.historymax;\n"
"			}\n"
"		}\n"
"\n"
"	}\n"
"	else\n"
"	{\n"
"		ReferenceGraph = Settings.ReferenceTime;\n"
"		ReferenceHistory = Settings.ReferenceTime;\n"
"		ReferenceBar = Settings.ReferenceTime;\n"
"	}\n"
"	if(Settings.AggregateFrames != AggregateFrames)\n"
"	{\n"
"		WSSendMessage(\"a\" + Settings.AggregateFrames);\n"
"		AggregateFrames = Settings.AggregateFrames;\n"
"	}\n"
"}\n"
"\n"
"var PendingDraw = 0;\n"
"\n"
"function Draw()\n"
"{\n"
"	PendingDraw = 0;\n"
"	ProfileModeClear();\n"
"	ProfileEnter(\"Total\");\n"
"\n"
"	UpdateSettings();\n"
"\n"
"	if(WSConnected && WS && WS.readyState == 1)\n"
"	{\n"
"		DrawViews();\n"
"		DrawMenu();\n"
"	}\n"
"	else\n"
"	{\n"
"		var context = CanvasDetailedView.getContext(\'2d\');\n"
"		context.clearRect(0, 0, nWidth, nHeight);\n"
"	}\n"
"	DrawMessage();\n"
"\n"
"	DrawConnectionStatus();\n"
"	DrawPlotf(CanvasDetailedView);\n"
"	DrawActiveToolTip();\n"
"\n"
"\n"
"	ProfileLeave();\n"
"	ProfileModeDraw(CanvasDetailedView);\n"
"\n"
"	PlotfClear();\n"
"\n"
"	MouseReleased = false;\n"
"}\n"
"function RequestDraw()\n"
"{\n"
"	if(!PendingDraw)\n"
"	{\n"
"		PendingDraw = 1;\n"
"		requestAnimationFrame(Draw);\n"
"	}\n"
"}\n"
"\n"
"\n"
"\n"
"\n"
"function WSOpen()\n"
"{\n"
"	SetMessage(\"Connected!\", 1000);\n"
"	WSSend = 0;\n"
"	WSReceive = 0;\n"
"	WSSendBytes = 0;\n"
"	WSReceiveBytes = 0;\n"
"	WSIsOpen = 1;\n"
"\n"
"	Empty = {\"id\":0, \"w\":0, \"depth\":0, \"sibling\":-1,\"parent\":-1,\"firstchild\":-1};\n"
"	TimerArray = [];\n"
"	TimerArray.push(Empty);\n"
"	WidthArray = [];\n"
"	CounterArray = [];\n"
"	WidthArray[TYPE_NONE] = 0;\n"
"	WidthArray[TYPE_TIMER] = 0;\n"
"	WidthArray[TYPE_GROUP] = 0;\n"
"	WidthArray[TYPE_CATEGORY] = 0;\n"
"	WidthTree = FontWidth;\n"
"\n"
"	ResetFrameData();\n"
"\n"
"	if(PresetToLoad && PresetToLoad != \"\")\n"
"	{\n"
"		LoadPreset(PresetToLoad, PresetToLoadRO);\n"
"	}\n"
"}\n"
"\n"
"function SplitIdTop(v)\n"
"{\n"
"	return v >> 24; // todo: verify\n"
"}\n"
"\n"
"function SplitIdBottom(v)\n"
"{\n"
"	return v & 0xffffff; // todo: verify\n"
"}\n"
"\n"
"function GetTimer(id)\n"
"{\n"
"	for(var i = 0; i < TimerArray.length; ++i)\n"
"	{\n"
"		if(TimerArray[i].id == id)\n"
"		{\n"
"			return i;\n"
"		}\n"
"	}\n"
"	return null;\n"
"}\n"
"\n"
"function UpdateActive()\n"
"{\n"
"	GroupsEnabled = 0;\n"
"	TimersEnabled = 0;\n"
"	for(var i = 0; i < TimerArray.length; ++i)\n"
"	{\n"
"		var T = TimerArray[i];\n"
"		if(T.e)\n"
"		{\n"
"			switch(T.idtype)\n"
"			{\n"
"				case TYPE_GROUP:\n"
"					GroupsEnabled++;\n"
"				break;\n"
"				case TYPE_TIMER:\n"
"					TimersEnabled++;\n"
"				break;\n"
"			}\n"
"		}\n"
"	}\n"
"}\n"
"function UpdateEnabledTimer(idx)\n"
"{\n"
"	UpdateActive();\n"
"	var type = TimerArray[idx].idtype;\n"
"	var enabled = TimerArray[idx].e;\n"
"	if(TimerArray[idx].idtype != TYPE_TIMER)\n"
"	{\n"
"		return;\n"
"	}\n"
"	var AutoCaptureSourceValue = null;\n"
"	if(AutoCaptureSourceIndex >= 0 && AutoCaptureSourceIndex < EnabledArray.length)\n"
"	{\n"
"		AutoCaptureSourceValue = EnabledArray[AutoCaptureSourceIndex];\n"
"	}\n"
"\n"
"	var i = EnabledArray.indexOf(idx);\n"
"	if(enabled)\n"
"	{\n"
"		if(i == -1)\n"
"		{\n"
"			EnabledArray.unshift(idx);\n"
"		}\n"
"	}\n"
"	else\n"
"	{\n"
"		if(i != -1)\n"
"		{\n"
"			EnabledArray.splice(i, 1);\n"
"		}\n"
"	}\n"
"	var NewIndex = AutoCaptureSourceValue != null ? EnabledArray.indexOf(AutoCaptureSourceValue) : -1;\n"
"	AutoCaptureSourceIndex = NewIndex;\n"
"}\n"
"\n"
"\n"
"function EnableTimer(T)\n"
"{\n"
"	var idx = GetTimer(T.id);\n"
"	if(idx != null && idx>=0)\n"
"	{\n"
"		TimerArray[idx].e = T.e;\n"
"		UpdateEnabledTimer(idx);\n"
"	}\n"
"	else\n"
"	{\n"
"		console.log(\'unknown enable message\');\n"
"	}\n"
"}\n"
"function MeasureWidth(str)\n"
"{\n"
"	var context = CanvasDetailedView.getContext(\'2d\');\n"
"	return context.measureText(str).width;\n"
"}\n"
"function AddTimer(T)\n"
"{\n"
"	var idx = TimerArray.length;\n"
"	var existing = GetTimer(T.id);\n"
"	if(existing)\n"
"	{\n"
"		idx = existing;\n"
"	}\n"
"	else\n"
"	{\n"
"		TimerArray[idx] = T;\n"
"	}\n"
"	var w = MeasureWidth(T.name);\n"
"	var idtype = SplitIdTop(T.id);\n"
"	var idelement = SplitIdBottom(T.id);\n"
"	TimerArray[idx].idtype = idtype;\n"
"	TimerArray[idx].idelement = idelement;\n"
"	TimerArray[idx].w = w;\n"
"	TimerArray[idx].wtree = w;\n"
"	if(!existing)\n"
"	{\n"
"		TimerArray[idx].sibling = -1;\n"
"		TimerArray[idx].parent = -1;\n"
"		TimerArray[idx].firstchild = -1;\n"
"	}\n"
"	if(w > WidthArray[idtype])\n"
"	{\n"
"		WidthArray[idtype] = w;\n"
"	}\n"
"	UpdateEnabledTimer(idx);\n"
"	var wparent = 0;\n"
"	var pidx = GetTimer(T.pid);\n"
"	if(pidx >= 0 && !existing)\n"
"	{\n"
"		TimerArray[idx].parent = pidx;\n"
"		var Parent = TimerArray[pidx];\n"
"		var Sibling = Parent.firstchild;\n"
"		wparent = MeasureWidth(Parent.name);\n"
"		Parent.firstchild = idx;\n"
"		if(Sibling != -1)\n"
"		{\n"
"			if(TimerArray[Sibling].sibling == idx)\n"
"			{\n"
"				debugger;\n"
"			}\n"
"		}\n"
"		TimerArray[idx].sibling = Sibling;\n"
"		TimerArray[idx].wtree += Parent.depth * FontWidth;\n"
"		TimerArray[idx].depth = Parent.depth + 1;\n"
"		if(TimerArray[idx].wtree > WidthTree)\n"
"		{\n"
"			WidthTree = TimerArray[idx].wtree;\n"
"		}\n"
"	}\n"
"	TimerArray[idx].wparent = wparent;\n"
"	TimerArray[idx].wtotal = wparent + w;\n"
"\n"
"	if(idtype == TYPE_COUNTER)\n"
"	{\n"
"		if(idelement != CounterArray.length)\n"
"		{\n"
"			debugger;\n"
"		}\n"
"		CounterArray.push(idx);\n"
"		TimerArray[idx].formattedlimit = FormatCounter(TimerArray[idx].format, TimerArray[idx].limit);\n"
"		CounterLimitWidth = Math.max(CounterLimitWidth, TimerArray[idx].formattedlimit.length * (FontWidth+1));\n"
"		CounterNameWidth = Math.max(CounterNameWidth, (TimerArray[idx].name.length + 1 + TimerArray[idx].depth) * (FontWidth+1));\n"
"		TimerArray[idx].counterhistory = {};		\n"
"		TimerArray[idx].counterhistory.history = AllocClearedArray(120);\n"
"		TimerArray[idx].counterhistory.prc = AllocClearedArray(120);		\n"
"	}\n"
"	RequestDraw();\n"
"}\n"
"\n"
"function AllocClearedArray(Size)\n"
"{\n"
"	var A = new Array(Size);\n"
"	for(var i = 0; i < Size; ++i)\n"
"	{\n"
"		A[i] = 0;\n"
"	}\n"
"	return A;\n"
"}\n"
"function PushIntoArray(A, v)\n"
"{\n"
"	A.shift();\n"
"	A.push(v);\n"
"}\n"
"function ResetFrameData()\n"
"{\n"
"	FrameData = {};\n"
"	FrameData.TimerMap = {};\n"
"	FrameData.Time = AllocClearedArray(FrameCount);\n"
"	FrameData.Ids = AllocClearedArray(FrameCount);\n"
"	FrameData.Frozen = AllocClearedArray(FrameCount);\n"
"}\n"
"function GetFrameData(id)\n"
"{\n"
"	if(FrameData.TimerMap[id])\n"
"	{\n"
"		return FrameData.TimerMap[id];\n"
"	}\n"
"	else\n"
"	{\n"
"		var FD = {};\n"
"		FD.Count = AllocClearedArray(FrameCount);\n"
"		FD.Time = AllocClearedArray(FrameCount);\n"
"		FD.TimeExcl = AllocClearedArray(FrameCount);\n"
"		//Ag\n"
"		FD.TimeMax = AllocClearedArray(AggregateHistorySize);\n"
"		FD.TimeMin = AllocClearedArray(AggregateHistorySize);\n"
"		FD.TimeAvg = AllocClearedArray(AggregateHistorySize);\n"
"		FD.TimeExclMax = AllocClearedArray(AggregateHistorySize);\n"
"		FD.TimeExclMin = AllocClearedArray(AggregateHistorySize);\n"
"		FD.TimeExclAvg = AllocClearedArray(AggregateHistorySize);\n"
"		FD.TimeCallAvg = AllocClearedArray(AggregateHistorySize);\n"
"		FD.TimeTotal = AllocClearedArray(AggregateHistorySize);\n"
"		FD.CallCount = AllocClearedArray(AggregateHistorySize);\n"
"		FD.EmptyFrames = 0;\n"
"		\n"
"\n"
"		FD.AggregateFrames = 0;\n"
"		FD.FrameTime = 0.0;\n"
"		FD.Aggregate = 0;\n"
"		FD.AggregateTime = 0.0;\n"
"		FD.AggregateSum = 0;\n"
"		FD.AggregateMax = 0;\n"
"		FD.AggregateMin = C_HUGE;\n"
"		FD.AggregateExclSum = 0;\n"
"		FD.AggregateExclMax = 0;\n"
"		FD.AggregateCount = 0;\n"
"		FD.AggregateExclMin = C_HUGE;\n"
"\n"
"\n"
"\n"
"		FrameData.TimerMap[id] = FD;\n"
"		return FD;\n"
"	}\n"
"}\n"
"\n"
"function ProcessCounters(C)\n"
"{\n"
"	for(var i = 0; i < CounterArray.length; ++i)\n"
"	{\n"
"		if(i > C.length)\n"
"		{\n"
"			debugger;\n"
"		}\n"
"		var idx = CounterArray[i];\n"
"		var value = C[i];\n"
"		var T = TimerArray[idx];\n"
"		T.value = value;\n"
"		if(T.minvalue == undefined)\n"
"			T.minvalue = value;\n"
"		else\n"
"			T.minvalue = Math.min(T.minvalue, value);\n"
"		if(T.maxvalue == undefined)\n"
"			T.maxvalue = value;\n"
"		else\n"
"			T.maxvalue = Math.max(T.maxvalue, value);\n"
"		T.formatted = FormatCounter(T.format, value);\n"
"		var boxprc = 1.0;\n"
"		var counterprc = 0;\n"
"		if(T.limit)\n"
"		{\n"
"			counterprc = value / T.limit;\n"
"			if(counterprc > 1.0)\n"
"			{\n"
"				boxprc = 1.0 / counterprc;\n"
"				counterprc = 1.0;\n"
"			}\n"
"			counterprc = Math.max(counterprc, 0.0);\n"
"\n"
"		}\n"
"		T.boxprc = boxprc;\n"
"		T.counterprc = counterprc;\n"
"		PushIntoArray(T.counterhistory.history, value);\n"
"		var prc = T.maxvalue > T.minvalue ? (value - T.minvalue) / (T.maxvalue - T.minvalue) : 0.0;\n"
"		PushIntoArray(T.counterhistory.prc, prc);\n"
"		CounterValueWidth = Math.max(CounterValueWidth, T.formatted.length * (FontWidth+1));\n"
"	}\n"
"\n"
"}\n"
"\n"
"\n"
"function ProcessFrame(F)\n"
"{\n"
"	if(F.fr)\n"
"	{\n"
"		IsFrozen = 10;//allow it to stabilize after freezing\n"
"		return;\n"
"	}\n"
"	if(IsFrozen)\n"
"	{\n"
"		IsFrozen--;\n"
"	}\n"
"	var TriggerAutoCapture = 0;\n"
"	PushIntoArray(FrameData.Time, F.t);\n"
"	PushIntoArray(FrameData.Ids, F.f);\n"
"	PushIntoArray(FrameData.Frozen, IsFrozen ? 1 : 0);\n"
"	var CaptureId = null;\n"
"	var AutoCapture = AutoCaptureEnabled && !IsFrozen;\n"
"	AggregateCurrent = F.a;\n"
"	if(F.m != Settings.ViewActive)\n"
"	{\n"
"		WSSendMessage(\"v\" + Settings.ViewActive);\n"
"	}\n"
"	if(AutoCapture)\n"
"	{\n"
"		if(AutoCaptureSourceIndex == -1 && F.t > Settings.AutoCaptureTheshold)\n"
"		{\n"
"			TriggerAutoCapture = 1;\n"
"			console.log(\'trigger capture! \', F.t, \' \', Settings.AutoCaptureTheshold);\n"
"		}\n"
"		else if(AutoCaptureSourceIndex >= 0 && AutoCaptureSourceIndex < EnabledArray.length)\n"
"		{\n"
"			var id = TimerArray[EnabledArray[AutoCaptureSourceIndex]].id;\n"
"			var Data = F.x[id];\n"
"			if(Data && Data[0])\n"
"			{\n"
"			 	if(Data[0] > Settings.AutoCaptureTheshold)\n"
"			 	{\n"
"			 		TriggerAutoCapture = 1;\n"
"					console.log(\'trigger capture! \', Data[0], \' \', Settings.AutoCaptureTheshold);\n"
"			 	}\n"
"			}\n"
"		}\n"
"	}\n"
"\n"
"	var GraphTimeMax = 0;\n"
"	var HistoryTimeMax = 0;\n"
"\n"
"	for(var i = 0; i < FrameData.Time.length; ++i)\n"
"	{\n"
"		if(0 == FrameData.Frozen[i])\n"
"		{\n"
"			HistoryTimeMax = HistoryTimeMax > FrameData.Time[i] ? HistoryTimeMax : FrameData.Time[i];\n"
"		}\n"
"	}\n"
"	var FindMaxTime = function(A)\n"
"	{\n"
"		var MaxTime = 0;\n"
"		for(var i = 0; i < A.length; ++i)\n"
"		{\n"
"			if(0 == FrameData.Frozen[i])\n"
"			{\n"
"				MaxTime = MaxTime > A[i] ? MaxTime : A[i];\n"
"			}\n"
"		}\n"
"		GraphTimeMax = MaxTime > GraphTimeMax ? MaxTime : GraphTimeMax;\n"
"		return MaxTime;\n"
"	}\n"
"	function SetTimersInArray(FD, id)\n"
"	{\n"
"		var idx = GetTimer(id);\n"
"		var Pos = AggregateHistorySize-1;\n"
"		var T = TimerArray[idx];\n"
"		T.average = FD.TimeAvg[Pos];\n"
"		T.max = FD.TimeMax[Pos];\n"
"		T.total = FD.TimeTotal[Pos];\n"
"		T.min = FD.TimeMin[Pos];\n"
"		T.spike = (T.average == 0 || T.max == 0) ? 0 : (100*T.max/T.average);\n"
"		T.callaverage = FD.TimeCallAvg[Pos];\n"
"		T.callcount = FD.CallCount[Pos];\n"
"		T.exclaverage = FD.TimeExclAvg[Pos];\n"
"		T.exclmax = FD.TimeExclMax[Pos];\n"
"		T.exclmin = FD.TimeExclMin[Pos];\n"
"	}\n"
"	for(var id in F.x)\n"
"	{\n"
"		var FD = GetFrameData(id);\n"
"		var Data = F.x[id];\n"
"		var Time = Data[0];\n"
"		var TimeExcl = Data[1];\n"
"		var Count = Data[2];\n"
"		PushIntoArray(FD.Time, Time);\n"
"		PushIntoArray(FD.TimeExcl, TimeExcl);\n"
"		PushIntoArray(FD.Count, Count);\n"
"		FD.historymax = FindMaxTime(FD.Time);\n"
"\n"
"		if(FD.Aggregate > Settings.AggregateFrames && Settings.AggregateFrames > 0)\n"
"		{\n"
"			SetTimersInArray(FD, id);\n"
"			FD.Aggregate = 0;\n"
"			FD.AggregateSum = 0;\n"
"			FD.AggregateMax = 0;\n"
"			FD.AggregateMin = C_HUGE;\n"
"			FD.AggregateExclSum = 0;\n"
"			FD.AggregateExclMax = 0;\n"
"			FD.AggregateExclMin = C_HUGE;\n"
"			FD.AggregateCount = 0;\n"
"			\n"
"			FD.TimeMax.shift();\n"
"			FD.TimeMax.push(0);\n"
"			\n"
"			FD.TimeMin.shift();\n"
"			FD.TimeMin.push(0);\n"
"\n"
"			FD.TimeAvg.shift();\n"
"			FD.TimeAvg.push(0);\n"
"			\n"
"			FD.TimeCallAvg.shift();\n"
"			FD.TimeCallAvg.push(0);\n"
"\n"
"			FD.CallCount.shift();\n"
"			FD.CallCount.push(0);\n"
"\n"
"			FD.TimeTotal.shift();\n"
"			FD.TimeTotal.push(0);\n"
"\n"
"			FD.TimeExclMax.shift();\n"
"			FD.TimeExclMax.push(0);\n"
"\n"
"			FD.TimeExclMin.shift();\n"
"			FD.TimeExclMin.push(0);\n"
"\n"
"			FD.TimeExclAvg.shift();\n"
"			FD.TimeExclAvg.push(0);\n"
"		}\n"
"\n"
"		FD.Aggregate += 1;\n"
"		FD.AggregateSum += Time;\n"
"		FD.AggregateMax = FD.AggregateMax > Time ? FD.AggregateMax : Time;\n"
"		FD.AggregateMin = FD.AggregateMin < Time ? FD.AggregateMin : Time;\n"
"		FD.AggregateExclSum += TimeExcl;\n"
"		FD.AggregateExclMax = FD.AggregateExclMax > TimeExcl ? FD.AggregateExclMax : TimeExcl;\n"
"		FD.AggregateExclMin = FD.AggregateExclMin < TimeExcl ? FD.AggregateExclMin : TimeExcl;\n"
"		FD.AggregateCount += Count;\n"
"		var UpdatePos = AggregateHistorySize-1;\n"
"		if(UpdatePos != FD.TimeMax.length - 1)\n"
"		{\n"
"			debugger;\n"
"		}\n"
"\n"
"		FD.TimeMax[UpdatePos] = FD.AggregateMax;\n"
"		FD.TimeMin[UpdatePos] = FD.AggregateMin;\n"
"		FD.TimeAvg[UpdatePos] = FD.AggregateSum / FD.Aggregate;\n"
"		FD.TimeCallAvg[UpdatePos] = FD.AggregateCount ? FD.AggregateSum / FD.AggregateCount : 0;\n"
"		FD.TimeTotal[UpdatePos] = FD.AggregateSum;\n"
"		FD.CallCount[UpdatePos] = FD.AggregateCount;\n"
"		FD.TimeExclAvg[UpdatePos] = FD.AggregateCount ? FD.AggregateExclSum / FD.AggregateCount : 0;\n"
"		FD.TimeExclMax[UpdatePos] = FD.AggregateExclMax;\n"
"		FD.TimeExclMin[UpdatePos] = FD.AggregateExclMin;\n"
"\n"
"		if(Settings.AggregateFrames <= 0)\n"
"		{\n"
"			SetTimersInArray(FD, id);\n"
"		}\n"
"	}\n"
"\n"
"	var ToDelete = new Array();\n"
"	for(var id in FrameData.TimerMap)\n"
"	{\n"
"		FD = FrameData.TimerMap[id];\n"
"		if(!F.x[id])\n"
"		{\n"
"			PushIntoArray(FD.Time,0.0);\n"
"			PushIntoArray(FD.TimeExcl, 0.0);\n"
"			PushIntoArray(FD.Count, 0);\n"
"			FindMaxTime(FD.Time);\n"
"			FD.EmptyFrames++;\n"
"		}\n"
"		else\n"
"		{\n"
"			FD.EmptyFrames = 0;\n"
"		}\n"
"		FD.FrameTime = FD.Time[FD.Time.length-1];\n"
"		FD.AggregateTime = FD.Time[FD.Time.length-1];\n"
"\n"
"		if(FD.EmptyFrames == FD.Time.length)\n"
"		{\n"
"			ToDelete.push(id);\n"
"		}\n"
"	}\n"
"	for(var i = 0; i < ToDelete.length; ++i)\n"
"	{\n"
"		delete FrameData.TimerMap[ToDelete[i]];\n"
"	}\n"
"	FramePending++;\n"
"\n"
"\n"
"	if(TriggerAutoCapture)\n"
"	{\n"
"		Capture();\n"
"		AutoCaptureEnabled = 0;\n"
"	}\n"
"\n"
"	ReferenceGraphAutomatic = 1.05 * GraphTimeMax;\n"
"	ReferenceHistoryAutomatic = 1.05 * HistoryTimeMax;\n"
"	RequestDraw();\n"
"}\n"
"\n"
"function WSMessage()\n"
"{\n"
"	var Obj = JSON.parse(event.data);\n"
"	WSReceive++;\n"
"	WSReceiveBytes += event.data.length;\n"
"	var k = Obj.k;\n"
"	if(k == MSG_TIMER_TREE)\n"
"	{\n"
"		AddTimer(Obj.v);\n"
"	}\n"
"	else if(k == MSG_ENABLED)\n"
"	{\n"
"		EnableTimer(Obj.v);\n"
"	}\n"
"	else if(k == MSG_FRAME)\n"
"	{\n"
"		ProcessFrame(Obj.v);\n"
"	}\n"
"	else if(k == MSG_LOADSETTINGS)\n"
"	{\n"
"		OnLoadPreset(Obj.v, 1, Obj.ro);\n"
"	}\n"
"	else if(k == MSG_CURRENTSETTINGS)\n"
"	{\n"
"		OnLoadPreset(Obj.v, 0, Obj.ro);\n"
"	}\n"
"	else if(k == MSG_PRESETS)\n"
"	{\n"
"		AddPresets(Obj.v);\n"
"	}\n"
"	else if(k == MSG_COUNTERS)\n"
"	{\n"
"		ProcessCounters(Obj.v);\n"
"	}\n"
"	else\n"
"	{\n"
"		console.log(\'hest!\');\n"
"	}\n"
"\n"
"}\n"
"function WSError()\n"
"{\n"
"	console.log(\'WSError\');\n"
"}\n"
"function WSClose()\n"
"{\n"
"	console.log(\'WSClose\');\n"
"	WSIsOpen = 0;\n"
"	FilterInputDiv.style[\'display\'] = \'none\';\n"
"}\n"
"function WSSendMessage(msgid)\n"
"{\n"
"	if(WSIsOpen)\n"
"	{\n"
"		var str = \'\' + msgid;\n"
"		WSSend++;\n"
"		WSSendBytes += str.length;\n"
"		WS.send(str);\n"
"	}\n"
"	else\n"
"	{\n"
"		if(msgid[0] == \'c\')\n"
"		{\n"
"			console.log(\'failing to send \' + msgid);\n"
"		}\n"
"	}\n"
"}\n"
"\n"
"\n"
"function Connect()\n"
"{\n"
"	if(WS && (WS.readyState == 1 || WS.readyState == 0))\n"
"	{\n"
"		WSConnected = WS.readyState == 1;\n"
"		WSFail = 0;\n"
"		WSSeconds = 0;\n"
"	}\n"
"	else\n"
"	{\n"
"		WSConnected = 0;\n"
"		WSSeconds = (new Date() - WSOpenTime);\n"
"		if(!WS || WSSeconds > 2000)\n"
"		{\n"
"			if(WS)\n"
"			{\n"
"				WS.close();\n"
"				WS = null;\n"
"			}\n"
"			WSOpenTime = new Date();\n"
"			WSPath = \"ws://\" + WSHost + \":\" + WSPort + \"/ws\";\n"
"			SetMessage(\'Connecting to \' + WSPath,5 * 1000);\n"
"			WS = new WebSocket(WSPath);\n"
"			WS.onopen = WSOpen;\n"
"			WS.onmessage = WSMessage;\n"
"			WS.onerror = WSError;\n"
"			WS.onclose = WSClose;\n"
"			WSFail = 0;\n"
"		}\n"
"		else\n"
"		{\n"
"			WSFail++;\n"
"		}\n"
"	}\n"
"	RequestDraw();\n"
"}\n"
"\n"
"\n"
"function MouseDragPan()\n"
"{\n"
"	return MouseDragButton == 1 || MouseDragKeyShift;\n"
"}\n"
"function MouseDragSelectRange()\n"
"{\n"
"	return MouseDragState == MouseDragMove && (MouseDragButton == 3 || (MouseDragKeyShift&&MouseDragKeyCtrl));\n"
"}\n"
"\n"
"function MouseHandleDrag()\n"
"{\n"
"	if(MouseDragTarget == CanvasDetailedView)\n"
"	{\n"
"		if(SubMenuActive == -1)\n"
"		{\n"
"			if(MouseDragSelectRange() && SubMenuActive == -1)\n"
"			{\n"
"				var xStart = MouseDragXStart;\n"
"				var xEnd = MouseDragX;\n"
"				if(xStart > xEnd)\n"
"				{\n"
"					var Temp = xStart;\n"
"					xStart = xEnd;\n"
"					xEnd = Temp;\n"
"				}\n"
"				if(xEnd - xStart > 1)\n"
"				{\n"
"					MouseDragActiveXStart = xStart;\n"
"					MouseDragActiveXEnd = xEnd;\n"
"				}\n"
"			}\n"
"			else if(MouseDragPan())\n"
"			{\n"
"				var X = MouseDragX - MouseDragXLast;\n"
"				var Y = MouseDragY - MouseDragYLast;\n"
"				if(X && MouseDragActiveXStart < MouseDragActiveXEnd)\n"
"				{\n"
"					MouseDragActiveXStart += X;\n"
"					MouseDragActiveXEnd += X;\n"
"				}\n"
"			}\n"
"			if(Settings.ViewActive == VIEW_BAR)\n"
"			{\n"
"				if(MouseDragKeyShift || MouseDragButton == 1)\n"
"				{\n"
"					var X = MouseDragX - MouseDragXLast;\n"
"					var Y = MouseDragY - MouseDragYLast;\n"
"					nOffsetBarsY -= Y;\n"
"					nOffsetBarsX -= X;\n"
"					if(nOffsetBarsY < 0)\n"
"					{\n"
"						nOffsetBarsY = 0;\n"
"					}\n"
"					if(nOffsetBarsX < 0)\n"
"					{\n"
"						nOffsetBarsX = 0;\n"
"					}\n"
"				}\n"
"			}\n"
"			if(Settings.ViewActive == VIEW_COUNTERS)\n"
"			{\n"
"				if(MouseDragKeyShift || MouseDragButton == 1)\n"
"				{\n"
"					var Y = MouseDragY - MouseDragYLast;\n"
"					nOffsetCountersY -= Y;\n"
"					if(nOffsetCountersY < 0)\n"
"					{\n"
"						nOffsetCountersY = 0;\n"
"					}\n"
"				}\n"
"			}\n"
"		}\n"
"		else if(SubMenuActive == SubMenuTimers || SubMenuActive == SubMenuGroup)\n"
"		{\n"
"			if(MouseDragKeyShift || MouseDragButton == 1)\n"
"			{\n"
"				var Y = MouseDragY - MouseDragYLast;\n"
"				if(SubMenuActive == SubMenuTimers)\n"
"				{\n"
"					nOffsetMenuTimers -= Y;\n"
"					if(nOffsetMenuTimers < 0)\n"
"					{\n"
"						nOffsetMenuTimers = 0;\n"
"					}\n"
"				}\n"
"				else\n"
"				{\n"
"					nOffsetMenuGroup -= Y;\n"
"					if(nOffsetMenuGroup < 0)\n"
"					{\n"
"						nOffsetMenuGroup = 0;\n"
"					}\n"
"				}\n"
"			}\n"
"		}\n"
"	}\n"
"	MouseDragXLast = MouseDragX;\n"
"	MouseDragYLast = MouseDragY;	\n"
"}\n"
"function MouseHandleDragEnd()\n"
"{\n"
"	if(MouseDragTarget == CanvasDetailedView)\n"
"	{\n"
"\n"
"	}\n"
"}\n"
"\n"
"function MouseHandleDragClick()\n"
"{\n"
"	if(SubMenuActive == -1)\n"
"	{	\n"
"		if(nHoverCounter != -1)\n"
"		{\n"
"			if(TimerArray[nHoverCounter].firstchild != -1)\n"
"			{\n"
"				TimerArray[nHoverCounter].closed = !TimerArray[nHoverCounter].closed;\n"
"			}\n"
"			else\n"
"			{\n"
"				TimerArray[nHoverCounter].Expanded = !TimerArray[nHoverCounter].Expanded;\n"
"			}\n"
"			Draw(1);\n"
"		}\n"
"	}\n"
"}\n"
"\n"
"function MapMouseButton(Event)\n"
"{\n"
"	if(event.button == 1 || event.which == 1)\n"
"	{\n"
"		return 1;\n"
"	}\n"
"	else if(event.button == 3 || event.which == 3)\n"
"	{\n"
"		return 3;\n"
"	}\n"
"	else\n"
"	{\n"
"		return 0;\n"
"	}\n"
"}\n"
"\n"
"function MouseDragReset()\n"
"{\n"
"	MouseDragState = MouseDragOff;\n"
"	MouseDragTarget = 0;\n"
"	MouseDragKeyShift = 0;\n"
"	MouseDragKeyCtrl = 0;\n"
"	MouseDragButton = 0;\n"
"}\n"
"function MouseDragKeyUp()\n"
"{\n"
"	if((MouseDragKeyShift && !KeyShiftDown) || (MouseDragKeyCtrl && !KeyCtrlDown))\n"
"	{\n"
"		MouseHandleDragEnd();\n"
"		MouseDragReset();\n"
"	}\n"
"}\n"
"function MouseDrag(Source, Event)\n"
"{\n"
"	if(Source == MouseDragOff || (MouseDragTarget && MouseDragTarget != Event.target))\n"
"	{\n"
"		MouseDragReset();\n"
"		return;\n"
"	}\n"
"\n"
"	var LocalRect = Event.target.getBoundingClientRect();\n"
"	MouseDragX = Event.clientX - LocalRect.left;\n"
"	MouseDragY = Event.clientY - LocalRect.top;\n"
"	if(MouseDragState == MouseDragMove)\n"
"	{\n"
"		var dx = Math.abs(MouseDragX - MouseDragXStart);\n"
"		var dy = Math.abs(MouseDragY - MouseDragYStart);\n"
"		if((Source == MouseDragUp && MapMouseButton(Event) == MouseDragButton) ||\n"
"			(MouseDragKeyCtrl && !KeyCtrlDown) ||\n"
"			(MouseDragKeyShift && !KeyShiftDown))\n"
"		{\n"
"			MouseHandleDragEnd();\n"
"			MouseDragReset();\n"
"			return;\n"
"		}\n"
"		else\n"
"		{\n"
"			MouseHandleDrag();\n"
"		}\n"
"	}\n"
"	else if(MouseDragState == MouseDragOff)\n"
"	{\n"
"		if(Source == MouseDragDown || KeyShiftDown || KeyCtrlDown)\n"
"		{\n"
"			MouseDragTarget = Event.target;\n"
"			MouseDragButton = MapMouseButton(Event);\n"
"			MouseDragState = MouseDragDown;\n"
"			MouseDragXStart = MouseDragX;\n"
"			MouseDragYStart = MouseDragY;\n"
"			MouseDragKeyCtrl = 0;\n"
"			MouseDragKeyShift = 0;\n"
"\n"
"			if(KeyShiftDown || KeyCtrlDown)\n"
"			{\n"
"				MouseDragKeyShift = KeyShiftDown;\n"
"				MouseDragKeyCtrl = KeyCtrlDown;\n"
"				MouseDragState = MouseDragMove;\n"
"			}\n"
"		}\n"
"	}\n"
"	else if(MouseDragState == MouseDragDown)\n"
"	{\n"
"		if(Source == MouseDragUp)\n"
"		{\n"
"			MouseHandleDragClick();\n"
"			MouseDragReset();\n"
"		}\n"
"		else if(Source == MouseDragMove)\n"
"		{\n"
"			var dx = Math.abs(MouseDragX - MouseDragXStart);\n"
"			var dy = Math.abs(MouseDragY - MouseDragYStart);\n"
"			if(dx+dy>1)\n"
"			{\n"
"				MouseDragState = MouseDragMove;\n"
"			}\n"
"		}\n"
"	}\n"
"	MouseDragXLast = MouseDragX;\n"
"	MouseDragYLast = MouseDragY;\n"
"}\n"
"\n"
"\n"
"function MouseMove(evt)\n"
"{\n"
"    evt.preventDefault();\n"
"	var rect = evt.target.getBoundingClientRect();\n"
"	var x = evt.clientX - rect.left;\n"
"	var y = evt.clientY - rect.top;\n"
"	MouseX = x;\n"
"	MouseY = y;\n"
"	MouseMoveTime = new Date();\n"
"    MouseDrag(MouseDragMove, evt);\n"
"    RequestDraw();\n"
"}\n"
"\n"
"\n"
"function MouseSortClick()\n"
"{\n"
"	if(SubMenuActive == -1)\n"
"	{\n"
"		if(SortColumnMouseOverNext)\n"
"		{\n"
"			if(SortColumnMouseOverNext == Settings.SortColumnMouseOver)\n"
"			{\n"
"				Settings.SortColumnOrderFlip =  1 - Settings.SortColumnOrderFlip;\n"
"			}\n"
"			else\n"
"			{\n"
"				Settings.SortColumnOrderFlip = 0;\n"
"			}\n"
"\n"
"			Settings.SortColumnMouseOver = SortColumnMouseOverNext;\n"
"			SortColumnMouseOverNext = null;\n"
"			if(Settings.SortColumnMouseOver == StrAverage)\n"
"			{\n"
"				Settings.SortColumn = 1;\n"
"			}\n"
"			else if(Settings.SortColumnMouseOve";

const size_t g_MicroProfileHtmlLive_begin_2_size = sizeof(g_MicroProfileHtmlLive_begin_2);
const char g_MicroProfileHtmlLive_begin_3[] =
"r == StrMax)\n"
"			{\n"
"				Settings.SortColumn = 2;\n"
"			}\n"
"			else if(Settings.SortColumnMouseOver == StrTotal)\n"
"			{\n"
"				Settings.SortColumn = 3;\n"
"			}			\n"
"			else if(Settings.SortColumnMouseOver == StrMin)\n"
"			{\n"
"				Settings.SortColumn = 4;\n"
"			}\n"
"			else if(Settings.SortColumnMouseOver == StrSpike)\n"
"			{\n"
"				Settings.SortColumn = 5;\n"
"			}\n"
"			else if(Settings.SortColumnMouseOver == StrCallAverage)\n"
"			{\n"
"				Settings.SortColumn = 6;\n"
"			}\n"
"			else if(Settings.SortColumnMouseOver == StrCount)\n"
"			{\n"
"				Settings.SortColumn = 7;\n"
"			}\n"
"			else if(Settings.SortColumnMouseOver == StrExclAverage)\n"
"			{\n"
"				Settings.SortColumn = 8;\n"
"			}\n"
"			else if(Settings.SortColumnMouseOver == StrExclMax)\n"
"			{\n"
"				Settings.SortColumn = 9;\n"
"			}\n"
"			else if(Settings.SortColumnMouseOver == StrGroup)\n"
"			{\n"
"				Settings.SortColumn = -1;\n"
"			}\n"
"			else if(Settings.SortColumnMouseOver == StrTimer)\n"
"			{\n"
"				Settings.SortColumn = -2;\n"
"			}\n"
"		}\n"
"	}\n"
"}\n"
"\n"
"\n"
"function MouseButton(bPressed, evt)\n"
"{\n"
"    evt.preventDefault();\n"
"    MouseReleased = !bPressed;\n"
"	MouseDrag(bPressed ? MouseDragDown : MouseDragUp, evt);\n"
"	if(!bPressed)\n"
"		MouseSortClick();\n"
"    RequestDraw();\n"
"}\n"
"\n"
"function MouseOut(evt)\n"
"{\n"
"	MouseDrag(MouseDragOff, evt);\n"
"	KeyCtrlDown = 0;\n"
"	KeyShiftDown = 0;\n"
"	// MouseDragButton = 0;\n"
"	// nHoverToken = -1;\n"
"	// RangeCpu = RangeInit();\n"
"}\n"
"\n"
"function MouseWheel(e)\n"
"{\n"
"//     var e = window.event || e;\n"
"//     var delta = (e.wheelDelta || e.detail * (-120));\n"
"//     ZoomGraph((-4 * delta / 120.0) | 0);\n"
"//     Draw(1);\n"
"}\n"
"\n"
"function KeyUp(evt)\n"
"{\n"
"	var k = evt.keyCode;\n"
"	console.log(\'key is \' + k);\n"
"	var InputActive = SubMenuActive == SubMenuTimers || SubMenuActive == SubMenuGroup;\n"
"	if(!InputActive)\n"
"	{\n"
"		if(k == 220)\n"
"		{\n"
"			ProfileMode = !ProfileMode;\n"
"		}\n"
"		if(k == 191)\n"
"		{\n"
"			WSPort++;\n"
"			if(WSPort > 1338+2)\n"
"			{\n"
"				WSPort = 1338;\n"
"			}\n"
"			if(WS)\n"
"			{\n"
"				WS.close();\n"
"				WS = null;\n"
"			}\n"
"		}\n"
"		if(k == 32)\n"
"		{\n"
"			if(0) //for debugging.\n"
"			{\n"
"				console.log(\"FrameData =\");\n"
"				console.log(JSON.stringify(FrameData));\n"
"				console.log(\"TimerArray =\");\n"
"				console.log(JSON.stringify(TimerArray));\n"
"			}\n"
"			WSSendMessage(\"f\");\n"
"		}\n"
"		if(k == 88)\n"
"		{\n"
"			ToggleView();\n"
"		}\n"
"		if(k == 13)\n"
"		{\n"
"			Capture();\n"
"		}\n"
"		if(k == 72)\n"
"		{\n"
"			ShowHelp(0, 1);\n"
"		}\n"
"\n"
"\n"
"	}\n"
"	if(k == 27)\n"
"	{\n"
"		if(FilterInput.value.trim() != \"\")\n"
"		{\n"
"			FilterInput.value = \"\";\n"
"		}\n"
"		else\n"
"		{\n"
"			EnableMenu(-1);\n"
"		}\n"
"\n"
"		MouseDragActiveXStart = MouseDragActiveXEnd = -1;\n"
"		Settings.SortColumn = 0;\n"
"		Settings.SortColumnMouseOver = \"\";\n"
"		ShowHelp(0);\n"
"	}\n"
"	if(k == 192)\n"
"	{\n"
"		Settings.ViewCompressed = Settings.ViewCompressed ? 0 : 1;\n"
"		ResizeCanvas();\n"
"	}\n"
"\n"
"	if(evt.keyCode == 17)\n"
"	{\n"
"		KeyCtrlDown = 0;\n"
"		MouseDragKeyUp();\n"
"	}\n"
"	if(evt.keyCode == 16)\n"
"	{\n"
"		KeyShiftDown = 0;\n"
"		MouseDragKeyUp();\n"
"	}\n"
"}\n"
"\n"
"function KeyDown(evt)\n"
"{\n"
"	if(evt.keyCode == 17)\n"
"	{\n"
"		KeyCtrlDown = 1;\n"
"		MouseDragKeyUp();\n"
"	}\n"
"	if(evt.keyCode == 16)\n"
"	{\n"
"		KeyShiftDown = 1;\n"
"		MouseDragKeyUp();\n"
"	}\n"
"}\n"
"\n"
"\n"
"function SetupEvents()\n"
"{\n"
"	var mousewheelevt = (/Firefox/i.test(navigator.userAgent)) ? \"DOMMouseScroll\" : \"mousewheel\" //FF doesn\'t recognize mousewheel as of \n"
"	CanvasDetailedView.addEventListener(\'mousemove\', MouseMove, false);\n"
"	CanvasDetailedView.addEventListener(\'mousedown\', function(evt) { MouseButton(true, evt); });\n"
"	CanvasDetailedView.addEventListener(\'mouseup\', function(evt) { MouseButton(false, evt); } );\n"
"	CanvasDetailedView.addEventListener(\'mouseout\', MouseOut);\n"
"	CanvasDetailedView.addEventListener(\"contextmenu\", function (e) { e.preventDefault(); }, false);\n"
"	CanvasDetailedView.addEventListener(mousewheelevt, MouseWheel, false);\n"
"	window.addEventListener(\'keydown\', KeyDown);\n"
"	window.addEventListener(\'keyup\', KeyUp);\n"
"	window.addEventListener(\'resize\', ResizeCanvas, false);\n"
"}\n"
"\n"
"function DrawToolTip(StringArray, Canvas, x, y)\n"
"{\n"
"	if(!ShowMenu())\n"
"	{\n"
"		return;\n"
"	}\n"
"	var context = Canvas.getContext(\'2d\');\n"
"	context.font = Font;\n"
"	var WidthArray = Array(StringArray.length);\n"
"	var nMaxWidth = 0;\n"
"	var nHeight = 0;\n"
"	for(var i = 0; i < StringArray.length; i += 2)\n"
"	{\n"
"		var nWidth0 = context.measureText(StringArray[i]).width;\n"
"		var nWidth1 = context.measureText(StringArray[i+1]).width;\n"
"		var nSum = nWidth0 + nWidth1;\n"
"		WidthArray[i] = nWidth0;\n"
"		WidthArray[i+1] = nWidth1;\n"
"		if(nSum > nMaxWidth)\n"
"		{\n"
"			nMaxWidth = nSum;\n"
"		}\n"
"		nHeight += BoxHeight;\n"
"	}\n"
"	nMaxWidth += 15;\n"
"	//bounds check.\n"
"	x = Math.max(0, x - 10 - nMaxWidth);\n"
"	var CanvasRect = Canvas.getBoundingClientRect();\n"
"	if(y + nHeight > CanvasRect.height)\n"
"	{\n"
"		y = CanvasRect.height - nHeight;\n"
"		x += 20;\n"
"	}\n"
"	if(x + nMaxWidth > CanvasRect.width)\n"
"	{\n"
"		x = CanvasRect.width - nMaxWidth;\n"
"	}\n"
"\n"
"	context.fillStyle = \'black\';\n"
"	context.fillRect(x-1, y, nMaxWidth+2, nHeight);\n"
"	context.fillStyle = \'white\';\n"
"\n"
"	var XPos = x;\n"
"	var XPosRight = x + nMaxWidth;\n"
"	var YPos = y + BoxHeight-2;\n"
"	for(i = 0; i < StringArray.length; i += 2)\n"
"	{\n"
"		context.fillText(StringArray[i], XPos, YPos);\n"
"		context.fillText(StringArray[i+1], XPosRight - WidthArray[i+1], YPos);\n"
"		YPos += BoxHeight;\n"
"	}\n"
"}\n"
"\n"
"function DrawPlotf(Canvas)\n"
"{\n"
"	return;\n"
"	var context = Canvas.getContext(\'2d\');\n"
"	context.font = Font;\n"
"	var WidthArray = Array(PlotfArray.length);\n"
"	var nMaxWidth = 0;\n"
"	var nHeight = 0;\n"
"\n"
"	context.font = Font;\n"
"	for(i = 0; i < PlotfArray.length; i++)\n"
"	{\n"
"		var nWidth = context.measureText(PlotfArray[i]).width;\n"
"		WidthArray[i] = nWidth;\n"
"		if(nWidth > nMaxWidth)\n"
"		{\n"
"			nMaxWidth = nWidth;\n"
"		}\n"
"		nHeight += BoxHeight;\n"
"	}\n"
"	nMaxWidth += 15;\n"
"	var x = 0;\n"
"	var y = 0;\n"
"\n"
"	context.fillStyle = \'black\';\n"
"	context.fillRect(x-1, y, nMaxWidth+2, nHeight);\n"
"	context.fillStyle = \'white\';\n"
"\n"
"	var XPos = x;\n"
"	var XPosRight = x + nMaxWidth;\n"
"	var YPos = y + BoxHeight-2;\n"
"	for(i = 0; i < PlotfArray.length; i++)\n"
"	{\n"
"		context.fillText(PlotfArray[i], XPos, YPos);\n"
"		YPos += BoxHeight;\n"
"	}\n"
"}\n"
"\n"
"\n"
"function ShiftRight10(v)\n"
"{\n"
"	if(v > 1024)\n"
"	{\n"
"		return v / 1024.0;\n"
"	}\n"
"	else\n"
"	{\n"
"		return v >> 10;\n"
"	}\n"
"}\n"
"\n"
"function FormatCounter(Format, Counter)\n"
"{\n"
"	if(!Counter)\n"
"	{\n"
"		return \'0\';\n"
"	}\n"
"	var Negative = 0;\n"
"	if(Counter < 0)\n"
"	{\n"
"		Counter = -Counter;\n"
"		Negative = 1;\n"
"		if(Counter < 0) // handle INT_MIN\n"
"		{\n"
"			Counter = -(Counter+1);\n"
"			if(Counter < 0)\n"
"			{\n"
"				return \'?\';\n"
"			}\n"
"		}\n"
"	}\n"
"	var str = Negative ? \'-\' :\'\' ;\n"
"	if(Format == FormatCounterDefault)\n"
"	{\n"
"		var Seperate = 0;\n"
"		var result = \'\';\n"
"		while (Counter)\n"
"		{\n"
"			if (Seperate)\n"
"			{\n"
"				result += \'.\';\n"
"			}\n"
"			Seperate = 1;\n"
"			for (var i = 0; Counter && i < 3; ++i)\n"
"			{\n"
"				var Digit = Math.floor(Counter % 10);\n"
"				Counter = Math.floor(Counter / 10);\n"
"				result += \'\' + Digit;\n"
"			}\n"
"		}\n"
"\n"
"		for(var i = 0; i < result.length; ++i)\n"
"		{\n"
"			str += result[result.length-1-i];\n"
"		}\n"
"		return str;\n"
"	}\n"
"	else if(Format == FormatCounterBytes)\n"
"	{\n"
"		var Shift = 0;\n"
"		var Divisor = 1;\n"
"		var CountShifted = ShiftRight10(Counter);\n"
"		while(CountShifted)\n"
"		{\n"
"			Divisor <<= 10;\n"
"			CountShifted = ShiftRight10(CountShifted);\n"
"			Shift++;\n"
"		}\n"
"		if(Shift)\n"
"		{\n"
"			return str + (Counter / Divisor).toFixed(2) + \'\' + FormatCounterBytesExt[Shift];\n"
"		}\n"
"		else\n"
"		{\n"
"			return str + Counter.toFixed(2) + \'\' + FormatCounterBytesExt[0];\n"
"		}\n"
"	}\n"
"	return \'?\'\n"
"}\n"
"function DrawCounterView(View, LocalMouseX, LocalMouseY, SubIndex)\n"
"{\n"
"	var TimerMap = FrameData.TimerMap;\n"
"	if(!TimerMap)\n"
"		return;\n"
"\n"
"\n"
"	ProfileEnter(\"DrawCounterView\");\n"
"\n"
"	var Canvas = View.Canvas[View.BackBuffer];\n"
"	var context = Canvas.getContext(\'2d\');\n"
"	context.clearRect(0, 0, View.w, View.h);\n"
"\n"
"\n"
"\n"
"	var Height = BoxHeight;\n"
"	var Width = nWidth;\n"
"	var nTotalRows = CounterArray.length;\n"
"	var nTotalRowPixels = nTotalRows * Height;\n"
"	var nFrameRows = nHeight - BoxHeight;\n"
"	if(nOffsetCountersY + nFrameRows > nTotalRowPixels && nTotalRowPixels > nFrameRows)\n"
"	{\n"
"		nOffsetCountersY = nTotalRowPixels - nFrameRows;\n"
"	}\n"
"	var CounterWidth = 150;\n"
"	var Y = -nOffsetCountersY + BoxHeight;\n"
"	var X = 0;\n"
"	var nColorIndex = 0;\n"
"	context.fillStyle = \'white\';\n"
"	context.font = Font;\n"
"	var bMouseIn = 0;\n"
"	function DrawHeaderSplitSingle(Header, Width)\n"
"	{\n"
"		context.fillStyle = \'white\';\n"
"		context.fillText(Header, X, Height-FontAscent);\n"
"		X += Width;\n"
"		context.fillStyle = nBackColorOffset;\n"
"		context.fillRect(X-3, 0, 1, nHeight);\n"
"	}\n"
"	function DrawHeaderSplitSingleRight(Header, Width)\n"
"	{\n"
"		X += Width;\n"
"		context.fillStyle = \'white\';\n"
"		context.textAlign  = \'right\';\n"
"		context.fillText(Header, X - FontWidth, Height-FontAscent);\n"
"		context.fillStyle = nBackColorOffset;\n"
"		context.fillRect(X, 0, 1, nHeight);\n"
"		context.textAlign  = \'left\';\n"
"	}\n"
"	var TimerLen = 6;\n"
"	var TimerWidth = TimerLen * FontWidth;\n"
"	nHoverCounter = -1;\n"
"	function CounterIndent(Level)\n"
"	{\n"
"		return Level * 4 * FontWidth;\n"
"	}\n"
"	function Max(a, b)\n"
"	{\n"
"		return a > b ? a : b;\n"
"	}\n"
"\n"
"	function DrawCounterRecursive(Index)\n"
"	{\n"
"		var Counter = TimerArray[Index];\n"
"		if(Counter.idtype == TYPE_COUNTER)\n"
"		{\n"
"			var Indent = CounterIndent(Counter.depth-1);\n"
"			var X = 0;\n"
"			nColorIndex = 1-nColorIndex;\n"
"			var HeightExpanded = Counter.Expanded ? Height * 5 : Height\n"
"\n"
"			bMouseIn = LocalMouseY >= Y && LocalMouseY < Y + HeightExpanded;\n"
"			if(bMouseIn)\n"
"			{\n"
"				nHoverCounter = Index;\n"
"			}\n"
"			var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
"			context.fillStyle = bgcolor;\n"
"			context.fillRect(0, Y, Width, HeightExpanded);\n"
"			context.fillStyle = \'white\';\n"
"			var c = Counter.closed ? \'*\' : \' \';\n"
"			context.fillText(c + Counter.name, Indent, Y+Height-FontAscent);\n"
"			X += CounterNameWidth;\n"
"			X += CounterValueWidth - FontWidth;\n"
"			context.textAlign = \'right\';\n"
"			context.fillText(Counter.formatted, X, Y+Height-FontAscent);\n"
"			context.textAlign = \'left\';\n"
"			X += FontWidth * 4;\n"
"			var Y0 = Y + 1;\n"
"			if(Counter.limit != 0)\n"
"			{\n"
"				context.fillText(Counter.formattedlimit, X, Y+Height-FontAscent);\n"
"				X += CounterLimitWidth;\n"
"				var X0 = X + 1;\n"
"				context.fillStyle = \'white\';\n"
"				context.fillRect(X0, Y0, Counter.boxprc * (CounterWidth-2), Height-2);\n"
"				context.fillStyle = bgcolor;\n"
"				context.fillRect(X0+1, Y0+1, Counter.boxprc * (CounterWidth-4), Height-4);\n"
"				context.fillStyle = \'cyan\';\n"
"				context.fillRect(X0+1, Y0+1, Counter.counterprc * (CounterWidth-4), Height-4);\n"
"				X += CounterWidth + 10;\n"
"			}\n"
"			else\n"
"			{\n"
"				X += CounterLimitWidth;\n"
"				X += CounterWidth + 10;\n"
"			}\n"
"			\n"
"			if(Counter.minvalue != Counter.maxvalue)\n"
"			{\n"
"				var CounterHistory = Counter.counterhistory;\n"
"				var Prc = CounterHistory.prc;\n"
"				context.fillStyle = \'cyan\';\n"
"				context.strokeStyle = \'cyan\';\n"
"				context.globalAlpha = 0.5;\n"
"				context.beginPath();\n"
"				var x = X;\n"
"				var YBase = Y0 + HeightExpanded-1;\n"
"				var YOffset = -(HeightExpanded-2);\n"
"\n"
"				context.moveTo(X, Y0);\n"
"				for(var i = 0; i < Prc.length; ++i)\n"
"				{\n"
"					context.moveTo(x, YBase);\n"
"					context.lineTo(x, YBase + Prc[i] * YOffset);\n"
"					x += 1;\n"
"				}\n"
"				context.stroke();\n"
"\n"
"				x = X;\n"
"				context.globalAlpha = 1.0;\n"
"				context.beginPath();\n"
"				context.moveTo(X, YBase);\n"
"\n"
"				for(var i = 0; i < Prc.length; ++i)\n"
"				{\n"
"					context.lineTo(x, YBase + Prc[i] * YOffset);\n"
"					x += 1;\n"
"				}\n"
"				context.stroke();\n"
"				if(bMouseIn)\n"
"				{\n"
"					var MouseGraphX = Math.floor(LocalMouseX - X);\n"
"					if(MouseGraphX >= 0 && MouseGraphX < CounterHistory.history.length)\n"
"					{\n"
"						context.fillStyle = \'white\';\n"
"						var Formatted = FormatCounter(Counter.format, CounterHistory.history[MouseGraphX]);\n"
"						context.fillText(Formatted, X, Y+Height-FontAscent);\n"
"					}\n"
"					context.strokeStyle = \'orange\';\n"
"					context.beginPath();\n"
"					var CrossX = X + MouseGraphX;\n"
"					var CrossY = YBase + Prc[MouseGraphX] * YOffset;\n"
"					context.moveTo(CrossX-2, CrossY-2);\n"
"					context.lineTo(CrossX+2, CrossY+2);\n"
"					context.moveTo(CrossX+2, CrossY-2);\n"
"					context.lineTo(CrossX-2, CrossY+2);\n"
"					context.stroke();\n"
"\n"
"				}\n"
"				X += Prc.length + 5;\n"
"				context.fillStyle = \'white\';\n"
"				context.fillText( FormatCounter(Counter.format, Counter.minvalue), X, Y + Height - FontAscent);\n"
"				X += CounterWidth + 5;\n"
"				context.fillText( FormatCounter(Counter.format, Counter.maxvalue), X, Y + Height - FontAscent);\n"
"				X += CounterWidth + 5;\n"
"			}\n"
"			Y += HeightExpanded;\n"
"		}\n"
"\n"
"		if(Index == 0 || (!Counter.closed && Counter.idtype == TYPE_COUNTER))\n"
"		{\n"
"			var ChildIndex = Counter.firstchild;\n"
"			while(ChildIndex != -1)\n"
"			{\n"
"				DrawCounterRecursive(ChildIndex);\n"
"				ChildIndex = TimerArray[ChildIndex].sibling;\n"
"			}\n"
"		}\n"
"	}\n"
"\n"
"	DrawCounterRecursive(0);\n"
"\n"
"	X = 0;\n"
"	context.fillStyle = nBackColorOffset;\n"
"	context.fillRect(0, 0, Width, Height);\n"
"	context.fillStyle = \'white\';\n"
"	DrawHeaderSplitSingle(\'Name\', CounterNameWidth);\n"
"	DrawHeaderSplitSingleRight(\'Value\', CounterValueWidth + (FontWidth+1));\n"
"	DrawHeaderSplitSingle(\'Limit\', CounterLimitWidth + CounterWidth + 3 * (FontWidth+1));\n"
"	ProfileLeave();\n"
"}\n"
"\n"
"function ShowHelp(Show, Toggle)\n"
"{\n"
"	var HelpWindow = document.getElementById(\'helpwindow\');\n"
"	if(Toggle)\n"
"	{\n"
"		if(HelpWindow.style[\'display\'] == \'block\')\n"
"		{\n"
"			HelpWindow.style[\'display\'] = \'none\';\n"
"		}\n"
"		else\n"
"		{\n"
"			HelpWindow.style[\'display\'] = \'block\';			\n"
"		}\n"
"	}\n"
"	else\n"
"	{\n"
"		if(Show)\n"
"		{\n"
"			HelpWindow.style[\'display\'] = \'block\';\n"
"		}\n"
"		else\n"
"		{\n"
"			HelpWindow.style[\'display\'] = \'none\';\n"
"		}\n"
"	}\n"
"}\n"
"\n"
"function ParseUrl()\n"
"{\n"
"	var path = window.location.pathname;\n"
"	var idx = path.indexOf(\'/\');\n"
"	if(idx < 0)\n"
"		return;\n"
"	var StrCommand = path.substring(idx+1);\n"
"	idx = StrCommand.indexOf(\'/\');\n"
"	if(idx < 0)\n"
"		return;\n"
"	var StrSettings = StrCommand.substring(idx+1);\n"
"	PresetToLoad = StrSettings;\n"
"	PresetToLoadRO = StrCommand[0] == \'b\';\n"
"}\n"
"\n"
"ParseUrl();\n"
"ResizeCanvas();\n"
"SetupEvents();\n"
"InitMenu();\n"
"setInterval(Connect, 100);\n"
"RequestDraw();\n"
"\n"
"\n"
"</script>\n"
"</body>\n"
"</html>      \n"
"";

const size_t g_MicroProfileHtmlLive_begin_3_size = sizeof(g_MicroProfileHtmlLive_begin_3);
const char* g_MicroProfileHtmlLive_begin[] = {
&g_MicroProfileHtmlLive_begin_0[0],
&g_MicroProfileHtmlLive_begin_1[0],
&g_MicroProfileHtmlLive_begin_2[0],
&g_MicroProfileHtmlLive_begin_3[0],
};
size_t g_MicroProfileHtmlLive_begin_sizes[] = {
sizeof(g_MicroProfileHtmlLive_begin_0),
sizeof(g_MicroProfileHtmlLive_begin_1),
sizeof(g_MicroProfileHtmlLive_begin_2),
sizeof(g_MicroProfileHtmlLive_begin_3),
};
size_t g_MicroProfileHtmlLive_begin_count = 4;
const char* g_MicroProfileHtmlLive_end[] = {
""};
size_t g_MicroProfileHtmlLive_end_sizes[] = {
0};
size_t g_MicroProfileHtmlLive_end_count = 0;
#endif //MICROPROFILE_EMBED_HTML

///end file generated from  microprofilelive.html
