Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
folium-app
GitHub Repository: folium-app/Folium
Path: blob/a-new-beginning/SharedDependencies/Sources/microprofile/include/microprofile_html.h
2 views
1
///start file generated from microprofile.html
2
#ifdef MICROPROFILE_EMBED_HTML
3
const char g_MicroProfileHtml_begin_0[] =
4
"<!DOCTYPE HTML>\n"
5
"<html>\n"
6
"<head>\n"
7
"<title>MicroProfile Capture</title>\n"
8
"<style>\n"
9
"/* about css: http://bit.ly/1eMQ42U */\n"
10
"body {margin: 0px;padding: 0px; font: 12px Courier New;background-color:#343434; color:white;overflow:hidden;}\n"
11
"ul {list-style-type: none;margin: 0;padding: 0;}\n"
12
"li{display: inline; float:left;border:5px; position:relative;text-align:center;}\n"
13
"a {\n"
14
" float:left;\n"
15
" text-decoration:none;\n"
16
" display: inline;\n"
17
" text-align: center;\n"
18
" padding:5px;\n"
19
" padding-bottom:0px;\n"
20
" padding-top:0px;\n"
21
" color: #FFFFFF;\n"
22
" background-color: #343434;\n"
23
"}\n"
24
"a:hover, a:active{\n"
25
" background-color: #000000;\n"
26
"}\n"
27
"\n"
28
"ul ul {\n"
29
" position:absolute;\n"
30
" left:0;\n"
31
" top:100%;\n"
32
" margin-left:-999em;\n"
33
"}\n"
34
"li:hover ul {\n"
35
" margin-left:0;\n"
36
" margin-right:0;\n"
37
"}\n"
38
"ul li ul{ display:block;float:none;}\n"
39
"ul li ul li{ display:block;float:none;}\n"
40
"li li a{ display:block;float:none;text-align:left;word-break: keep-all;white-space: nowrap;}\n"
41
"#nav li:hover div {margin-left:0;}\n"
42
".dropzone {display:flex;justify-content:center;align-items:center;font-size:50px;position: fixed; top: 0; left: 0; z-index: 9999999999; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5);transition: visibility 175ms, opacity 175ms;}\n"
43
".help {position:absolute;z-index:5;text-align:left;padding:2px;background-color: #313131;width:300px;}\n"
44
".helpstart {position:absolute;z-index:5;text-align:left;padding:2px;background-color: #313131;width:300px;display:none}\n"
45
".root {z-index:1;position:absolute;top:0px;left:0px;}\n"
46
".filterinput0{position:fixed;bottom:10px;left:25px;background-color: #313131}\n"
47
".filterinput1{position:fixed;bottom:10px;left:175px;background-color: #313131}\n"
48
".filterinputsearchdiv{position:fixed; background-color: #313131;display:none;}\n"
49
".filterinputsearchdivmenu{position:absolute; background-color: #313131;display:none;}\n"
50
".filterinputsearch{width:100px;}\n"
51
".filtersearchdiv{position:fixed;top:71px;right:75px; display:block;}\n"
52
".filterinputsearch2{width:100px; display:none}\n"
53
"</style>\n"
54
"</head>\n"
55
"<body style=\"\"> \n"
56
"<input type=\"file\" id=\"file-input\" style=\"display:none\"/>\n"
57
"<div style=\"visibility:hidden; opacity:0\" class=\"dropzone\" ondrop=\"DropHandler(event);\" ondragover=\"DragOverHandler(event);\">drop .html file to compare</div>\n"
58
"<div class=\"filtersearchdiv\" id=\"filtersearchdiv\"><input type=\"text\" id=\"FilterInputSearch2\" class=\"filterinputsearch2\"></div>\n"
59
"<div id=\'filterinput\'>\n"
60
"<div class=\"filterinput0\">Group<br><input type=\"text\" id=\"filtergroup\"></div>\n"
61
"<div class=\"filterinput1\">Timer/Thread<br><input type=\"text\" id=\"filtertimer\"></div>\n"
62
"</div>\n"
63
"<div class=\"filterinputsearchdiv\" id=\"FilterInputDiv\">Filter<br><input type=\"text\" id=\"FilterInput\" class=\"filterinputsearch\"></div>\n"
64
"<div class=\"filterinputsearchdivmenu\" id=\"FilterInputMenuDiv\">Filter<br><input type=\"text\" id=\"FilterInputMenu\" class=\"filterinputsearch\"></div>\n"
65
"<canvas id=\"History\" height=\"70\" style=\"background-color:#343434;margin:0px;padding:0px;\"></canvas>\n"
66
"<canvas id=\"DetailedView\" height=\"200\" style=\"background-color:#343434;margin:0px;padding:0px;\"></canvas>\n"
67
"<canvas id=\"CanvasMenu\" style=\"pointer-events:none;position:absolute;top:0;left:0;margin:0px;padding:0px;zIndex:1\" height=\"500\" width=\"500\"></canvas>\n"
68
"<div class=\"help\" id=\"divFrameInfo\" style=\"display:none;left:20px;top:300px;width:auto;\"></div>\n"
69
"<div class=\"helpstart\" id=\"helpwindow\" style=\"left:20px;top:20px\">\n"
70
"History View:<br>\n"
71
"Click + Drag: Pan View<br>\n"
72
"Right Click + Drag : Zoom on region<br>\n"
73
"Click Frame : Center on frame<br>\n"
74
"<hr>\n"
75
"Main View:<br>\n"
76
"Ctrl + Mouse up/down: Zoom<br>\n"
77
"Mousewheel : Zoom<br>\n"
78
"Right Click + Drag: Select region<br>\n"
79
"Ctrl + Shift + Drag: Select region<br>\n"
80
"Space: Zoom to Selection<br>\n"
81
"Ctrl + Drag: Pan<br>\n"
82
"Click + Drag: Pan<br>\n"
83
"hold alt: Show tooltip from timer view in detailed, detailed in timer<br>\n"
84
"x : Toggle View<br>\n"
85
"\\ : Switch color mode<br>\n"
86
"c : toggle collapse mode<br>\n"
87
"h : hightlight core types(context switch only)<br>\n"
88
"tab : go to filter view<br>\n"
89
"<hr>\n"
90
"Detailed View:<br>\n"
91
"Tab: Go To Worst Instance<br>\n"
92
"Left/Right Arror: Next/Prev Instance<br>\n"
93
"Enter: Search for timer in view<br>\n"
94
"<hr>\n"
95
"Timer Views:<br>\n"
96
"Tab: go to filtering<br>\n"
97
"Esc: Exit &amp; Clear filter\n"
98
"<hr>\n"
99
"<table style=\"width:100%\">\n"
100
"<tr>\n"
101
"<td width=\"50%\" align=\"left\"><a href=\'javascript:void(0)\' onclick=\"ShowHelp(0, 0);\">Close</a></td>\n"
102
"<td width=\"50%\" align=\"right\"><a href=\'javascript:void(0)\' onclick=\"ShowHelp(0, 1);\">Close, Never Show</a></td>\n"
103
"</tr>\n"
104
"</table>\n"
105
"</div>\n"
106
"<script>\n"
107
"function ConvertRgbToHsl(hexTripletColor) //from https://gist.github.com/mjackson/5311256\n"
108
"{\n"
109
" var color = hexTripletColor;\n"
110
" color = color.substring(1);\n"
111
" color = parseInt(color, 16);\n"
112
" var r = ((color >> 16) % 256)/255.0;\n"
113
" var g = ((color >> 8) % 256)/255.0;\n"
114
" var b = ((color >> 0) % 256)/255.0;\n"
115
" var max = Math.max(r, g, b), min = Math.min(r, g, b);\n"
116
" var h, s, l = (max + min) / 2;\n"
117
" if (max == min) {\n"
118
" h = s = 0; // achromatic\n"
119
" }\n"
120
" else\n"
121
" {\n"
122
" var d = max - min;\n"
123
" s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n"
124
"\n"
125
" switch (max)\n"
126
" {\n"
127
" case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n"
128
" case g: h = (b - r) / d + 2; break;\n"
129
" case b: h = (r - g) / d + 4; break;\n"
130
" }\n"
131
" h /= 6;\n"
132
" }\n"
133
" return [ h, s, l ];\n"
134
"}\n"
135
"\n"
136
"function ConvertHslToColor(h, s, l) //from https://gist.github.com/mjackson/5311256\n"
137
"{\n"
138
" var r, g, b;\n"
139
" if (s == 0)\n"
140
" {\n"
141
" r = g = b = l; // achromatic\n"
142
" }\n"
143
" else\n"
144
" {\n"
145
" function hue2rgb(p, q, t)\n"
146
" {\n"
147
" if (t < 0) t += 1;\n"
148
" if (t > 1) t -= 1;\n"
149
" if (t < 1/6) return p + (q - p) * 6 * t;\n"
150
" if (t < 1/2) return q;\n"
151
" if (t < 2/3) return p + (q - p) * (2/3 - t) * 6;\n"
152
" return p;\n"
153
" }\n"
154
" var q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n"
155
" var p = 2 * l - q;\n"
156
" r = hue2rgb(p, q, h + 1/3);\n"
157
" g = hue2rgb(p, q, h);\n"
158
" b = hue2rgb(p, q, h - 1/3);\n"
159
" }\n"
160
" var color = ((r*255)<<16) | ((g*255)<<8) | (b*255);\n"
161
" return \'#\' + (\"000000\" + color.toString(16)).slice(-6);\n"
162
"}\n"
163
"\n"
164
"\n"
165
"function ConvertColorDark(hexTripletColor)\n"
166
"{\n"
167
" var color = hexTripletColor;\n"
168
" color = color.substring(1); // remove #\n"
169
" color = parseInt(color, 16); // convert to integer\n"
170
" // console.log(color.toString(16));\n"
171
" color = (color >> 1);\n"
172
" // console.log(color.toString(16));\n"
173
" color = color & 0x7f7f7f;\n"
174
" // console.log(color.toString(16));\n"
175
" return \'#\' + (\"000000\" + color.toString(16)).slice(-6);\n"
176
"}\n"
177
"function InvertColor(hexTripletColor)\n"
178
"{\n"
179
" var color = hexTripletColor;\n"
180
" color = color.substring(1); // remove #\n"
181
" color = parseInt(color, 16); // convert to integer\n"
182
" var R = ((color >> 16) % 256)/255.0;\n"
183
" var G = ((color >> 8) % 256)/255.0;\n"
184
" var B = ((color >> 0) % 256)/255.0;\n"
185
" var lum = (0.2126*R + 0.7152*G + 0.0722*B);\n"
186
" if(lum < 0.7)\n"
187
" {\n"
188
" return \'#ffffff\';\n"
189
" }\n"
190
" else\n"
191
" {\n"
192
" return \'#333333\';\n"
193
" }\n"
194
"}\n"
195
"function InvertColorIndex(hexTripletColor) {\n"
196
" var color = hexTripletColor;\n"
197
" color = color.substring(1); // remove #\n"
198
" color = parseInt(color, 16); // convert to integer\n"
199
" var R = ((color >> 16) % 256)/255.0;\n"
200
" var G = ((color >> 8) % 256)/255.0;\n"
201
" var B = ((color >> 0) % 256)/255.0;\n"
202
" var lum = (0.2126*R + 0.7152*G + 0.0722*B);\n"
203
" if(lum < 0.7)\n"
204
" {\n"
205
" return 0;\n"
206
" }\n"
207
" else\n"
208
" {\n"
209
" return 1;\n"
210
" }\n"
211
"}\n"
212
"\n"
213
"function MakeGroup(id, name, category, numtimers, isgpu, total, average, max, color)\n"
214
"{\n"
215
" if(color == \"\")\n"
216
" {\n"
217
" color = ColorFromString(name, 40, 50);\n"
218
" }\n"
219
" var cid = GetColorIndex(color);\n"
220
" var group = {\"id\":id, \"name\":name, \"category\":category, \"numtimers\":numtimers, \"isgpu\":isgpu, \"total\": total, \"average\" : average, \"max\" : max, \"cid\":cid};\n"
221
" return group;\n"
222
"}\n"
223
"\n"
224
"function MakeGroupCid(id, name, category, numtimers, isgpu, total, average, max, color, cid)\n"
225
"{\n"
226
" var group = {\"id\":id, \"name\":name, \"category\":category, \"numtimers\":numtimers, \"isgpu\":isgpu, \"total\": total, \"average\" : average, \"max\" : max, \"cid\":cid};\n"
227
" return group;\n"
228
"}\n"
229
"\n"
230
"function MakeTimer(id, name, group, color, colordark, average, max, min, exclaverage, exclmax, callaverage, callcount, total, meta, metaavg, metamax, flags)\n"
231
"{\n"
232
" if(color == \"#000000\")\n"
233
" {\n"
234
" color = ColorFromString(name + \"x\" + group, 40, 50);\n"
235
" colordark = ColorFromString(name + \"x\" + group, 25, 50);\n"
236
" }\n"
237
" var spike = max <= 0 || average <= 0 ? 0 : (100 * max / average);\n"
238
" var cid = GetColorIndex(color);\n"
239
" 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, \"search\":cid, \"flags\":flags};\n"
240
" return timer;\n"
241
"}\n"
242
"\n"
243
"function MakeTimerCid(id, name, group, cid, average, max, min, exclaverage, exclmax, callaverage, callcount, total, meta, metaavg, metamax)\n"
244
"{\n"
245
" var spike = max <= 0 || average <= 0 ? 0 : (100 * max / average);\n"
246
" 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"
247
" return timer;\n"
248
"}\n"
249
"\n"
250
"function CloneTimer(T)\n"
251
"{\n"
252
" return MakeTimerCid(T.id, T.name, T.group, T.cid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\n"
253
"}\n"
254
"function CloneGroup(G)\n"
255
"{\n"
256
" return MakeGroupCid(G.id, G.name, G.category, G.numtimers, G.isgpu, G.total, G.average, G.max, G.cid);\n"
257
"}\n"
258
"\n"
259
"function MakeFrame(id, framestart, frameend, framestartgpu, frameendgpu, ts, tt, ti)\n"
260
"{\n"
261
" var frame = {\"id\":id, \"framestart\":framestart, \"frameend\":frameend, \"framestartgpu\":framestartgpu, \"frameendgpu\":frameendgpu, \"ts\":ts, \"tt\":tt, \"ti\":ti};\n"
262
" return frame;\n"
263
"}\n"
264
"function MakeCounterHistory(id, history, prc)\n"
265
"{\n"
266
" var counterhistory = {\"id\":id, \"history\":history, \"prc\":prc};\n"
267
" return counterhistory;\n"
268
"}\n"
269
"function MakeCounter(id, parent, sibling, firstchild, level, name, value, minvalue, maxvalue, formatted, limit, formattedlimit, counterprc, boxprc, format, counterhistory)\n"
270
"{\n"
271
" 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"
272
" return counter;\n"
273
"}\n"
274
"function Clamp(v, low, high)\n"
275
"{\n"
276
" return v < low ? low : (v > high ? high : v);\n"
277
"}\n"
278
"function FormatTime(Time)\n"
279
"{\n"
280
" return Time.toFixed(2);\n"
281
"}\n"
282
"\n"
283
"\n"
284
"\n"
285
"var g_ColorMap = {};\n"
286
"var g_Colors = new Array();\n"
287
"var g_ColorsDark = new Array();\n"
288
"var g_ColorsTextIndex = new Array();\n"
289
"var g_ColorH = new Array();\n"
290
"var g_ColorS = new Array();\n"
291
"var g_ColorL = new Array();\n"
292
"\n"
293
"function GetColorIndex(color)\n"
294
"{\n"
295
" if(g_ColorMap[color])\n"
296
" {\n"
297
" return g_ColorMap[color];\n"
298
" }\n"
299
" else\n"
300
" {\n"
301
" var idx = g_Colors.length;\n"
302
" g_ColorMap[color] = idx;\n"
303
" g_Colors.push(color);\n"
304
" g_ColorsDark.push(ConvertColorDark(color));\n"
305
" g_ColorsTextIndex.push(InvertColorIndex(color));\n"
306
" var hsl = ConvertRgbToHsl(color);\n"
307
" g_ColorH.push(hsl[0]);\n"
308
" g_ColorS.push(hsl[1]);\n"
309
" g_ColorL.push(hsl[2]);\n"
310
" return idx;\n"
311
" }\n"
312
"}\n"
313
"//color index 0 reserved for blinking\n"
314
"var cidhovercolor = 0;\n"
315
"g_Colors.push(\'#000000\');\n"
316
"g_ColorsDark.push(\'#000000\');\n"
317
"g_ColorsTextIndex.push(0);\n"
318
"g_ColorH.push(0);\n"
319
"g_ColorS.push(0);\n"
320
"g_ColorL.push(0);\n"
321
"\n"
322
"const CIDMatch = GetColorIndex(\"#AA3333\");\n"
323
"const CIDFail = GetColorIndex(\"#555555\");\n"
324
"\n"
325
"var S = {};\n"
326
"var S2 = {};\n"
327
"var Timeline = {};\n"
328
"S.TimelineArray = [];\n"
329
"S.TimelineIdArray = [];\n"
330
"S.TimelineNames = [];\n"
331
"S.TimelineColorArray = [];\n"
332
"\n"
333
"\n"
334
"\n"
335
"//EBEGIN\n"
336
"";
337
338
const size_t g_MicroProfileHtml_begin_0_size = sizeof(g_MicroProfileHtml_begin_0);
339
const char* g_MicroProfileHtml_begin[] = {
340
&g_MicroProfileHtml_begin_0[0],
341
};
342
size_t g_MicroProfileHtml_begin_sizes[] = {
343
sizeof(g_MicroProfileHtml_begin_0),
344
};
345
size_t g_MicroProfileHtml_begin_count = 1;
346
const char g_MicroProfileHtml_end_0[] =
347
"\n"
348
"//EEND\n"
349
"\n"
350
"const MP_LOG_LEAVE=0x0;\n"
351
"const MP_LOG_ENTER=0x1;\n"
352
"const MP_LOG_EXTENDED=0x2;\n"
353
"const MP_LOG_EXTENDED_NO_DATA=0x3;\n"
354
"\n"
355
"const ETOKEN_GPU_CPU_TIMESTAMP=0x3fff;\n"
356
"const ETOKEN_GPU_CPU_SOURCE_THREAD=0x3ffe;\n"
357
"const ETOKEN_META_MARKER=0x3ffd;\n"
358
"const ETOKEN_CUSTOM_NAME=0x3ffc;\n"
359
"const ETOKEN_CUSTOM_COLOR=0x3ffb;\n"
360
"const ETOKEN_CUSTOM_ID=0x3ffa;\n"
361
"\n"
362
"const ETOKEN_CSTR_PTR = 0x2000;\n"
363
"const ETOKEN_MAX = 0x2000;\n"
364
"\n"
365
"\n"
366
"\n"
367
"var CanvasDetailedView = document.getElementById(\'DetailedView\');\n"
368
"var CanvasHistory = document.getElementById(\'History\');\n"
369
"var CanvasMenu = document.getElementById(\'CanvasMenu\');\n"
370
"var CanvasDetailedOffscreen = document.createElement(\'canvas\');\n"
371
"var FilterInputGroup = document.getElementById(\'filtergroup\');\n"
372
"var FilterInputTimer = document.getElementById(\'filtertimer\');\n"
373
"\n"
374
"var FilterInput = document.getElementById(\'FilterInput\');\n"
375
"var FilterInputDiv = document.getElementById(\'FilterInputDiv\');\n"
376
"var FilterInputDivPos = {\"x\":-1,\"y\":-1,\"w\":-1,\"h\":-1};\n"
377
"var FilterInputMenu = document.getElementById(\'FilterInputMenu\');\n"
378
"var FilterInputMenuDiv = document.getElementById(\'FilterInputMenuDiv\');\n"
379
"var FilterInputMenuDivPos = {\"x\":-1,\"y\":-1,\"w\":-1,\"h\":-1};\n"
380
"var FilterInputMenuValueLast = \'\';\n"
381
"\n"
382
"let FilterInputSearch2 = document.getElementById(\'FilterInputSearch2\');\n"
383
"FilterInputSearch2.value = \'\';\n"
384
"let FilterInputSearchValue = \'\';\n"
385
"let FilterInputSearchActive2 = 0;\n"
386
"\n"
387
"const FLAGS_SECTION = 1;\n"
388
"\n"
389
"\n"
390
"let LastDropTarget = null;\n"
391
"\n"
392
"var FilterInputGroupString = null;\n"
393
"var FilterInputTimerString = null;\n"
394
"var FilterInputArray = [FilterInputGroup, FilterInputTimer];\n"
395
"var FilterGroup = null;\n"
396
"var FilterTimer = null;\n"
397
"var g_Msg = \'0\';\n"
398
"\n"
399
"var RedrawRequested = 0;\n"
400
"var InsideDraw = 0;\n"
401
"\n"
402
"\n"
403
"\n"
404
"var Initialized = 0;\n"
405
"var fDetailedOffset = S.Frames[0].framestart;\n"
406
"var fDetailedOffsetSecond = 0;\n"
407
"var fDetailedRange = S.Frames[S.Frames.length-1].frameend - fDetailedOffset;\n"
408
"var nWidth = CanvasDetailedView.width;\n"
409
"var nHeight = CanvasDetailedView.height;\n"
410
"var ReferenceTimeString = \'100\';\n"
411
"var ReferenceTimeAutoString = \'auto\';\n"
412
"var ReferenceTime = 100;\n"
413
"var TargetTime = 15;\n"
414
"var TargetTimeString = \'15ms\';\n"
415
"var nHistoryHeight = 70;\n"
416
"var nOffsetY = 0;\n"
417
"var nOffsetBarsX = 0;\n"
418
"var nOffsetBarsY = 0;\n"
419
"var nOffsetCountersY = 0;\n"
420
"var nOffsetFilterSearch = 0;\n"
421
"var nOffsetMenuThreads = 0;\n"
422
"var nOffsetMenuGroups = 0;\n"
423
"var FilterInputSearchLast = \'\';\n"
424
"var nBarsWidth = 80;\n"
425
"var MouseButtonState = [0,0,0,0,0,0,0,0];\n"
426
"var KeyShiftDown = 0;\n"
427
"var KeyAltDown = 0;\n"
428
"var KeyCtrlDown = 0;\n"
429
"let KeyHDown = 0;\n"
430
"var MouseDragButton = 0;\n"
431
"var ToolTipFlip = 0;\n"
432
"var ToolTipCorner = 0;\n"
433
"let ToolTipImmediate = null;\n"
434
"var DetailedViewMouseX = 0;\n"
435
"var DetailedViewMouseY = 0;\n"
436
"var DetailedMouseOverButton = 0;\n"
437
"var DetailedMouseEvent = null;\n"
438
"var HistoryViewMouseX = -1;\n"
439
"var HistoryViewMouseY = -1;\n"
440
"var GlobalMouseX = -1;\n"
441
"var GlobalMouseY = -1;\n"
442
"var MouseReleased = false;\n"
443
"var MouseHistory = 0;\n"
444
"var MouseDetailed = 0;\n"
445
"const FontName = \'Courier New\';\n"
446
"const FontHeight = 10;\n"
447
"const FontHeightLarge = 22;\n"
448
"const FontHeightFlash = 35;\n"
449
"let FontWidth = 1;\n"
450
"const FontAscent = 3; //Set manually\n"
451
"const Font = \'Bold \' + FontHeight + \'px \' + FontName;\n"
452
"const FontLarge = \'Bold \' + FontHeightLarge + \'px \' + FontName;\n"
453
"const FontFlash = \'Bold \' + FontHeightFlash + \'px \' + FontName;\n"
454
"const BoxHeight = FontHeight + 2;\n"
455
"let ThreadsHidden = {};\n"
456
"var GroupsDisabled = new Object();\n"
457
"var nMinWidth = 0.01;//subpixel width\n"
458
"var nMinWidthPan = 1.0;//subpixel width when panning\n"
459
"var nContextSwitchEnabled = 1;\n"
460
"var DisableLod = 0;\n"
461
"var DisableMerge = 0;\n"
462
"var GroupColors = 0;\n"
463
"var DrawDetailedFlameMode = 0;\n"
464
"var DrawDetailedNewDraw = 1;\n"
465
"var DrawDetailedCompareReverse = 1;\n"
466
"var nModDown = 0;\n"
467
"var g_MSG = \'no\';\n"
468
"var nDrawCount = 0;\n"
469
"var nBackColors = [\'#292929\', \'#343434\' ];\n"
470
"var nBackColorsDark = [\'#292929\', \'#272727\' ];\n"
471
"var nBackColorOffset = \'#404040\';\n"
472
"const CSwitchColors =[\"#EAAC76\",\"#8CE48B\",\"#C4D688\",\"#9DD8AF\",\"#D7B6DA\",\"#DBDA61\",\"#8AD5E1\",\"#57E5C4\"];//generated by http://tools.medialab.sciences-po.fr/iwanthue/index.php\n"
473
"var CSwitchHeight = 5;\n"
474
"var FRAME_HISTORY_COLOR_CPU = \'#ff7f27\';\n"
475
"var FRAME_HISTORY_COLOR_GPU = \'#ffffff\';\n"
476
"var ZOOM_TIME = 0.5;\n"
477
"var AnimationActive = false;\n"
478
"var nHoverCSCpu = -1;\n"
479
"var nHoverCSCpuNext = -1;\n"
480
"var nHoverCSToolTip = null;\n"
481
"var nHoverToken = -1;\n"
482
"var HoverTokenOwner = null;\n"
483
"//var nHoverFrame = -1;\n"
484
"var nHoverTokenIndex = -1;\n"
485
"var nHoverTokenLogIndex = -1;\n"
486
"var nHoverCounter = 0;\n"
487
"var nHoverCounterDelta = 8;\n"
488
"var nHoverTokenNext = -1;\n"
489
"var nHoverTokenLogIndexNext = -1;\n"
490
"var nHoverTokenIndexNext = -1;\n"
491
"var HoverTokenNextOwner = null;\n"
492
"var nHoverCounter = -1;\n"
493
"var nHoverTokenDrawn = -1;\n"
494
"var nHideHelp = 0;\n"
495
"var fFrameScale = 33.33;\n"
496
"var SortColumn = 0;\n"
497
"var SortColumnOrderFlip = 0;\n"
498
"var SortColumnMouseOver = null;\n"
499
"var SortColumnMouseOverNext = null;\n"
500
"var ColumnsWidth = [];\n"
501
"var ColumnsEnabled = [];\n"
502
"let ColumnNames =[\"Average\", \"Max\", \"Total\", \"Min\", \"Spike\", \"Call Average\", \"Call Count\", \"Excl Average\", \"Excl Max\"];\n"
503
"let NumColumns = ColumnNames.length;\n"
504
"while(ColumnsEnabled.length < NumColumns)\n"
505
"{\n"
506
" ColumnsEnabled.push(1);\n"
507
" ColumnsWidth.push(20);\n"
508
"}\n"
509
"var FilterSearchActive = 0;\n"
510
"var FilterSearchSelection = -1;\n"
511
"var FilterSearchSelectionMax = 0;\n"
512
"var FilterSearchPassIndex = -1;\n"
513
"FilterSearchReset();\n"
514
"var FilterSearchStartTime = new Date();\n"
515
"var IgnoreInput = 0;\n"
516
"function RangeInit()\n"
517
"{\n"
518
" return {\"Begin\":-1, \"End\":-1, \"YBegin\":-1, \"YEnd\":-1, \"Thread\": -1 , \"Index\": -1, \"Off\": 0, \"Second\":0};\n"
519
"}\n"
520
"function RangeValid(Range)\n"
521
"{\n"
522
" return Range && Range.Begin < Range.End;\n"
523
"}\n"
524
"function RangeCopy(Dst, Src)\n"
525
"{\n"
526
" Dst.Begin = Src.Begin;\n"
527
" Dst.End = Src.End;\n"
528
" Dst.YBegin = Src.YBegin;\n"
529
" Dst.YEnd = Src.YEnd;\n"
530
" Dst.Thread = Src.Thread;\n"
531
" Dst.Off = Src.Off;\n"
532
" Dst.Second = Src.Second;\n"
533
"}\n"
534
"var RangeCpu = RangeInit();\n"
535
"var RangeGpu = RangeInit();\n"
536
"var RangeSelect = RangeInit();\n"
537
"\n"
538
"var RangeCpuNext = RangeInit();\n"
539
"var RangeGpuNext = RangeInit();\n"
540
"\n"
541
"var RangeCpuHistory = RangeInit();\n"
542
"var RangeGpuHistory = RangeInit();\n"
543
"\n"
544
"var fRangeBegin = 0;\n"
545
"var fRangeEnd = -1;\n"
546
"var fRangeThreadId = -1;\n"
547
"var fRangeThreadIdNext = -1;\n"
548
"var fRangeBeginNext = 0;\n"
549
"var fRangeEndNext = 0;\n"
550
"var fRangeBeginGpuNext = 0;\n"
551
"var fRangeEndGpuNext = 0;\n"
552
"var fRangeBeginHistory = -1;\n"
553
"var fRangeEndHistory = -1;\n"
554
"var fRangeBeginHistoryGpu = -1;\n"
555
"var fRangeEndHistoryGpu = -1;\n"
556
"var fRangeBeginSelect = 0;\n"
557
"var fRangeEndSelect = -1;\n"
558
"var ThreadYBegin;\n"
559
"var ThreadYEnd;\n"
560
"\n"
561
"var ModeDetailed = 0;\n"
562
"var ModeTimers = 1;\n"
563
"var ModeTimers_Threads = 2;\n"
564
"var ModeTimers_Groups = 3;\n"
565
"var ModeCounters = 4;\n"
566
"var ModeCount = 5;\n"
567
"var Mode = ModeDetailed;\n"
568
"\n"
569
"var DebugDrawQuadCount = 0;\n"
570
"var DebugDrawTextCount = 0;\n"
571
"var ProfileMode = 0;\n"
572
"var ProfileRedraw0 = 0;\n"
573
"var ProfileRedraw1 = 0;\n"
574
"var ProfileRedraw2 = 0;\n"
575
"var ProfileFps = 0;\n"
576
"var ProfileFpsAggr = 0;\n"
577
"var ProfileFpsCount = 0;\n"
578
"var ProfileLastTimeStamp = new Date();\n"
579
"\n"
580
"var ProfileData = {};\n"
581
"var ProfileStackTime = {};\n"
582
"var ProfileStackName = {};\n"
583
"let ProfileDrawStartLast = new Date();\n"
584
"let ProfileDrawEndLast = new Date();\n"
585
"function CreateEmptyFloatArray(Size)\n"
586
"{\n"
587
" let a = Array(Size);\n"
588
" for(let i = 0; i < Size; ++i)\n"
589
" a[i] = 0.0;\n"
590
" return a;\n"
591
"}\n"
592
"let ProfileDrawTime = CreateEmptyFloatArray(120);\n"
593
"let ProfileDeltaTime = CreateEmptyFloatArray(120);\n"
594
"let ProfileDraw2Draw = CreateEmptyFloatArray(120);\n"
595
"\n"
596
"var Debug = 1;\n"
597
"\n"
598
"var ThreadLogAutoHide = 0;\n"
599
"var NumLodSplits = 10;\n"
600
"var SplitMin = 100;\n"
601
"var SPLIT_LIMIT = 1e20;\n"
602
"var DPR = 1;\n"
603
"var DetailedRedrawState = {};\n"
604
"var OffscreenData;\n"
605
"var DetailedFrameCounter = 0;\n"
606
"var Invalidate = 0;\n"
607
"var GroupOrder = Array();\n"
608
"var ThreadOrder = Array();\n"
609
"var ThreadOrderNames = Array();\n"
610
"var ThreadOrderT = Array();\n"
611
"var MetaLengths = Array();\n"
612
"var MetaLengthsAvg = Array();\n"
613
"var MetaLengthsMax = Array();\n"
614
"\n"
615
"var ZoomActive = 0;\n"
616
"\n"
617
"var StrGroup = \"Group\";\n"
618
"var StrThread = \"Thread\";\n"
619
"var StrTimer = \"Timer\";\n"
620
"var StrAverage = \"Average\";\n"
621
"var StrMax = \"Max\";\n"
622
"var StrTotal = \"Total\";\n"
623
"var StrMin = \"Min\";\n"
624
"var StrSpike = \"Spike%\";\n"
625
"var StrCallAverage = \"Call Average\";\n"
626
"var StrCount = \"Count\";\n"
627
"var StrExclAverage = \"Excl Average\";\n"
628
"var StrExclMax = \"Excl Max\";\n"
629
"\n"
630
"var GroupRemapReverse = [];\n"
631
"var TimerRemapReverse = [];\n"
632
"var ThreadRemapReverse = [];\n"
633
"\n"
634
"let SubMenuHelp = 0;\n"
635
"let SubMenuMode = 1;\n"
636
"let SubMenuReference = 2;\n"
637
"let SubMenuTarget = 3;\n"
638
"let SubMenuThreads = 4;\n"
639
"let SubMenuGroups = 5;\n"
640
"let SubMenuColumns = 6;\n"
641
"let SubMenuOptions = 7;\n"
642
"let SubMenuCompare = 8;\n"
643
"\n"
644
"let MenuRedraw = 0;\n"
645
"let SubMenuActive = -1;\n"
646
"let SubMenuTimeoutBase = 0.7;\n"
647
"let SubMenuMouseX = 0;\n"
648
"let SubMenuMouseY = 0;\n"
649
"let SubMenuTimeout = new Date();\n"
650
"let MenuItems = [];\n"
651
"let FilterInputMenuThreadsValue = \'\';\n"
652
"let FilterInputMenuGroupsValue = \'\';\n"
653
"let MouseMoveTime = new Date();\n"
654
"let ReferenceTimes = [-1, 5, 10, 15, 16, 20, 30, 33, 50, 100, 250, 500, 1000];\n"
655
"let TargetTimes = [5, 10, 15, 16, 20, 30, 33, 50, 100, 250, 500, 1000];\n"
656
"let ModeItems = [\"Detailed\", \"Timers\", \"Threads\", \"Groups\", \"Counters\"];\n"
657
"let HideModeFullyHidden = 0;\n"
658
"let HideModeCollapsed = 1;\n"
659
"let HideMode = HideModeCollapsed;\n"
660
"\n"
661
"\n"
662
"function ProfileModeClear()\n"
663
"{\n"
664
" if(ProfileMode)\n"
665
" {\n"
666
" ProfileData = new Object();\n"
667
" ProfileStackTime = new Array();\n"
668
" ProfileStackName = new Array();\n"
669
" }\n"
670
"}\n"
671
"function ProfileEnter(Name)\n"
672
"{\n"
673
" if(ProfileMode)\n"
674
" {\n"
675
" ProfileStackTime.push(new Date());\n"
676
" ProfileStackName.push(Name);\n"
677
" }\n"
678
"}\n"
679
"function ProfileLeave()\n"
680
"{\n"
681
" if(ProfileMode)\n"
682
" {\n"
683
" var Time = new Date();\n"
684
" var Delta = Time - ProfileStackTime.pop();\n"
685
" var Name = ProfileStackName.pop();\n"
686
" var Obj = ProfileData[Name];\n"
687
" if(!Obj)\n"
688
" {\n"
689
" Obj = new Object();\n"
690
" Obj.Count = 0;\n"
691
" Obj.Name = Name;\n"
692
" Obj.Time = 0;\n"
693
" ProfileData[Name] = Obj;\n"
694
" }\n"
695
" Obj.Time += Delta;\n"
696
" Obj.Count += 1;\n"
697
" }\n"
698
"}\n"
699
"\n"
700
"function ProfilePlot(s)\n"
701
"{\n"
702
" if(ProfileMode)\n"
703
" {\n"
704
" var A = ProfileData.Plot;\n"
705
" if(!A)\n"
706
" {\n"
707
" ProfileData.Plot = Array();\n"
708
" A = ProfileData.Plot;\n"
709
" }\n"
710
" if(A.length<10)\n"
711
" {\n"
712
" A.push(s);\n"
713
" }\n"
714
" }\n"
715
"}\n"
716
"function ProfileModeDump()\n"
717
"{\n"
718
" for(var idx in ProfileData)\n"
719
" {\n"
720
" var Timer = ProfileData[idx];\n"
721
" console.log(Timer.Name + \" \" + Timer.Time + \"ms \" + Timer.Count);\n"
722
" }\n"
723
"}\n"
724
"\n"
725
"function ProfileDrawFrameTimeGraph(context)\n"
726
"{\n"
727
" if(ProfileMode)\n"
728
" {\n"
729
" let Params = CreateDrawGraphParameters();\n"
730
" let Mouse = {};\n"
731
" Mouse.X = DetailedViewMouseX;\n"
732
" Mouse.Y = DetailedViewMouseY;\n"
733
" Params.RangeMin = 0;\n"
734
" Params.RangeMax = 50;\n"
735
"\n"
736
" let DrawTimeData = CreateGraphData(ProfileDrawTime, \"DrawTime\", \"#ff2288\");\n"
737
" let DeltaTimeData = CreateGraphData(ProfileDeltaTime, \"DeltaTime\", \"#2288ee\");\n"
738
" let Draw2DrawData = CreateGraphData(ProfileDraw2Draw, \"Draw2Draw\", \"#11aa33\");\n"
739
"\n"
740
" {\n"
741
" Params.Rect = WindowRect(0, nHeight-200, 200, 200);\n"
742
"\n"
743
" DrawGraph(context, Params, [DrawTimeData], Mouse);\n"
744
" }\n"
745
" {\n"
746
" Params.Rect = WindowRect(200, nHeight-200, 200, 200);\n"
747
"\n"
748
" DrawGraph(context, Params, [DeltaTimeData], Mouse);\n"
749
" }\n"
750
" {\n"
751
" Params.Rect = WindowRect(400, nHeight-200, 200, 200);\n"
752
" DrawGraph(context, Params, [Draw2DrawData], Mouse);\n"
753
" }\n"
754
" {\n"
755
" Params.Rect = WindowRect(610, nHeight-200, 200, 200);\n"
756
" DrawGraph(context, Params, [DrawTimeData, DeltaTimeData,Draw2DrawData], Mouse);\n"
757
" }\n"
758
" }\n"
759
"}\n"
760
"\n"
761
"function ProfileModeDraw(Canvas)\n"
762
"{\n"
763
" if(ProfileMode)\n"
764
" {\n"
765
" var StringArray = [];\n"
766
" for(var idx in ProfileData)\n"
767
" {\n"
768
" if(idx == \"Plot\")\n"
769
" continue;\n"
770
" var Timer = ProfileData[idx];\n"
771
" StringArray.push(Timer.Name);\n"
772
" StringArray.push(Timer.Time + \"ms\");\n"
773
" StringArray.push(\"#\");\n"
774
" StringArray.push(\"\" + Timer.Count);\n"
775
" }\n"
776
" StringArray.push(\"debug\");\n"
777
" StringArray.push(Debug);\n"
778
" var Time = new Date();\n"
779
" var Delta = Time - ProfileLastTimeStamp;\n"
780
" ProfileLastTimeStamp = Time;\n"
781
" StringArray.push(\"Frame Delta\");\n"
782
" StringArray.push(Delta + \"ms\");\n"
783
" if(ProfileMode == 2)\n"
784
" {\n"
785
" ProfileFpsAggr += Delta;\n"
786
" ProfileFpsCount ++ ;\n"
787
" var AggrFrames = 10;\n"
788
" if(ProfileFpsCount == AggrFrames)\n"
789
" {\n"
790
" ProfileFps = 1000 / (ProfileFpsAggr / AggrFrames);\n"
791
" ProfileFpsAggr = 0;\n"
792
" ProfileFpsCount = 0;\n"
793
" }\n"
794
" StringArray.push(\"FPS\");\n"
795
" StringArray.push(\"\" + ProfileFps.toFixed(2));\n"
796
" }\n"
797
" StringArray.push(\"ProfileRedraw0\");\n"
798
" StringArray.push(\"\" + ProfileRedraw0);\n"
799
" StringArray.push(\"ProfileRedraw1\");\n"
800
" StringArray.push(\"\" + ProfileRedraw1);\n"
801
" StringArray.push(\"ProfileRedraw2\");\n"
802
" StringArray.push(\"\" + ProfileRedraw2);\n"
803
" ProfileRedraw0 = 0;\n"
804
" ProfileRedraw1 = 0;\n"
805
" ProfileRedraw2 = 0;\n"
806
"\n"
807
"\n"
808
" for(var i = 0; i < ProfileData.Plot; ++i)\n"
809
" {\n"
810
" StringArray.push(\"\");\n"
811
" StringArray.push(ProfileData.Plot[i]);\n"
812
" }\n"
813
" ProfileData.Plot = Array();\n"
814
" DrawToolTip(StringArray, Canvas, 0, 200);\n"
815
" }\n"
816
"}\n"
817
"\n"
818
"function ToggleDebugMode()\n"
819
"{\n"
820
" ProfileMode = (ProfileMode+1)%4;\n"
821
" console.log(\'Toggle Debug Mode \' + ProfileMode);\n"
822
"}\n"
823
"\n"
824
"function DetailedTotal(S)\n"
825
"{\n"
826
" var Total = 0;\n"
827
" for(var i = 0; i < S.Frames.length; i++)\n"
828
" {\n"
829
" var frfr = S.Frames[i];\n"
830
" Total += frfr.frameend - frfr.framestart;\n"
831
" }\n"
832
" return Total;\n"
833
"}\n"
834
"\n"
835
"\n"
836
"function InitFrameInfo()\n"
837
"{\n"
838
"\n"
839
" var div = document.getElementById(\'divFrameInfo\');\n"
840
" var txt = \'\';\n"
841
" txt = txt + \'Timers View\' + \'<br>\';\n"
842
" txt = txt + \'Frames:\' + S.AggregateInfo.Frames +\'<br>\';\n"
843
" txt = txt + \'Time:\' + S.AggregateInfo.Time.toFixed(2) +\'ms<br>\';\n"
844
" txt = txt + \'<hr>\';\n"
845
" txt = txt + \'Detailed View\' + \'<br>\';\n"
846
" txt = txt + \'Frames:\' + S.Frames.length +\'<br>\';\n"
847
" txt = txt + \'Time:\' + DetailedTotal(S).toFixed(2) +\'ms<br>\';\n"
848
" div.innerHTML = txt;\n"
849
"}\n"
850
"function InitGroups()\n"
851
"{\n"
852
" for(groupid in S.GroupInfo)\n"
853
" {\n"
854
" var TimerArray = Array();\n"
855
" for(timerid in S.TimerInfo)\n"
856
" {\n"
857
" if(S.TimerInfo[timerid].group == groupid)\n"
858
" {\n"
859
" TimerArray.push(timerid);\n"
860
" }\n"
861
" }\n"
862
" S.GroupInfo[groupid].TimerArray = TimerArray;\n"
863
" }\n"
864
"}\n"
865
"\n"
866
"\n"
867
"function ThreadOrderMove(Name, Dir, Top)\n"
868
"{\n"
869
" let idx = ThreadOrderNames.indexOf(Name);\n"
870
" let base = idx;\n"
871
" idx += Dir;\n"
872
" let found = -1;\n"
873
" while(idx >= 0 && idx <= ThreadOrderNames.length)\n"
874
" {\n"
875
" let n = S.ThreadNames.indexOf(ThreadOrderNames[idx]);\n"
876
" if(n != -1)\n"
877
" {\n"
878
" found = idx;\n"
879
" if(!Top)\n"
880
" break;\n"
881
" }\n"
882
" idx += Dir;\n"
883
" }\n"
884
" Dir = -Dir;\n"
885
" while(found >= 0 && found <= ThreadOrderNames.length && (Dir > 0 ? (found <= base) : (found >= base)))\n"
886
" {\n"
887
" let Tmp = ThreadOrderNames[found];\n"
888
" ThreadOrderNames[found] = Name;\n"
889
" Name = Tmp;\n"
890
" found += Dir;\n"
891
" }\n"
892
" ThreadOrderSort();\n"
893
"}\n"
894
"function ThreadOrderMoveUp(Name, Top)\n"
895
"{\n"
896
" ThreadOrderMove(Name, -1, Top);\n"
897
" WriteCookie();\n"
898
"}\n"
899
"function ThreadOrderMoveDown(Name, Top)\n"
900
"{\n"
901
" ThreadOrderMove(Name, 1, Top);\n"
902
" WriteCookie();\n"
903
"}\n"
904
"function ThreadOrderSort()\n"
905
"{\n"
906
" for(let i = 0; i < S.ThreadNames.length; ++i)\n"
907
" {\n"
908
" var name = S.ThreadNames[i];\n"
909
" var idx = ThreadOrderNames.indexOf(name);\n"
910
" if(idx == -1)\n"
911
" {\n"
912
" ThreadOrderNames.push(name);\n"
913
" }\n"
914
" }\n"
915
"\n"
916
" //clear all that are not present??\n"
917
" let ThreadOrderX = Array(S.ThreadNames.length);\n"
918
" for(let i = 0; i < S.ThreadNames.length; ++i)\n"
919
" {\n"
920
" let isgpu = S.ISGPU[i]?1:0;\n"
921
" var n = ThreadOrderNames.indexOf(S.ThreadNames[i]);\n"
922
" if(n == -1)\n"
923
" {\n"
924
" debugger;\n"
925
" }\n"
926
" ThreadOrderX[i] = {\"i\":i, \"n\": n, \"g\":isgpu};\n"
927
" }\n"
928
" ThreadOrderX.sort(function(l,r){if(l.g!=r.g)return r.g-l.g;return l.n-r.n;}); //sort gpu first\n"
929
" ThreadOrderT = Array(S.ThreadNames.length);\n"
930
" for(let i = 0; i < S.ThreadNames.length; ++i)\n"
931
" {\n"
932
" ThreadOrderT[i] = ThreadOrderX[i].i;\n"
933
" }\n"
934
"}\n"
935
"function IsThreadActive(ThreadName)\n"
936
"{\n"
937
" return !ThreadsHidden[ThreadName];\n"
938
"}\n"
939
"\n"
940
"function ToggleThread(ThreadName, All, FilterArray, State)\n"
941
"{\n"
942
" if(ThreadName)\n"
943
" {\n"
944
" if(ThreadsHidden[ThreadName])\n"
945
" {\n"
946
" delete ThreadsHidden[ThreadName];\n"
947
" }\n"
948
" else\n"
949
" {\n"
950
" ThreadsHidden[ThreadName] = 1;\n"
951
" }\n"
952
" }\n"
953
" else\n"
954
" {\n"
955
" let Names = All ? S.ThreadNames : FilterArray;\n"
956
"\n"
957
" for(let i in Names)\n"
958
" {\n"
959
" switch(State)\n"
960
" {\n"
961
" case 0: if(!ThreadsHidden[Names[i]]){ ThreadsHidden[Names[i]] = 1;} break;\n"
962
" case 1: ThreadsHidden[Names[i]] = ThreadsHidden[Names[i]] ? 0 : 1; break;\n"
963
" case 2: if(ThreadsHidden[Names[i]]){ delete ThreadsHidden[Names[i]];} break;\n"
964
" }\n"
965
" }\n"
966
" }\n"
967
" RequestRedraw();\n"
968
" Invalidate = 0;\n"
969
" FilterSearchReset();\n"
970
" WriteCookie();\n"
971
"}\n"
972
"\n"
973
"\n"
974
"function CreateOrderArray(Source, NameFunc)\n"
975
"{\n"
976
" var Temp = Array(Source.length);\n"
977
" for(var i = 0; i < Source.length; ++i)\n"
978
" {\n"
979
" Temp[i] = {};\n"
980
" Temp[i].index = i;\n"
981
" Temp[i].namezz = NameFunc(Source[i]).toLowerCase();\n"
982
" }\n"
983
" Temp.sort(function(l, r)\n"
984
" {\n"
985
" if(r.namezz<l.namezz)\n"
986
" {return 1;}\n"
987
" if(l.namezz<r.namezz)\n"
988
" {return -1;}\n"
989
" return 0;\n"
990
" } );\n"
991
" var OrderArray = Array(Source.length);\n"
992
" for(var i = 0; i < Source.length; ++i)\n"
993
" {\n"
994
" OrderArray[i] = Temp[i].index;\n"
995
" }\n"
996
" return OrderArray;\n"
997
"}\n"
998
"\n"
999
"function InitOrderArrays()\n"
1000
"{\n"
1001
" ThreadOrder = [];\n"
1002
" ThreadOrder = CreateOrderArray(S.ThreadNames, function(a){return a;});\n"
1003
"\n"
1004
"\n"
1005
" let MaxLen = 7;\n"
1006
" let MenuArray = Array();\n"
1007
" for(let i = 0; i < S.GroupInfo.length; ++i)\n"
1008
" {\n"
1009
" let x = {};\n"
1010
" x.IsCategory = 0;\n"
1011
" x.category = S.GroupInfo[i].category;\n"
1012
" x.name = S.GroupInfo[i].name;\n"
1013
" x.index = i;\n"
1014
" MenuArray.push(x);\n"
1015
" }\n"
1016
" for(let i = 0; i < S.CategoryInfo.length; ++i)\n"
1017
" {\n"
1018
" let x = {};\n"
1019
" x.IsCategory = 1;\n"
1020
" x.category = i;\n"
1021
" x.name = S.CategoryInfo[i];\n"
1022
" x.index = i;\n"
1023
" MenuArray.push(x);\n"
1024
" }\n"
1025
" let OrderFunction = function(a){ return a.category + \"__\" + a.name; };\n"
1026
" let OrderFunctionMenu = function(a){ return a.IsCategory ? (a.category + \'\') : (a.category + \"__\" + a.name); };\n"
1027
" GroupOrder = CreateOrderArray(S.GroupInfo, OrderFunction);\n"
1028
"}\n"
1029
"\n"
1030
"function CategoryIndex(CategoryName)\n"
1031
"{\n"
1032
" for(var i = 0; i < S.CategoryInfo.length; ++i)\n"
1033
" {\n"
1034
" if(S.CategoryInfo[i] == CategoryName)\n"
1035
" {\n"
1036
" return i;\n"
1037
" }\n"
1038
" }\n"
1039
" return -1;\n"
1040
"}\n"
1041
"function IsCategoryActive(CategoryIdx)\n"
1042
"{\n"
1043
" for(var i = 0; i < S.GroupInfo.length; ++i)\n"
1044
" {\n"
1045
" if(S.GroupInfo[i].category == CategoryIdx)\n"
1046
" {\n"
1047
" var Name = S.GroupInfo[i].name;\n"
1048
" if(!GroupsActive[Name])\n"
1049
" {\n"
1050
" return false;\n"
1051
" }\n"
1052
" }\n"
1053
" }\n"
1054
" return true;\n"
1055
"\n"
1056
"}\n"
1057
"function ToggleCategory(CategoryName, WantRedraw)\n"
1058
"{\n"
1059
" var CategoryIdx = CategoryIndex(CategoryName);\n"
1060
" if(CategoryIdx < 0)\n"
1061
" return;\n"
1062
" var CategoryActive = IsCategoryActive(CategoryIdx);\n"
1063
" for(var i = 0; i < S.GroupInfo.length; ++i)\n"
1064
" {\n"
1065
" if(S.GroupInfo[i].category == CategoryIdx)\n"
1066
" {\n"
1067
" var Name = S.GroupInfo[i].name;\n"
1068
" if(CategoryActive)\n"
1069
" {\n"
1070
" delete GroupsDisabled[Name];\n"
1071
" }\n"
1072
" else\n"
1073
" {\n"
1074
" GroupsDisabled[Name] = 1;\n"
1075
" }\n"
1076
" }\n"
1077
" }\n"
1078
" WriteCookie();\n"
1079
" if(WantRedraw)\n"
1080
" {\n"
1081
" RequestRedraw();\n"
1082
" }\n"
1083
"}\n"
1084
"\n"
1085
"function ToggleGroup(GroupName, All, FilterArray, State)\n"
1086
"{\n"
1087
" if(GroupName)\n"
1088
" {\n"
1089
" if(GroupsDisabled[GroupName])\n"
1090
" {\n"
1091
" delete GroupsDisabled[GroupName];\n"
1092
" }\n"
1093
" else\n"
1094
" {\n"
1095
" GroupsDisabled[GroupName] = 1;\n"
1096
" }\n"
1097
" }\n"
1098
" else\n"
1099
" {\n"
1100
" let Names = FilterArray;\n"
1101
" if(All)\n"
1102
" {\n"
1103
" Names = [];\n"
1104
" for(let i in S.GroupInfo)\n"
1105
" {\n"
1106
" Names.push(S.GroupInfo[i].name);\n"
1107
" }\n"
1108
" }\n"
1109
"\n"
1110
" for(let i in Names)\n"
1111
" {\n"
1112
" let N = Names[i];\n"
1113
" switch(State)\n"
1114
" {\n"
1115
" case 2: if(GroupsDisabled[N]){ delete GroupsDisabled[N];} break;\n"
1116
" case 1:\n"
1117
" if(GroupsDisabled[N])\n"
1118
" {\n"
1119
" delete GroupsDisabled[N];\n"
1120
" }\n"
1121
" else\n"
1122
" {\n"
1123
" GroupsDisabled[N] = 1;\n"
1124
" }\n"
1125
"\n"
1126
" break;\n"
1127
" case 0: if(!GroupsDisabled[N]){ GroupsDisabled[N] = 1;} break;\n"
1128
" }\n"
1129
" }\n"
1130
" }\n"
1131
" WriteCookie();\n"
1132
"}\n"
1133
"\n"
1134
"function UpdateGroupColors()\n"
1135
"{\n"
1136
" for(var i = 0; i < S.TimerInfo.length; ++i)\n"
1137
" {\n"
1138
" if(GroupColors == 1)\n"
1139
" {\n"
1140
" S.TimerInfo[i].cid = S.GroupInfo[S.TimerInfo[i].group].cid;\n"
1141
" }\n"
1142
" else\n"
1143
" {\n"
1144
" S.TimerInfo[i].cid = S.TimerInfo[i].timercid;\n"
1145
" }\n"
1146
" }\n"
1147
"}\n"
1148
"function ToggleDetailedFlameMode(WantRedraw)\n"
1149
"{\n"
1150
" DrawDetailedFlameMode = (DrawDetailedFlameMode+1)%3;\n"
1151
" WriteCookie();\n"
1152
" if(WantRedraw)\n"
1153
" {\n"
1154
" RequestRedraw();\n"
1155
" }\n"
1156
"}\n"
1157
"\n"
1158
"function ToggleDetailedNewDraw()\n"
1159
"{\n"
1160
" DrawDetailedNewDraw = DrawDetailedNewDraw ? 0 : 1;\n"
1161
" WriteCookie();\n"
1162
" RequestRedraw();\n"
1163
"}\n"
1164
"\n"
1165
"\n"
1166
"\n"
1167
"function ToggleDetailedSecondReverse(WantRedraw)\n"
1168
"{\n"
1169
" DrawDetailedCompareReverse = 1-DrawDetailedCompareReverse;\n"
1170
" WriteCookie();\n"
1171
" if(WantRedraw)\n"
1172
" {\n"
1173
" RequestRedraw();\n"
1174
" }\n"
1175
"}\n"
1176
"\n"
1177
"function ToggleGroupColors(WantRedraw)\n"
1178
"{\n"
1179
" GroupColors = (GroupColors+1)%4;\n"
1180
" UpdateGroupColors();\n"
1181
" WriteCookie();\n"
1182
" if(WantRedraw)\n"
1183
" {\n"
1184
" RequestRedraw();\n"
1185
" }\n"
1186
"}\n"
1187
"\n"
1188
"function ShowHelp(Show, Forever)\n"
1189
"{\n"
1190
" var HelpWindow = document.getElementById(\'helpwindow\');\n"
1191
" if(Show)\n"
1192
" {\n"
1193
" HelpWindow.style[\'display\'] = \'block\';\n"
1194
" }\n"
1195
" else\n"
1196
" {\n"
1197
" HelpWindow.style[\'display\'] = \'none\';\n"
1198
" }\n"
1199
" if(Forever)\n"
1200
" {\n"
1201
" nHideHelp = Show ? 0 : 1;\n"
1202
" WriteCookie();\n"
1203
" }\n"
1204
"}\n"
1205
"function ToggleMode()\n"
1206
"{\n"
1207
" Mode = (Mode + 1) % ModeCount;\n"
1208
" SetMode(Mode);\n"
1209
"}\n"
1210
"\n"
1211
"function SetMode(NewMode, WantRedraw)\n"
1212
"{\n"
1213
" ResetColumnWidth();\n"
1214
" Mode = NewMode;\n"
1215
" if(Mode == ModeTimers || Mode == ModeTimers_Groups || Mode == ModeTimers_Threads)\n"
1216
" {\n"
1217
" SetFilterInput(FilterInputGroupString, FilterInputTimerString);\n"
1218
" }\n"
1219
" else\n"
1220
" {\n"
1221
" ShowFilterInput(0);\n"
1222
" }\n"
1223
" ShowDetailedSearch(false);\n"
1224
"\n"
1225
" WriteCookie();\n"
1226
" if(WantRedraw)\n"
1227
" {\n"
1228
" RequestRedraw();\n"
1229
" }\n"
1230
"}\n"
1231
"\n"
1232
"\n"
1233
"function UpdateReferenceTime()\n"
1234
"{\n"
1235
" S.CaptureStartTime = S.Frames[0].framestart;\n"
1236
" S.CaptureEndTime = S.Frames[S.Frames.length-1].frameend;\n"
1237
"\n"
1238
" if(\'auto\' == ReferenceTimeString.substring(0,4))\n"
1239
" {\n"
1240
" let Max = 0.1;\n"
1241
" for(var i = 0; i < S.Frames.length; ++i)\n"
1242
" {\n"
1243
" let T = S.Frames[i].frameend - S.Frames[i].framestart;\n"
1244
" Max = Math.max(T, Max);\n"
1245
" }\n"
1246
" ReferenceTime = Max*1.20;\n"
1247
" if(TargetTime>0)\n"
1248
" {\n"
1249
" ReferenceTime = Math.max(ReferenceTime, TargetTime * 1.33);\n"
1250
" }\n"
1251
" ReferenceTimeAutoString = \'auto [\' + Max.toFixed(2) + \'ms]\';\n"
1252
" }\n"
1253
" else\n"
1254
" {\n"
1255
" ReferenceTime = parseInt(ReferenceTimeString);\n"
1256
" }\n"
1257
"}\n"
1258
"\n"
1259
"function SetReferenceTime(TimeString, WantRedraw)\n"
1260
"{\n"
1261
" ReferenceTimeString = TimeString;\n"
1262
" UpdateReferenceTime();\n"
1263
" WriteCookie();\n"
1264
" if(WantRedraw)\n"
1265
" {\n"
1266
" RequestRedraw();\n"
1267
" }\n"
1268
"}\n"
1269
"\n"
1270
"function SetTargetTime(TimeString, WantRedraw)\n"
1271
"{\n"
1272
" TargetTimeString = TimeString;\n"
1273
" TargetTime = parseInt(TargetTimeString);\n"
1274
" WriteCookie();\n"
1275
" if(WantRedraw)\n"
1276
" {\n"
1277
" RequestRedraw();\n"
1278
" }\n"
1279
"}\n"
1280
"\n"
1281
"function ToggleContextSwitch()\n"
1282
"{\n"
1283
" SetContextSwitch(nContextSwitchEnabled ? 0 : 1);\n"
1284
"}\n"
1285
"\n"
1286
"function SetContextSwitch(Enabled, WantRedraw)\n"
1287
"{\n"
1288
" nContextSwitchEnabled = Enabled ? 1 : 0;\n"
1289
" WriteCookie();\n"
1290
" if(WantRedraw)\n"
1291
" {\n"
1292
" RequestRedraw();\n"
1293
" }\n"
1294
"}\n"
1295
"function PushIntoArray(A, v)\n"
1296
"{\n"
1297
" A.shift();\n"
1298
" A.push(v);\n"
1299
"}\n"
1300
"function ToggleDebug()\n"
1301
"{\n"
1302
" Debug = (Debug + 1) % 2;\n"
1303
"}\n"
1304
"\n"
1305
"function ToggleDisableMerge()\n"
1306
"{\n"
1307
" DisableMerge = DisableMerge ? 0 : 1;\n"
1308
"}\n"
1309
"function ToggleDisableLod()\n"
1310
"{\n"
1311
" DisableLod = DisableLod ? 0 : 1;\n"
1312
"}\n"
1313
"\n"
1314
"function GatherHoverMetaCounters(TimerIndex, StartIndex, nLog, nFrameLast)\n"
1315
"{\n"
1316
" var HoverInfo = new Object();\n"
1317
" return HoverInfo;\n"
1318
" var StackPos = 1;\n"
1319
" //search backwards, count meta counters\n"
1320
" for(var i = nFrameLast; i >= 0; i--)\n"
1321
" {\n"
1322
" var fr = S.Frames[i];\n"
1323
" var ts = fr.ts[nLog];\n"
1324
" var ti = fr.ti[nLog];\n"
1325
" var tt = fr.tt[nLog];\n"
1326
" var start = i == nFrameLast ? StartIndex-1-fr.LogStart[nLog] : ts.length-1;\n"
1327
"\n"
1328
" for(var j = start; j >= 0; j--)\n"
1329
" {\n"
1330
" var type = tt[j];\n"
1331
" var index = ti[j];\n"
1332
" var time = ts[j];\n"
1333
" if(type == 1)\n"
1334
" {\n"
1335
" StackPos--;\n"
1336
" if(StackPos == 0 && index == TimerIndex)\n"
1337
" {\n"
1338
" return HoverInfo;\n"
1339
" }\n"
1340
" }\n"
1341
" else if(type == 0)\n"
1342
" {\n"
1343
" StackPos++;\n"
1344
" }\n"
1345
" else if(type > 1)\n"
1346
" {\n"
1347
" // var nMetaCount = type - 3;\n"
1348
" // var nMetaIndex = MetaNames[index];\n"
1349
" // if(nMetaIndex in HoverInfo)\n"
1350
" // {\n"
1351
" // HoverInfo[nMetaIndex] += nMetaCount;\n"
1352
" // }\n"
1353
" // else\n"
1354
" // {\n"
1355
" // HoverInfo[nMetaIndex] = nMetaCount;\n"
1356
" // }\n"
1357
" }\n"
1358
" }\n"
1359
" }\n"
1360
"}\n"
1361
"function CalculateAllTimers(fBegin, fEnd)\n"
1362
"{\n"
1363
" var Sum = [];\n"
1364
" var Count = [];\n"
1365
" var Sorted = [];\n"
1366
" for(var i = 0; i < S.TimerInfo.length; ++i)\n"
1367
" {\n"
1368
" Sum.push(0.0);\n"
1369
" Count.push(0);\n"
1370
" Sorted.push(i);\n"
1371
" }\n"
1372
" var nFrameFirst = 0;\n"
1373
" var nFrameLast = S.Frames.length;\n"
1374
"\n"
1375
" var nNumLogs = S.Frames[0].ts.length;\n"
1376
" var StackPosArray = Array(nNumLogs);\n"
1377
" var StackArray = Array(nNumLogs);\n"
1378
" for(var i = 0; i < nNumLogs; ++i)\n"
1379
" {\n"
1380
" StackPosArray[i] = 0;\n"
1381
" StackArray[i] = Array(20);\n"
1382
" }\n"
1383
"\n"
1384
" for(var i = nFrameFirst; i < nFrameLast; i++)\n"
1385
" {\n"
1386
" var fr = S.Frames[i];\n"
1387
" for(nLog = 0; nLog < nNumLogs; nLog++)\n"
1388
" {\n"
1389
" var StackPos = StackPosArray[nLog];\n"
1390
" var Stack = StackArray[nLog];\n"
1391
" var ts = fr.ts[nLog];\n"
1392
" var ti = fr.ti[nLog];\n"
1393
" var tt = fr.tt[nLog];\n"
1394
" var count = ts.length;\n"
1395
" for(j = 0; j < count; j++)\n"
1396
" {\n"
1397
" var type = tt[j];\n"
1398
" var index = ti[j];\n"
1399
" var time = ts[j];\n"
1400
" if(type == 1 && time < fEnd) //enter\n"
1401
" {\n"
1402
" Stack[StackPos] = time < fBegin ? fBegin : time;\n"
1403
" if(StackArray[nLog][StackPos] != time)\n"
1404
" {\n"
1405
" console.log(\'fail fail fail\');\n"
1406
" }\n"
1407
" StackPos++;\n"
1408
" }\n"
1409
" else if(type == 0) // leave\n"
1410
" {\n"
1411
" if(StackPos>0)\n"
1412
" {\n"
1413
" var timeend = time;\n"
1414
" StackPos--;\n"
1415
" timestart = Stack[StackPos];\n"
1416
" var TimeDelta = timeend - timestart;\n"
1417
" Sum[index] += TimeDelta;\n"
1418
" Count[index]++;\n"
1419
" }\n"
1420
" }\n"
1421
" }\n"
1422
" StackPosArray[nLog] = StackPos;\n"
1423
" }\n"
1424
" }\n"
1425
" Sorted.sort(function(a,b){ return Sum[b] - Sum[a]; } );\n"
1426
" var Result = {\"Sorted\" : Sorted, \"Sum\" : Sum, \"Count\" : Count};\n"
1427
" return Result;\n"
1428
"}\n"
1429
"\n"
1430
"function CalculateTimers2(Result, TimerIndex, Time, SContext)\n"
1431
"{\n"
1432
" let nFrame = -1;\n"
1433
" for(var i = 0; i < SContext.Frames.length; ++i)\n"
1434
" {\n"
1435
" let F = SContext.Frames[i];\n"
1436
" if(Time > F.framestart && Time <= F.frameend)\n"
1437
" {\n"
1438
" nFrame = i;\n"
1439
" break;\n"
1440
" }\n"
1441
" }\n"
1442
" CalculateTimers(Result, TimerIndex, nFrame, nFrame+1, SContext);\n"
1443
" return nFrame;\n"
1444
"}\n"
1445
"\n"
1446
"function CalculateTimers(Result, TimerIndex, nFrameFirst, nFrameLast, SContext)\n"
1447
"{\n"
1448
" if(!SContext)\n"
1449
" SContext = S;\n"
1450
" if(!nFrameFirst || nFrameFirst < 0)\n"
1451
" nFrameFirst = 0;\n"
1452
" if(!nFrameLast || nFrameLast > SContext.Frames.length)\n"
1453
" nFrameLast = SContext.Frames.length;\n"
1454
" var FrameCount = nFrameLast - nFrameFirst;\n"
1455
" if(0 == FrameCount)\n"
1456
" return;\n"
1457
" var CallCount = 0;\n"
1458
" var Sum = 0;\n"
1459
" var Max = 0;\n"
1460
" var FrameMax = 0;\n"
1461
"\n"
1462
" var nNumLogs = SContext.Frames[0].ts.length;\n"
1463
" var StackPosArray = Array(nNumLogs);\n"
1464
" var StackArray = Array(nNumLogs);\n"
1465
" let StackIndexArray = Array(nNumLogs);\n"
1466
" for(var i = 0; i < nNumLogs; ++i)\n"
1467
" {\n"
1468
" StackPosArray[i] = 0;\n"
1469
" StackArray[i] = Array(32);\n"
1470
" StackIndexArray[i] = Array(32);\n"
1471
" }\n"
1472
"\n"
1473
" for(var i = nFrameFirst; i < nFrameLast; i++)\n"
1474
" {\n"
1475
" let FrameSum = 0;\n"
1476
" let fr = SContext.Frames[i];\n"
1477
" for(nLog = 0; nLog < nNumLogs; nLog++)\n"
1478
" {\n"
1479
" let StackPos = StackPosArray[nLog];\n"
1480
" let Stack = StackArray[nLog];\n"
1481
" let StackIndex = StackIndexArray[nLog];\n"
1482
" var ts = fr.ts[nLog];\n"
1483
" var ti = fr.ti[nLog];\n"
1484
" var tt = fr.tt[nLog];\n"
1485
" var count = ts.length;\n"
1486
" for(var j = 0; j < count; j++)\n"
1487
" {\n"
1488
" var type = tt[j];\n"
1489
" var index = ti[j];\n"
1490
" var time = ts[j];\n"
1491
" if(index < ETOKEN_MAX)\n"
1492
" {\n"
1493
" if(type == 1) //enter\n"
1494
" {\n"
1495
" //push\n"
1496
" Stack[StackPos] = time;\n"
1497
" StackIndex[StackPos] = index;\n"
1498
" if(StackArray[nLog][StackPos] != time)\n"
1499
" {\n"
1500
" console.log(\'fail fail fail\');\n"
1501
" }\n"
1502
" StackPos++;\n"
1503
" }\n"
1504
" else if(type == 0) // leave\n"
1505
" {\n"
1506
" var timestart;\n"
1507
" var timeend = time;\n"
1508
" if(StackPos>0)\n"
1509
" {\n"
1510
" StackPos--;\n"
1511
" timestart = Stack[StackPos];\n"
1512
" }\n"
1513
" else\n"
1514
" {\n"
1515
" timestart = SContext.Frames[nFrameFirst].framestart;\n"
1516
" }\n"
1517
" if(index == TimerIndex)\n"
1518
" {\n"
1519
" let TimeDelta = timeend - timestart;\n"
1520
" CallCount++;\n"
1521
" FrameSum += TimeDelta;\n"
1522
" Sum += TimeDelta;\n"
1523
" if(TimeDelta > Max)\n"
1524
" Max = TimeDelta;\n"
1525
" }\n"
1526
" }\n"
1527
" else\n"
1528
" {\n"
1529
" //meta\n"
1530
" }\n"
1531
" }\n"
1532
" }\n"
1533
" if(i == nFrameLast - 1)\n"
1534
" {\n"
1535
" for(var j = 0; j < StackPos; ++j)\n"
1536
" {\n"
1537
" if(StackIndex[j] == TimerIndex)\n"
1538
" {\n"
1539
" let LastFrameEnd = SContext.Frames[nFrameLast-1].frameend;\n"
1540
" let TimeDelta = LastFrameEnd - Stack[j];\n"
1541
" CallCount++;\n"
1542
" FrameSum += TimeDelta;\n"
1543
" Sum += TimeDelta;\n"
1544
" if(TimeDelta > Max)\n"
1545
" Max = TimeDelta;\n"
1546
" break;\n"
1547
" }\n"
1548
" }\n"
1549
"\n"
1550
" }\n"
1551
" if(FrameSum > FrameMax)\n"
1552
" {\n"
1553
" FrameMax = FrameSum;\n"
1554
" }\n"
1555
" StackPosArray[nLog] = StackPos;\n"
1556
" }\n"
1557
" }\n"
1558
"\n"
1559
" Result.CallCount = CallCount;\n"
1560
" Result.Sum = Sum.toFixed(3);\n"
1561
" Result.Max = Max.toFixed(3);\n"
1562
" Result.Average = (Sum / CallCount).toFixed(3);\n"
1563
" Result.FrameAverage = (Sum / FrameCount).toFixed(3);\n"
1564
" Result.FrameCallAverage = (CallCount / FrameCount).toFixed(3);\n"
1565
" Result.FrameMax = FrameMax.toFixed(3);\n"
1566
" return Result;\n"
1567
"}\n"
1568
"\n"
1569
"function PreprocessCalculateAllTimers()\n"
1570
"{\n"
1571
" ProfileEnter(\"CalculateAllTimers\");\n"
1572
" let nFrameFirst = 0;\n"
1573
" let nFrameLast = S.Frames.length;\n"
1574
" let FrameCount = nFrameLast - nFrameFirst;\n"
1575
" if(0 == FrameCount)\n"
1576
" return;\n"
1577
" for(let j = 0; j < S.TimerInfo.length; j++)\n"
1578
" {\n"
1579
" S.TimerInfo[j].CallCount = 0;\n"
1580
" S.TimerInfo[j].CallCountExcl = 0;\n"
1581
" S.TimerInfo[j].Sum = 0;\n"
1582
" S.TimerInfo[j].SumExcl = 0;\n"
1583
" S.TimerInfo[j].Max = 0;\n"
1584
" S.TimerInfo[j].MaxExcl = 0;\n"
1585
" S.TimerInfo[j].Average = 0;\n"
1586
" S.TimerInfo[j].AverageExcl = 0;\n"
1587
" S.TimerInfo[j].FrameAverage = 0;\n"
1588
" S.TimerInfo[j].FrameAverageExcl = 0;\n"
1589
" S.TimerInfo[j].FrameCallAverage = 0;\n"
1590
" S.TimerInfo[j].FrameMax = 0;\n"
1591
" S.TimerInfo[j].FrameMaxExcl = 0;\n"
1592
" }\n"
1593
"\n"
1594
"\n"
1595
" let nNumLogs = S.Frames[0].ts.length;\n"
1596
" let ChildTimeStackArray = new Array(nNumLogs);\n"
1597
" let TimerStackArray = new Array(nNumLogs);\n"
1598
" let StackPosArray = Array(nNumLogs);\n"
1599
" let StackArray = Array(nNumLogs);\n"
1600
" function ClearArray(a)\n"
1601
" {\n"
1602
" for(let j = 0; j < a.length; ++j)\n"
1603
" a[j] = 0;\n"
1604
" }\n"
1605
" for(let i = 0; i < nNumLogs; ++i)\n"
1606
" {\n"
1607
" StackPosArray[i] = 0;\n"
1608
" StackArray[i] = Array(20);\n"
1609
" ChildTimeStackArray[i] = Array(32);\n"
1610
" ClearArray(ChildTimeStackArray[i]);\n"
1611
" TimerStackArray[i] = Array(S.TimerInfo.length);\n"
1612
" ClearArray(TimerStackArray[i]); \n"
1613
" }\n"
1614
"\n"
1615
" for(let i = nFrameFirst; i < nFrameLast; i++)\n"
1616
" {\n"
1617
" for(let j = 0; j < S.TimerInfo.length; j++)\n"
1618
" {\n"
1619
" S.TimerInfo[j].FrameSum = 0;\n"
1620
" S.TimerInfo[j].FrameSumExcl = 0;\n"
1621
" }\n"
1622
"\n"
1623
" let fr = S.Frames[i];\n"
1624
" for(nLog = 0; nLog < nNumLogs; nLog++)\n"
1625
" {\n"
1626
" let StackPos = StackPosArray[nLog];\n"
1627
" let Stack = StackArray[nLog];\n"
1628
" let ChildTimeStack = ChildTimeStackArray[nLog];\n"
1629
" let TimerStack = TimerStackArray[nLog];\n"
1630
"\n"
1631
" let ts = fr.ts[nLog];\n"
1632
" let ti = fr.ti[nLog];\n"
1633
" let tt = fr.tt[nLog];\n"
1634
" let count = ts.length;\n"
1635
" for(j = 0; j < count; j++)\n"
1636
" {\n"
1637
" let type = tt[j];\n"
1638
" let index = ti[j];\n"
1639
" let time = ts[j];\n"
1640
" if(index < ETOKEN_MAX && index >= 0)\n"
1641
" {\n"
1642
" if(type == 1) //enter\n"
1643
" {\n"
1644
" //push\n"
1645
" Stack[StackPos] = time;\n"
1646
" TimerStack[index] += 1;\n"
1647
" if(StackArray[nLog][StackPos] != time)\n"
1648
" {\n"
1649
" console.log(\'fail fail fail\');\n"
1650
" }\n"
1651
" StackPos++;\n"
1652
" }\n"
1653
" else if(type == 0) // leave\n"
1654
" {\n"
1655
" let TimeStart;\n"
1656
" let TimeEnd = time;\n"
1657
" let TimeChild = 0;\n"
1658
" if(StackPos>0)\n"
1659
" {\n"
1660
" StackPos--;\n"
1661
" TimeStart = Stack[StackPos];\n"
1662
" TimeChild = ChildTimeStack[StackPos];\n"
1663
" ChildTimeStack[StackPos] = 0;\n"
1664
" }\n"
1665
" else\n"
1666
" {\n"
1667
" TimeStart = S.Frames[nFrameFirst].framestart;\n"
1668
" }\n"
1669
" let TimerIsRoot = TimerStack[index] == 0 || (0 == --TimerStack[index]);\n"
1670
" let TimeDelta = TimeEnd - TimeStart;\n"
1671
" let TimeDeltaExcl = Math.max(0, TimeDelta - TimeChild);\n"
1672
" S.TimerInfo[index].SumExcl += TimeDeltaExcl;\n"
1673
" S.TimerInfo[index].FrameSumExcl += TimeDeltaExcl;\n"
1674
" S.TimerInfo[index].CallCountExcl++;\n"
1675
" if(TimeDeltaExcl > S.TimerInfo[index].MaxExcl)\n"
1676
" {\n"
1677
" S.TimerInfo[index].MaxExcl = TimeDeltaExcl;\n"
1678
" }\n"
1679
"\n"
1680
" if(TimerIsRoot)\n"
1681
" {\n"
1682
" S.TimerInfo[index].CallCount++;\n"
1683
" S.TimerInfo[index].FrameSum += TimeDelta;\n"
1684
" S.TimerInfo[index].Sum += TimeDelta;\n"
1685
" if(TimeDelta > S.TimerInfo[index].Max)\n"
1686
" {\n"
1687
" S.TimerInfo[index].Max = TimeDelta;\n"
1688
" S.TimerInfo[index].worst = TimeDelta;\n"
1689
" S.TimerInfo[index].worststart = TimeStart;\n"
1690
" S.TimerInfo[index].worstend = TimeEnd;\n"
1691
" S.TimerInfo[index].worstthread = nLog;\n"
1692
" }\n"
1693
" }\n"
1694
" if(StackPos > 0)\n"
1695
" ChildTimeStack[StackPos-1] += TimeDelta;\n"
1696
" }\n"
1697
" }\n"
1698
" }\n"
1699
" for(let j = 0; j < S.TimerInfo.length; j++)\n"
1700
" {\n"
1701
" if(S.TimerInfo[j].FrameSum > S.TimerInfo[j].FrameMax)\n"
1702
" {\n"
1703
" S.TimerInfo[j].FrameMax = S.TimerInfo[j].FrameSum;\n"
1704
" }\n"
1705
" if(S.TimerInfo[j].FrameSumExcl > S.TimerInfo[j].FrameMaxExcl)\n"
1706
" {\n"
1707
" S.TimerInfo[j].FrameMaxExcl = S.TimerInfo[j].FrameSumExcl;\n"
1708
" }\n"
1709
"\n"
1710
" }\n"
1711
" StackPosArray[nLog] = StackPos;\n"
1712
" }\n"
1713
"\n"
1714
"\n"
1715
" }\n"
1716
"\n"
1717
" for(let j = 0; j < S.TimerInfo.length; j++)\n"
1718
" {\n"
1719
" let CallCount = S.TimerInfo[j].CallCount;\n"
1720
" let Sum = S.TimerInfo[j].Sum.toFixed(3);\n"
1721
" let SumExcl = S.TimerInfo[j].SumExcl.toFixed(3);\n"
1722
" let Max = S.TimerInfo[j].Max.toFixed(3);\n"
1723
" let MaxExcl = S.TimerInfo[j].MaxExcl.toFixed(3);\n"
1724
" let Average = (S.TimerInfo[j].Sum / S.TimerInfo[j].CallCount).toFixed(3);\n"
1725
" let AverageExcl = (S.TimerInfo[j].SumExcl / S.TimerInfo[j].CallCountExcl).toFixed(3);\n"
1726
" let FrameAverage = (S.TimerInfo[j].Sum / FrameCount).toFixed(3);\n"
1727
" let FrameAverageExcl = (S.TimerInfo[j].SumExcl / FrameCount).toFixed(3);\n"
1728
" let FrameCallAverage = (S.TimerInfo[j].CallCount / FrameCount).toFixed(3);\n"
1729
" let FrameMax = S.TimerInfo[j].FrameMax.toFixed(3);\n"
1730
" let FrameMaxExcl = S.TimerInfo[j].FrameMaxExcl.toFixed(3);\n"
1731
"\n"
1732
" S.TimerInfo[j].CallCount = CallCount;\n"
1733
" S.TimerInfo[j].Sum = Sum;\n"
1734
" S.TimerInfo[j].SumExcl = SumExcl;\n"
1735
" S.TimerInfo[j].Max = Max;\n"
1736
" S.TimerInfo[j].MaxExcl = MaxExcl;\n"
1737
" S.TimerInfo[j].Average = Average;\n"
1738
" S.TimerInfo[j].AverageExcl = AverageExcl;\n"
1739
" S.TimerInfo[j].FrameAverage = FrameAverage;\n"
1740
" S.TimerInfo[j].FrameAverageExcl = FrameAverageExcl;\n"
1741
" S.TimerInfo[j].FrameCallAverage = FrameCallAverage;\n"
1742
" S.TimerInfo[j].FrameMax = FrameMax;\n"
1743
" S.TimerInfo[j].FrameMaxExcl = FrameMaxExcl; \n"
1744
" }\n"
1745
" ProfileLeave();\n"
1746
"}\n"
1747
"\n"
1748
"var FlashFrames = 10;\n"
1749
"var FlashFrameCounter = 0;\n"
1750
"var FlashMessage = \'\';\n"
1751
"function TimeString(Diff)\n"
1752
"{\n"
1753
" var DiffString = \"0 sec\";\n"
1754
" var DiffTable = [1,60,60*60,60*60*24];\n"
1755
" var DiffNameTable = [\"sec\", \"min\", \"hr\", \"day\"];\n"
1756
" for(var i = 0; i < DiffTable.length; ++i)\n"
1757
" {\n"
1758
" if(Diff >= DiffTable[i])\n"
1759
" {\n"
1760
" DiffString = Math.floor(Diff / DiffTable[i]) + \" \" + DiffNameTable[i];\n"
1761
" }\n"
1762
" }\n"
1763
" return DiffString;\n"
1764
"\n"
1765
"}\n"
1766
"function ShowFlashMessage(Message, FrameCount)\n"
1767
"{\n"
1768
" FlashMessage = Message;\n"
1769
" FlashFrameCounter = FrameCount;\n"
1770
"}\n"
1771
"function OnPageReady()\n"
1772
"{\n"
1773
" var DumpDate = S.DumpUtcCaptureTime;\n"
1774
" var CurrentDate = Date.now() / 1000;\n"
1775
" var Diff = CurrentDate - DumpDate;\n"
1776
" var Limit = 10*60;//flash old message when loading captures older than 10 minutes\n"
1777
" if(Diff > Limit)\n"
1778
" {\n"
1779
" ShowFlashMessage(\"Captured \" + TimeString(Diff) + \" ago\", 100);\n"
1780
" }\n"
1781
"}\n"
1782
"\n"
1783
"function DrawFlash";
1784
1785
const size_t g_MicroProfileHtml_end_0_size = sizeof(g_MicroProfileHtml_end_0);
1786
const char g_MicroProfileHtml_end_1[] =
1787
"Message(context)\n"
1788
"{\n"
1789
" if(FlashFrameCounter > 0)\n"
1790
" {\n"
1791
" if(FlashFrameCounter>1)\n"
1792
" {\n"
1793
" var FlashPrc = Math.sin(FlashFrameCounter / FlashFrames);\n"
1794
" context.font = FontFlash;\n"
1795
" context.globalAlpha = FlashPrc * 0.35 + 0.5;\n"
1796
" context.textAlign = \'center\';\n"
1797
" context.fillStyle = \'red\';\n"
1798
" context.fillText(FlashMessage, nWidth * 0.5, 50);\n"
1799
" context.globalAlpha = 1;\n"
1800
" context.textAlign = \'left\';\n"
1801
" context.font = Font;\n"
1802
" }\n"
1803
" FlashFrameCounter -= 1;\n"
1804
"\n"
1805
" }\n"
1806
"}\n"
1807
"\n"
1808
"function DrawCaptureInfo(context)\n"
1809
"{\n"
1810
" context.fillStyle = \'white\';\n"
1811
" context.textAlign = \'right\';\n"
1812
" context.font = Font;\n"
1813
" var DumpDate = S.DumpUtcCaptureTime;\n"
1814
" var CurrentDate = Date.now() / 1000;\n"
1815
" var Diff = CurrentDate - DumpDate;\n"
1816
" var DiffString = TimeString(Diff) + \" ago\";\n"
1817
" context.fillText(new Date(DumpDate*1000).toLocaleString(), nWidth, FontHeight);\n"
1818
" if(Mode == ModeTimers || Mode == ModeTimers_Threads || Mode == ModeTimers_Groups)\n"
1819
" {\n"
1820
" context.fillText(\"Timer Frames: \" + S.AggregateInfo.Frames, nWidth, FontHeight*2);\n"
1821
" }\n"
1822
" else\n"
1823
" {\n"
1824
" context.fillText(\"Detailed Frames \"+ S.Frames.length, nWidth, FontHeight*2);\n"
1825
" }\n"
1826
" context.fillText(S.DumpHost, nWidth, FontHeight*3);\n"
1827
" context.fillText(DiffString, nWidth, FontHeight*4);\n"
1828
" context.textAlign = \'left\';\n"
1829
" DrawFlashMessage(context);\n"
1830
"}\n"
1831
"\n"
1832
"function DrawDetailedFrameHistory()\n"
1833
"{\n"
1834
" ProfileEnter(\"DrawDetailedFrameHistory\");\n"
1835
" var x = HistoryViewMouseX;\n"
1836
"\n"
1837
" var context = CanvasHistory.getContext(\'2d\');\n"
1838
" context.clearRect(0, 0, CanvasHistory.width, CanvasHistory.height);\n"
1839
"\n"
1840
" let HistoryHeight = CanvasHistory.height;\n"
1841
"\n"
1842
" var GreenTime = (TargetTime * 0.9);\n"
1843
" var RedBegin = (TargetTime * 1.1);\n"
1844
" var LerpDist = 1.0 / (RedBegin - GreenTime);\n"
1845
"\n"
1846
"\n"
1847
" var fHeight = nHistoryHeight;\n"
1848
" var fWidth = nWidth / S.Frames.length;\n"
1849
" var fHeightScale = fHeight / ReferenceTime;\n"
1850
" var fX = 0;\n"
1851
" var FrameIndex = -1;\n"
1852
" var MouseDragging = MouseDragState != MouseDragOff;\n"
1853
" RangeCpuHistory = RangeInit();\n"
1854
" RangeGpuHistory = RangeInit()\n"
1855
"\n"
1856
" var FrameFirst = -1;\n"
1857
" var FrameLast = nWidth;\n"
1858
" var fDetailedOffsetEnd = fDetailedOffset + fDetailedRange;\n"
1859
" for(i = 0; i < S.Frames.length; i++)\n"
1860
" {\n"
1861
" var fMs = S.Frames[i].frameend - S.Frames[i].framestart;\n"
1862
"\n"
1863
" var fPrc = (fMs - GreenTime) * LerpDist;\n"
1864
" fPrc = Clamp(fPrc, 0, 1);\n"
1865
" var color = LerpColor(fPrc);\n"
1866
"\n"
1867
"\n"
1868
"\n"
1869
" if(fDetailedOffset <= S.Frames[i].frameend && fDetailedOffset >= S.Frames[i].framestart)\n"
1870
" {\n"
1871
" var lerp = (fDetailedOffset - S.Frames[i].framestart) / (S.Frames[i].frameend - S.Frames[i].framestart);\n"
1872
" FrameFirst = fX + fWidth * lerp;\n"
1873
" }\n"
1874
" if(fDetailedOffsetEnd <= S.Frames[i].frameend && fDetailedOffsetEnd >= S.Frames[i].framestart)\n"
1875
" {\n"
1876
" var lerp = (fDetailedOffsetEnd - S.Frames[i].framestart) / (S.Frames[i].frameend - S.Frames[i].framestart);\n"
1877
" FrameLast = fX + fWidth * lerp;\n"
1878
" }\n"
1879
" var fH = fHeightScale * fMs;\n"
1880
" var bMouse = x > fX && x < fX + fWidth;\n"
1881
" if(bMouse && !MouseDragging)\n"
1882
" {\n"
1883
" context.fillStyle = FRAME_HISTORY_COLOR_GPU;\n"
1884
" RangeCpuHistory.Begin = S.Frames[i].framestart;\n"
1885
" RangeCpuHistory.End = S.Frames[i].frameend;\n"
1886
" if(S.Frames[i].framestartgpu)\n"
1887
" {\n"
1888
" RangeGpuHistory.Begin = S.Frames[i].framestartgpu;\n"
1889
" RangeGpuHistory.End = S.Frames[i].frameendgpu;\n"
1890
" }\n"
1891
" FrameIndex = i;\n"
1892
" }\n"
1893
" else\n"
1894
" {\n"
1895
" context.fillStyle = color;\n"
1896
" }\n"
1897
" context.fillRect(fX, fHeight - fH, fWidth-1, fH);\n"
1898
" fX += fWidth;\n"
1899
" }\n"
1900
"\n"
1901
" var fRangeHistoryBegin = FrameFirst;\n"
1902
" var fRangeHistoryEnd = FrameLast;\n"
1903
" var X = fRangeHistoryBegin;\n"
1904
" var Y = 0;\n"
1905
" var W = fRangeHistoryEnd - fRangeHistoryBegin;\n"
1906
" context.globalAlpha = 0.35;\n"
1907
" context.fillStyle = \'#009900\';\n"
1908
" context.fillRect(X, Y, W, fHeight);\n"
1909
" context.globalAlpha = 1;\n"
1910
" context.strokeStyle = \'#00ff00\';\n"
1911
" context.beginPath();\n"
1912
" context.moveTo(X, Y);\n"
1913
" context.lineTo(X, Y+fHeight);\n"
1914
" context.moveTo(X+W, Y);\n"
1915
" context.lineTo(X+W, Y+fHeight);\n"
1916
" context.stroke();\n"
1917
"\n"
1918
" {\n"
1919
" var fH = fHeight - fHeightScale * TargetTime;\n"
1920
" context.fillStyle = \'wheat\';\n"
1921
" context.strokeStyle = \'wheat\';\n"
1922
" context.beginPath();\n"
1923
" context.moveTo(0, fH);\n"
1924
" context.lineTo(nWidth, fH);\n"
1925
" // context.closePath();\n"
1926
" context.stroke();\n"
1927
" var YText;\n"
1928
" if(fH > HistoryHeight * 0.25)\n"
1929
" {\n"
1930
" YText = fH - FontAscent;\n"
1931
" }\n"
1932
" else\n"
1933
" {\n"
1934
" YText = fH + FontHeight;\n"
1935
" }\n"
1936
" context.fillText(TargetTime + \'ms\', 3, YText);\n"
1937
" context.textAlign=\'right\';\n"
1938
" context.fillText(FormatTime(ReferenceTime) + \'ms\', nWidth, FontHeight);\n"
1939
" context.textAlign=\'left\';\n"
1940
" }\n"
1941
"\n"
1942
"\n"
1943
" DrawCaptureInfo(context);\n"
1944
"\n"
1945
" if(FrameIndex>=0 && !MouseDragging)\n"
1946
" {\n"
1947
" var StringArray = [];\n"
1948
" StringArray.push(\"Frame\");\n"
1949
" StringArray.push(\"\" + FrameIndex);\n"
1950
" StringArray.push(\"Time\");\n"
1951
" StringArray.push(\"\" + (S.Frames[FrameIndex].frameend - S.Frames[FrameIndex].framestart).toFixed(3));\n"
1952
"\n"
1953
" DrawToolTip(StringArray, CanvasHistory, HistoryViewMouseX, HistoryViewMouseY+20);\n"
1954
"\n"
1955
" }\n"
1956
" ProfileLeave();\n"
1957
"}\n"
1958
"function TimeToMsString(Time)\n"
1959
"{\n"
1960
" return Time.toFixed(3) + \"ms\";\n"
1961
"}\n"
1962
"function TimeToString(Time)\n"
1963
"{\n"
1964
" if(Time > 1000)\n"
1965
" {\n"
1966
" return (Time/1000.0).toFixed(0) +\"s\";\n"
1967
" }\n"
1968
" else if(Time > 0.9)\n"
1969
" {\n"
1970
" return Time.toFixed(0) + \"ms\";\n"
1971
" }\n"
1972
" else if(Time > 0.0009)\n"
1973
" {\n"
1974
" return (Time*1000).toFixed(0) + \"us\";\n"
1975
" }\n"
1976
" else\n"
1977
" {\n"
1978
" return (Time*1000000).toFixed(0) + \"ns\";\n"
1979
" }\n"
1980
"}\n"
1981
"\n"
1982
"function DrawDetailedBackground(context)\n"
1983
"{\n"
1984
" var fMs = fDetailedRange;\n"
1985
" var fMsEnd = fMs + fDetailedOffset;\n"
1986
" var fMsToScreen = nWidth / fMs;\n"
1987
" var fRate = Math.floor(2*((Math.log(fMs)/Math.log(10))-1))/2;\n"
1988
" var fStep = Math.pow(10, fRate);\n"
1989
" var fRcpStep = 1.0 / fStep;\n"
1990
" var nColorIndex = Math.floor(fDetailedOffset * fRcpStep) % 2;\n"
1991
" if(nColorIndex < 0)\n"
1992
" nColorIndex = -nColorIndex;\n"
1993
" var fStart = Math.floor(fDetailedOffset * fRcpStep) * fStep;\n"
1994
" var fHeight = CanvasDetailedView.height;\n"
1995
" var fScaleX = nWidth / fDetailedRange;\n"
1996
" var HeaderString = TimeToString(fStep);\n"
1997
" context.textAlign = \'center\';\n"
1998
" for(f = fStart; f < fMsEnd; )\n"
1999
" {\n"
2000
" var fNext = f + fStep;\n"
2001
" var X = (f - fDetailedOffset) * fScaleX;\n"
2002
" var W = (fNext-f)*fScaleX;\n"
2003
" context.fillStyle = nBackColors[nColorIndex];\n"
2004
" context.fillRect(X, 0, W+2, fHeight);\n"
2005
" nColorIndex = 1 - nColorIndex;\n"
2006
" context.fillStyle = \'#777777\'\n"
2007
" context.fillText(HeaderString, X + W * 0.5, 10);\n"
2008
" context.fillText(HeaderString, X + W * 0.5, nHeight - 10);\n"
2009
" f = fNext;\n"
2010
" }\n"
2011
" context.textAlign = \'left\';\n"
2012
" var fScaleX = nWidth / fDetailedRange;\n"
2013
" context.globalAlpha = 0.5;\n"
2014
" context.strokeStyle = \'#bbbbbb\';\n"
2015
" context.beginPath();\n"
2016
" for(var i = 0; i < S.Frames.length; i++)\n"
2017
" {\n"
2018
" var frfr = S.Frames[i];\n"
2019
" if(frfr.frameend < fDetailedOffset || frfr.framestart > fDetailedOffset + fDetailedRange)\n"
2020
" {\n"
2021
" continue;\n"
2022
" }\n"
2023
" var X = (frfr.framestart - fDetailedOffset) * fScaleX;\n"
2024
" if(X >= 0 && X < nWidth)\n"
2025
" {\n"
2026
" context.moveTo(X, 0);\n"
2027
" context.lineTo(X, nHeight);\n"
2028
" }\n"
2029
" }\n"
2030
" context.stroke();\n"
2031
" context.globalAlpha = 1;\n"
2032
"\n"
2033
"}\n"
2034
"\n"
2035
"function DrawToolTip(StringArray, Canvas, x, y, bSecondary)\n"
2036
"{\n"
2037
" var context = Canvas.getContext(\'2d\');\n"
2038
" context.font = Font;\n"
2039
" var WidthArray = Array(StringArray.length);\n"
2040
" var nMaxWidth = 0;\n"
2041
" var nHeight = 0;\n"
2042
" for(i = 0; i < StringArray.length; i += 2)\n"
2043
" {\n"
2044
" var nWidth0 = context.measureText(StringArray[i]).width;\n"
2045
" var nWidth1 = context.measureText(StringArray[i+1]).width;\n"
2046
" var nSum = nWidth0 + nWidth1;\n"
2047
" WidthArray[i] = nWidth0;\n"
2048
" WidthArray[i+1] = nWidth1;\n"
2049
" if(nSum > nMaxWidth)\n"
2050
" {\n"
2051
" nMaxWidth = nSum;\n"
2052
" }\n"
2053
" nHeight += BoxHeight;\n"
2054
" }\n"
2055
" nMaxWidth += 15;\n"
2056
" //bounds check.\n"
2057
" if(!bSecondary)\n"
2058
" {\n"
2059
" var CanvasRect = Canvas.getBoundingClientRect();\n"
2060
" if(y + nHeight > CanvasRect.height)\n"
2061
" {\n"
2062
" y = CanvasRect.height - nHeight;\n"
2063
" x += 20;\n"
2064
" }\n"
2065
" if(x + nMaxWidth > CanvasRect.width)\n"
2066
" {\n"
2067
" x = CanvasRect.width - nMaxWidth;\n"
2068
" }\n"
2069
" }\n"
2070
" else\n"
2071
" {\n"
2072
" x -= nMaxWidth;\n"
2073
" }\n"
2074
" context.fillStyle = \'black\';\n"
2075
" context.fillRect(x-1, y, nMaxWidth+2, nHeight);\n"
2076
" context.fillStyle = \'white\';\n"
2077
"\n"
2078
" var XPos = x;\n"
2079
" var XPosRight = x + nMaxWidth;\n"
2080
" var YPos = y + BoxHeight-2;\n"
2081
" for(i = 0; i < StringArray.length; i += 2)\n"
2082
" {\n"
2083
" context.fillText(StringArray[i], XPos, YPos);\n"
2084
" context.fillText(StringArray[i+1], XPosRight - WidthArray[i+1], YPos);\n"
2085
" YPos += BoxHeight;\n"
2086
" }\n"
2087
" return {\"x\":x, \"y\":y};\n"
2088
"}\n"
2089
"\n"
2090
"function BuildToolTipDetailed(So, nHoverToken, HoverTokenOwner, bSecond, SelectedRangeCpu, SelectedRangeGpu)\n"
2091
"{\n"
2092
" let StringArray = [];\n"
2093
" let groupid = So.TimerInfo[nHoverToken].group;\n"
2094
" \n"
2095
" if(S2 && S2.AA)\n"
2096
" {\n"
2097
" StringArray.push(\"Capture\");\n"
2098
" StringArray.push(So == S ? \"Main\" : \"Other\");\n"
2099
" }\n"
2100
"\n"
2101
" if(nHoverToken > -1)\n"
2102
" {\n"
2103
" StringArray.push(\"Timer\");\n"
2104
" StringArray.push(So.TimerInfo[nHoverToken].name);\n"
2105
" StringArray.push(\"Group\");\n"
2106
" StringArray.push(So.GroupInfo[groupid].name);\n"
2107
" }\n"
2108
" else\n"
2109
" {\n"
2110
" StringArray.push(\"\");\n"
2111
" StringArray.push(\"\");\n"
2112
" StringArray.push(\"\");\n"
2113
" StringArray.push(\"\");\n"
2114
" }\n"
2115
" StringArray.push(\"\");\n"
2116
" StringArray.push(\"\");\n"
2117
"\n"
2118
" if(RangeValid(SelectedRangeGpu))\n"
2119
" {\n"
2120
" StringArray.push(\"GPU Time\");\n"
2121
" StringArray.push((SelectedRangeGpu.End-SelectedRangeGpu.Begin).toFixed(3));\n"
2122
" }\n"
2123
" if(RangeValid(SelectedRangeCpu))\n"
2124
" {\n"
2125
"\n"
2126
" StringArray.push(\"CPU Time\");\n"
2127
" StringArray.push((SelectedRangeCpu.End-SelectedRangeCpu.Begin).toFixed(3));\n"
2128
" }\n"
2129
"\n"
2130
" if(RangeValid(SelectedRangeGpu))\n"
2131
" {\n"
2132
" StringArray.push(\"\");\n"
2133
" StringArray.push(\"\");\n"
2134
" StringArray.push(\"GPU Aggregates\");\n"
2135
" StringArray.push(\"\");\n"
2136
" }\n"
2137
"\n"
2138
" StringArray.push(\"\");\n"
2139
" StringArray.push(\"\");\n"
2140
" StringArray.push(\"Total\");\n"
2141
" StringArray.push(\"\" + So.TimerInfo[nHoverToken].Sum);\n"
2142
" StringArray.push(\"Max\");\n"
2143
" StringArray.push(\"\" + So.TimerInfo[nHoverToken].Max);\n"
2144
" StringArray.push(\"Average\");\n"
2145
" StringArray.push(\"\" + So.TimerInfo[nHoverToken].Average);\n"
2146
" StringArray.push(\"Count\");\n"
2147
" StringArray.push(\"\" + So.TimerInfo[nHoverToken].CallCount);\n"
2148
"\n"
2149
" StringArray.push(\"\");\n"
2150
" StringArray.push(\"\");\n"
2151
" StringArray.push(\"Excl Total\");\n"
2152
" StringArray.push(\"\" + So.TimerInfo[nHoverToken].SumExcl);\n"
2153
" StringArray.push(\"Excl Max\");\n"
2154
" StringArray.push(\"\" + So.TimerInfo[nHoverToken].MaxExcl);\n"
2155
" StringArray.push(\"Excl Average\");\n"
2156
" StringArray.push(\"\" + So.TimerInfo[nHoverToken].AverageExcl);\n"
2157
" StringArray.push(\"Excl Count\");\n"
2158
" StringArray.push(\"\" + So.TimerInfo[nHoverToken].CallCountExcl);\n"
2159
"\n"
2160
" StringArray.push(\"\");\n"
2161
" StringArray.push(\"\");\n"
2162
" StringArray.push(\"Max/Frame\");\n"
2163
" StringArray.push(\"\" + So.TimerInfo[nHoverToken].FrameMax);\n"
2164
" StringArray.push(\"Average Time/Frame\");\n"
2165
" StringArray.push(\"\" + So.TimerInfo[nHoverToken].FrameAverage);\n"
2166
" StringArray.push(\"Average Count/Frame\");\n"
2167
" StringArray.push(\"\" + So.TimerInfo[nHoverToken].FrameCallAverage);\n"
2168
"\n"
2169
" StringArray.push(\"\");\n"
2170
" StringArray.push(\"\");\n"
2171
" StringArray.push(\"Excl Max/Frame\");\n"
2172
" StringArray.push(\"\" + So.TimerInfo[nHoverToken].FrameMaxExcl);\n"
2173
" StringArray.push(\"Excl Average Time/Frame\");\n"
2174
" StringArray.push(\"\" + So.TimerInfo[nHoverToken].FrameAverageExcl);\n"
2175
"\n"
2176
"\n"
2177
" let Time = fDetailedOffset + fDetailedRange * (DetailedViewMouseX / nWidth);\n"
2178
" if(bSecond)\n"
2179
" Time += fDetailedOffsetSecond;\n"
2180
" let FrameTime = new Object();\n"
2181
" let Frame = CalculateTimers2(FrameTime, nHoverToken, Time, S);\n"
2182
"\n"
2183
" StringArray.push(\"\");\n"
2184
" StringArray.push(\"\");\n"
2185
"\n"
2186
" StringArray.push(\"Detailed Capture\");\n"
2187
" StringArray.push(\"\");\n"
2188
" StringArray.push(\"Frames\");\n"
2189
" StringArray.push(So.Frames.length);\n"
2190
" StringArray.push(\"Time\");\n"
2191
" StringArray.push(DetailedTotal(So).toFixed(2) + \"ms\");\n"
2192
" return StringArray;\n"
2193
"}\n"
2194
"\n"
2195
"\n"
2196
"function DrawHoverToolTip()\n"
2197
"{\n"
2198
" ProfileEnter(\"DrawHoverToolTip\");\n"
2199
" let StringArray = [];\n"
2200
" let StringArray2;\n"
2201
"\n"
2202
"\n"
2203
" if(Mode == ModeDetailed)\n"
2204
" {\n"
2205
" if(RangeValid(RangeSelect) && RangeSelect.Index >= 0)\n"
2206
" {\n"
2207
" let Source = RangeSelect.Second ? S2 : S;\n"
2208
" let ti = Source.TimerInfo[RangeSelect.Index];\n"
2209
" let isGpu = Source.GroupInfo[ti.group].isgpu;\n"
2210
" let cpuRange = isGpu ? null : RangeSelect;\n"
2211
" let gpuRange = isGpu ? RangeSelect : null;\n"
2212
" let StringArrayWorst = BuildToolTipDetailed(Source, RangeSelect.Index, null, 0, cpuRange, gpuRange);\n"
2213
" DrawToolTip(StringArrayWorst, CanvasDetailedView, 0, nHeight);\n"
2214
" }\n"
2215
" }\n"
2216
"\n"
2217
" if(ToolTipImmediate != null)\n"
2218
" {\n"
2219
" DrawToolTip(ToolTipImmediate, CanvasDetailedView, DetailedViewMouseX, DetailedViewMouseY+20);\n"
2220
" ToolTipImmediate = null;\n"
2221
"\n"
2222
" }\n"
2223
" else if(nHoverToken != -1)\n"
2224
" {\n"
2225
"\n"
2226
" let bShowTimers = Mode == ModeTimers || Mode == ModeTimers_Threads || Mode == ModeTimers_Groups;\n"
2227
" if(bShowTimers)\n"
2228
" {\n"
2229
" // var StringArray = [];\n"
2230
" let groupid = S.TimerInfo[nHoverToken].group;\n"
2231
" StringArray.push(\"Timer\");\n"
2232
" StringArray.push(S.TimerInfo[nHoverToken].name);\n"
2233
" StringArray.push(\"Group\");\n"
2234
" StringArray.push(S.GroupInfo[groupid].name);\n"
2235
"\n"
2236
" StringArray.push(\"\");\n"
2237
" StringArray.push(\"\");\n"
2238
" let Timer = S.TimerInfo[nHoverToken];\n"
2239
" StringArray.push(\"Average\");\n"
2240
" StringArray.push(Timer.average);\n"
2241
" StringArray.push(\"Max\");\n"
2242
" StringArray.push(Timer.max);\n"
2243
" StringArray.push(\"Excl Max\");\n"
2244
" StringArray.push(Timer.exclmax);\n"
2245
" StringArray.push(\"Excl Average\");\n"
2246
" StringArray.push(Timer.exclaverage);\n"
2247
" StringArray.push(\"Call Average\");\n"
2248
" StringArray.push(Timer.callaverage);\n"
2249
" StringArray.push(\"Call Count\");\n"
2250
" StringArray.push(Timer.callcount);\n"
2251
"\n"
2252
" StringArray.push(\"\");\n"
2253
" StringArray.push(\"\");\n"
2254
"\n"
2255
"\n"
2256
" StringArray.push(\"Group\");\n"
2257
" StringArray.push(S.GroupInfo[groupid].name);\n"
2258
" StringArray.push(\"Average\");\n"
2259
" StringArray.push(S.GroupInfo[groupid].average);\n"
2260
" StringArray.push(\"Max\");\n"
2261
" StringArray.push(S.GroupInfo[groupid].max);\n"
2262
"\n"
2263
" StringArray.push(\"\");\n"
2264
" StringArray.push(\"\");\n"
2265
"\n"
2266
" StringArray.push(\"Timer Capture\");\n"
2267
" StringArray.push(\"\");\n"
2268
" StringArray.push(\"Frames\");\n"
2269
" StringArray.push(S.AggregateInfo.Frames);\n"
2270
" StringArray.push(\"Time\");\n"
2271
" StringArray.push(S.AggregateInfo.Time.toFixed(2) + \"ms\");\n"
2272
"\n"
2273
"\n"
2274
" }\n"
2275
" else\n"
2276
" {\n"
2277
" let cpu = S == HoverTokenOwner ? RangeCpu : null;\n"
2278
" let gpu = S == HoverTokenOwner ? RangeGpu : null;\n"
2279
" StringArray = BuildToolTipDetailed(S, nHoverToken, HoverTokenOwner, 0, cpu, gpu);\n"
2280
" let nCompareHoverToken = TimerRemapReverse[nHoverToken];\n"
2281
" if(nCompareHoverToken > -1)\n"
2282
" {\n"
2283
" let cpu = S2 == HoverTokenOwner ? RangeCpu : null;\n"
2284
" let gpu = S2 == HoverTokenOwner ? RangeGpu : null;\n"
2285
" StringArray2 = BuildToolTipDetailed(S2, nCompareHoverToken, HoverTokenOwner, 1, cpu, gpu);\n"
2286
" }\n"
2287
" }\n"
2288
" if(ToolTipCorner)\n"
2289
" {\n"
2290
" let R = DrawToolTip(StringArray, CanvasDetailedView, nWidth, nHeight);\n"
2291
" if(StringArray2)\n"
2292
" DrawToolTip(StringArray2, CanvasDetailedView, R.x-15, R.y, 1);\n"
2293
" }\n"
2294
" else\n"
2295
" {\n"
2296
" let R = DrawToolTip(StringArray, CanvasDetailedView, DetailedViewMouseX, DetailedViewMouseY+20);\n"
2297
" if(StringArray2)\n"
2298
" DrawToolTip(StringArray2, CanvasDetailedView, R.x-15, R.y, 1);\n"
2299
" }\n"
2300
" }\n"
2301
" else if(nHoverCSCpu >= 0)\n"
2302
" {\n"
2303
" StringArray = [];\n"
2304
" StringArray.push(\"Context Switch\");\n"
2305
" StringArray.push(\"\");\n"
2306
" StringArray.push(\"\");\n"
2307
" StringArray.push(\"\");\n"
2308
" StringArray.push(\"Cpu\");\n"
2309
" StringArray.push(\"\" + nHoverCSCpu);\n"
2310
" StringArray.push(\"EfficiencyClass\");\n"
2311
" StringArray.push(\"\" + S.CoreEfficiencyClass[nHoverCSCpu]);\n"
2312
" StringArray.push(\"Begin\");\n"
2313
" StringArray.push(\"\" + RangeCpu.Begin);\n"
2314
" StringArray.push(\"End\");\n"
2315
" StringArray.push(\"\" + RangeCpu.End);\n"
2316
" if(ToolTipCorner)\n"
2317
" {\n"
2318
" DrawToolTip(StringArray, CanvasDetailedView, nWidth, nHeight);\n"
2319
" }\n"
2320
" else\n"
2321
" DrawToolTip(StringArray, CanvasDetailedView, DetailedViewMouseX, DetailedViewMouseY+20);\n"
2322
" }\n"
2323
" ProfileLeave();\n"
2324
"}\n"
2325
"\n"
2326
"function FormatMeta(Value, Dec)\n"
2327
"{\n"
2328
" if(!Value)\n"
2329
" {\n"
2330
" Value = \"0\";\n"
2331
" }\n"
2332
" else\n"
2333
" {\n"
2334
" Value = \'\' + Value.toFixed(Dec);\n"
2335
" }\n"
2336
" return Value;\n"
2337
"}\n"
2338
"\n"
2339
"function FilterMatch(FilterArray, value)\n"
2340
"{\n"
2341
" if(!FilterArray)\n"
2342
" return true;\n"
2343
" for(var i = 0; i < FilterArray.length; ++i)\n"
2344
" {\n"
2345
" var res = value.search(FilterArray[i]);\n"
2346
" if(res<0)\n"
2347
" return false;\n"
2348
" }\n"
2349
" return true;\n"
2350
"}\n"
2351
"\n"
2352
"\n"
2353
"function DrawBarView()\n"
2354
"{\n"
2355
" ProfileEnter(\"DrawBarView\");\n"
2356
" Invalidate++;\n"
2357
" nHoverToken = -1;\n"
2358
" var context = CanvasDetailedView.getContext(\'2d\');\n"
2359
" context.clearRect(0, 0, nWidth, nHeight);\n"
2360
"\n"
2361
" var Height = BoxHeight;\n"
2362
" var Width = nWidth;\n"
2363
" var NameWidth = Math.max(S.TimerNameWidth, S.GroupNameWidth) + 20;\n"
2364
"\n"
2365
" //clamp offset to prevent scrolling into the void\n"
2366
" var nTotalRows = 0;\n"
2367
" for(var groupid in S.GroupInfo)\n"
2368
" {\n"
2369
" if(!GroupsDisabled[S.GroupInfo[groupid].name])\n"
2370
" {\n"
2371
" nTotalRows += S.GroupInfo[groupid].TimerArray.length + 1;\n"
2372
" }\n"
2373
" }\n"
2374
" var nTotalRowPixels = nTotalRows * Height;\n"
2375
" var nFrameRows = nHeight - BoxHeight;\n"
2376
"\n"
2377
" if(nOffsetBarsY + nFrameRows > nTotalRowPixels && nTotalRowPixels > nFrameRows)\n"
2378
" {\n"
2379
" nOffsetBarsY = nTotalRowPixels - nFrameRows;\n"
2380
" }\n"
2381
" var ColumnsWidthBefore = new Array(ColumnsWidth.length);\n"
2382
" for(var i = 0; i < ColumnsWidth.length; ++i)\n"
2383
" {\n"
2384
" ColumnsWidthBefore[i] = ColumnsWidth[i];\n"
2385
" }\n"
2386
"\n"
2387
" var Y = -nOffsetBarsY + BoxHeight;\n"
2388
" let TimersGroups = Mode == ModeTimers_Threads || Mode == ModeTimers_Groups;\n"
2389
" if(TimersGroups)\n"
2390
" {\n"
2391
" nOffsetBarsX = 0;\n"
2392
" }\n"
2393
" var XBase = -nOffsetBarsX;\n"
2394
" var nColorIndex = 0;\n"
2395
"\n"
2396
" context.fillStyle = \'white\';\n"
2397
" context.font = Font;\n"
2398
" var bMouseIn = 0;\n"
2399
" var RcpReferenceTime = 1.0 / ReferenceTime;\n"
2400
" var CountWidth = 12 * FontWidth;\n"
2401
" var nMetaLen = S.TimerInfo[0].meta.length;\n"
2402
" var nMetaCharacters = 10;\n"
2403
" var InnerBoxHeight = BoxHeight-2;\n"
2404
" var TimerLen = 8; //todo: fix max digits.\n"
2405
" var TimerWidth = TimerLen * FontWidth;\n"
2406
" var nWidthBars = nBarsWidth+2;\n"
2407
" var nWidthMs = TimerWidth+2+10;\n"
2408
" var R = 0;\n"
2409
" var AllColumns = TimersGroups != 0;\n"
2410
"\n"
2411
"\n"
2412
"\n"
2413
" for(var i = 0; i < nMetaLen; ++i)\n"
2414
" {\n"
2415
" if(nMetaCharacters < MetaNames[i].length)\n"
2416
" nMetaCharacters = MetaNames[i].length;\n"
2417
" }\n"
2418
" var nWidthMeta = nMetaCharacters * FontWidth + 6;\n"
2419
" function HeaderMouseHandle(XBegin, X, Header)\n"
2420
" {\n"
2421
" var bMouseIn = DetailedViewMouseY >= 0 && DetailedViewMouseY < BoxHeight && DetailedViewMouseX < X && DetailedViewMouseX > XBegin;\n"
2422
" if(bMouseIn)\n"
2423
" {\n"
2424
" SortColumnMouseOverNext = Header;\n"
2425
" }\n"
2426
" }\n"
2427
" function HeaderString(Header)\n"
2428
" {\n"
2429
" if(Header == SortColumnMouseOver)\n"
2430
" {\n"
2431
" return Header + (SortColumnOrderFlip ? \'<\' : \'>\');\n"
2432
" }\n"
2433
" else\n"
2434
" {\n"
2435
" return Header;\n"
2436
" }\n"
2437
"\n"
2438
" }\n"
2439
" function DrawHeaderSplit(Header)\n"
2440
" {\n"
2441
" if(ColumnsEnabled[R]||AllColumns)\n"
2442
" {\n"
2443
" context.fillStyle = \'white\';\n"
2444
" context.fillText(HeaderString(Header), X, Height-FontAscent);\n"
2445
" var XBegin = X;\n"
2446
" X += nWidthBars;\n"
2447
" context.fillStyle = nBackColorOffset;\n"
2448
" X += ColumnsWidth[R];\n"
2449
" if(X >= NameWidth)\n"
2450
" {\n"
2451
" context.fillRect(X-3, 0, 1, nHeight);\n"
2452
" }\n"
2453
" HeaderMouseHandle(XBegin, X, Header);\n"
2454
" }\n"
2455
" R++;\n"
2456
" }\n"
2457
" function DrawHeaderSplitSingle(Header, Col)\n"
2458
" {\n"
2459
" if(ColumnsEnabled[Col]||AllColumns)\n"
2460
" {\n"
2461
" context.fillStyle = \'white\';\n"
2462
" context.fillText(HeaderString(Header), X, Height-FontAscent);\n"
2463
" var XBegin = X;\n"
2464
" X += ColumnsWidth[R];\n"
2465
" context.fillStyle = nBackColorOffset;\n"
2466
" if(X >= NameWidth)\n"
2467
" {\n"
2468
" context.fillRect(X-3, 0, 1, nHeight);\n"
2469
" }\n"
2470
" HeaderMouseHandle(XBegin, X, Header);\n"
2471
" }\n"
2472
" R++;\n"
2473
" }\n"
2474
" function DrawHeaderSplitLeftRight(HeaderLeft, HeaderRight, Width)\n"
2475
" {\n"
2476
" context.textAlign = \'left\';\n"
2477
" context.fillStyle = \'white\';\n"
2478
" context.fillText(HeaderLeft, X, Height-FontAscent);\n"
2479
" var XBegin = X;\n"
2480
" X += Width;\n"
2481
" context.textAlign = \'right\';\n"
2482
" context.fillText(HeaderRight, X-5, Height-FontAscent);\n"
2483
" context.textAlign = \'left\';\n"
2484
" context.fillStyle = nBackColorOffset;\n"
2485
" if(X >= NameWidth)\n"
2486
" {\n"
2487
" context.fillRect(X-3, 0, 1, nHeight);\n"
2488
" }\n"
2489
" HeaderMouseHandle(XBegin, X, HeaderLeft);\n"
2490
" }\n"
2491
" function DrawTimer(Value, Color)\n"
2492
" {\n"
2493
" if(ColumnsEnabled[R]||AllColumns)\n"
2494
" {\n"
2495
" var Prc = Value * RcpReferenceTime;\n"
2496
" var YText = Y+Height-FontAscent;\n"
2497
" if(Prc > 1)\n"
2498
" {\n"
2499
" Prc = 1;\n"
2500
" }\n"
2501
" context.textAlign = \'left\';\n"
2502
" context.fillStyle = Color;\n"
2503
" context.fillRect(X+1, Y+1, Prc * nBarsWidth, InnerBoxHeight);\n"
2504
" var TimerText = Value.toFixed(2);\n"
2505
" var W = context.measureText(TimerText).width + FontWidth;\n"
2506
" ColumnsWidth[R] = Math.max(W, ColumnsWidth[R]);\n"
2507
" X += nWidthBars;\n"
2508
" X += ColumnsWidth[R];\n"
2509
" context.fillStyle = \'white\';\n"
2510
" context.textAlign = \'right\';\n"
2511
" context.fillText(TimerText, X - FontWidth, YText);\n"
2512
" context.textAlign = \'left\';\n"
2513
" }\n"
2514
" R++;\n"
2515
" }\n"
2516
" function DrawCount(Str)\n"
2517
" {\n"
2518
" if(ColumnsEnabled[R]||AllColumns)\n"
2519
" {\n"
2520
" X += ColumnsWidth[R];\n"
2521
" context.fillStyle = \'white\';\n"
2522
" context.textAlign = \'right\';\n"
2523
" var YText = Y+Height-FontAscent;\n"
2524
" context.fillText(Str, X-6, YText);\n"
2525
" var W = Math.max(80, context.measureText(Str).width + FontWidth * 2);\n"
2526
" ColumnsWidth[R] = Math.max(W, ColumnsWidth[R]);\n"
2527
" }\n"
2528
" R++;\n"
2529
"\n"
2530
" }\n"
2531
"\n"
2532
"\n"
2533
" function DrawMeta(Value, Width, Dec, YText, Col)\n"
2534
" {\n"
2535
" if(ColumnsEnabled[Col]||AllColumns)\n"
2536
" {\n"
2537
" Value = FormatMeta(Value, Dec);\n"
2538
" X += (FontWidth*Width);\n"
2539
" ColumnsWidth[R] = FontWidth*Width;\n"
2540
" context.textAlign = \'right\';\n"
2541
" context.fillText(Value, X-FontWidth, YText);\n"
2542
" context.textAlign = \'left\';\n"
2543
" }\n"
2544
" R++;\n"
2545
" }\n"
2546
"\n"
2547
"\n"
2548
"\n"
2549
" function DrawTimerRow(timerid, showgroup)\n"
2550
" {\n"
2551
" R = 0;\n"
2552
" var Timer = S.TimerInfo[timerid];\n"
2553
" var Average = Timer.average;\n"
2554
" var Max = Timer.max;\n"
2555
" var Min = Timer.min;\n"
2556
" var Spike = Timer.spike;\n"
2557
" var ExclusiveMax = Timer.exclmax;\n"
2558
" var ExclusiveAverage = Timer.exclaverage;\n"
2559
" var CallAverage = Timer.callaverage;\n"
2560
" var CallCount = Timer.callcount;\n"
2561
" var YText = Y+Height-FontAscent;\n"
2562
" var Color = g_Colors[Timer.cid];\n"
2563
" X = NameWidth + XBase;\n"
2564
"\n"
2565
" nColorIndex = 1-nColorIndex;\n"
2566
" bMouseIn = DetailedViewMouseY >= Y && DetailedViewMouseY < Y + BoxHeight;\n"
2567
" if(bMouseIn)\n"
2568
" {\n"
2569
" nHoverToken = timerid;\n"
2570
" }\n"
2571
" context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
2572
" context.fillRect(0, Y, Width, FontHeight+2);\n"
2573
"\n"
2574
" DrawTimer(Average, Color);\n"
2575
" DrawTimer(Max, Color);\n"
2576
" DrawTimer(Timer.total, Color);\n"
2577
" DrawTimer(Min, Color);\n"
2578
" DrawCount(Spike.toFixed(2) + \'%\');\n"
2579
" DrawTimer(CallAverage, Color);\n"
2580
" DrawCount(CallCount);\n"
2581
" DrawTimer(ExclusiveAverage, Color);\n"
2582
" DrawTimer(ExclusiveMax, Color);\n"
2583
"\n"
2584
" context.fillStyle = \'white\';\n"
2585
" var Col = R;\n"
2586
" for(var j = 0; j < nMetaLen; ++j)\n"
2587
" {\n"
2588
" DrawMeta(Timer.meta[j], MetaLengths[j], 0, YText, Col + j);\n"
2589
" DrawMeta(Timer.metaavg[j], MetaLengthsAvg[j], 2, YText, Col + j);\n"
2590
" DrawMeta(Timer.metamax[j], MetaLengthsMax[j], 0, YText, Col + j);\n"
2591
" }\n"
2592
" context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
2593
" context.fillRect(0, Y, NameWidth, Height);\n"
2594
" context.textAlign = \'right\';\n"
2595
" context.fillStyle = Color;\n"
2596
" context.fillText(Timer.name, NameWidth - 5, YText);\n"
2597
" context.textAlign = \'left\';\n"
2598
" if(showgroup)\n"
2599
" {\n"
2600
" context.fillStyle = \'white\';\n"
2601
" context.fillText(S.GroupInfo[Timer.group].name, 1, YText);\n"
2602
" }\n"
2603
" }\n"
2604
" if(SortColumn && Mode == ModeTimers)\n"
2605
" {\n"
2606
" var OrderArray = new Array(S.TimerInfo.length);\n"
2607
" var KeyArray = new Array(S.TimerInfo.length);\n"
2608
" for(var idx in GroupOrder)\n"
2609
" {\n"
2610
" var Group = S.GroupInfo[idx];\n"
2611
" if((!GroupsDisabled[Group.name]) && FilterMatch(FilterGroup, Group.name))\n"
2612
" {\n"
2613
" var TimerArray = Group.TimerArray;\n"
2614
" for(var timerindex in TimerArray)\n"
2615
" {\n"
2616
" var timerid = TimerArray[timerindex];\n"
2617
" if(FilterMatch(FilterTimer, S.TimerInfo[timerid].name))\n"
2618
" {\n"
2619
" OrderArray.push(timerid);\n"
2620
" NameWidth = Math.max(S.TimerInfo[timerid].wtotal, NameWidth);\n"
2621
" }\n"
2622
" }\n"
2623
" }\n"
2624
" }\n"
2625
" var KeyFunc = null;\n"
2626
" switch(SortColumn)\n"
2627
" {\n"
2628
" case 1: KeyFunc = function (a) { return S.TimerInfo[a].average; }; break;\n"
2629
" case 2: KeyFunc = function (a) { return S.TimerInfo[a].max; }; break;\n"
2630
" case 3: KeyFunc = function (a) { return S.TimerInfo[a].total; }; break;\n"
2631
" case 4: KeyFunc = function (a) { return S.TimerInfo[a].min; }; break;\n"
2632
" case 5: KeyFunc = function (a) { return S.TimerInfo[a].spike; }; break;\n"
2633
" case 6: KeyFunc = function (a) { return S.TimerInfo[a].callaverage; }; break;\n"
2634
" case 7: KeyFunc = function (a) { return S.TimerInfo[a].callcount; }; break;\n"
2635
" case 8: KeyFunc = function (a) { return S.TimerInfo[a].exclaverage; }; break;\n"
2636
" case 9: KeyFunc = function (a) { return S.TimerInfo[a].exclmax; }; break;\n"
2637
" }\n"
2638
"\n"
2639
" var Flip = SortColumnOrderFlip == 1 ? -1 : 1;\n"
2640
" OrderArray.sort(function(a,b) { return Flip * (KeyFunc(b) - KeyFunc(a)); } );\n"
2641
"\n"
2642
" for(var i in OrderArray)\n"
2643
" {\n"
2644
" DrawTimerRow(OrderArray[i], 1);\n"
2645
" Y += Height;\n"
2646
" }\n"
2647
"\n"
2648
" }\n"
2649
" else if(Mode == ModeTimers_Threads)\n"
2650
" {\n"
2651
" for(var i = 0; i < S.ThreadNames.length; ++i)\n"
2652
" {\n"
2653
" if((IsThreadActive(S.ThreadNames[i])) && FilterMatch(FilterTimer, S.ThreadNames[i]))\n"
2654
" {\n"
2655
" var X = 0;\n"
2656
" var YText = Y+Height-FontAscent;\n"
2657
" bMouseIn = DetailedViewMouseY >= Y && DetailedViewMouseY < Y + BoxHeight;\n"
2658
" nColorIndex = 1-nColorIndex;\n"
2659
" context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
2660
" context.fillRect(0, Y, Width, FontHeight+2);\n"
2661
" var ThreadColor = CSwitchColors[i % CSwitchColors.length];\n"
2662
" context.fillStyle = ThreadColor;\n"
2663
" context.fillText(S.ThreadNames[i], 1, YText);\n"
2664
" context.textAlign = \'left\';\n"
2665
" Y += Height;\n"
2666
" for(var idx in GroupOrder)\n"
2667
" {\n"
2668
" R = 0;\n"
2669
" var groupid = GroupOrder[idx];\n"
2670
" var Group = S.GroupInfo[groupid];\n"
2671
" var PerThreadTimer = S.ThreadGroupTimeArray[i][groupid];\n"
2672
" var PerThreadTimerTotal = S.ThreadGroupTimeTotalArray[i][groupid];\n"
2673
" if((PerThreadTimer > 0.0001|| PerThreadTimerTotal>0.1) && (!GroupsDisabled[Group.name]) && FilterMatch(FilterGroup, Group.name))\n"
2674
" {\n"
2675
" var GColor = GroupColors ? g_Colors[S.GroupInfo[groupid].cid] : \'white\';\n"
2676
" var X = 0;\n"
2677
" nColorIndex = 1-nColorIndex;\n"
2678
" bMouseIn = DetailedViewMouseY >= Y && DetailedViewMouseY < Y + BoxHeight;\n"
2679
" context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
2680
" context.fillRect(0, Y, Width, nHeight);\n"
2681
" context.fillStyle = GColor;\n"
2682
" context.textAlign = \'right\';\n"
2683
" context.fillText(Group.name, NameWidth - 5, Y+Height-FontAscent);\n"
2684
" context.textAlign = \'left\';\n"
2685
" X += NameWidth;\n"
2686
" DrawTimer(PerThreadTimer, GColor);\n"
2687
" DrawTimer(PerThreadTimerTotal, GColor);\n"
2688
" Y += Height;\n"
2689
" }\n"
2690
" }\n"
2691
" }\n"
2692
" }\n"
2693
" }\n"
2694
" else\n"
2695
" {\n"
2696
" for(var idx in GroupOrder)\n"
2697
" {\n"
2698
" var groupid = GroupOrder[idx];\n"
2699
" var Group = S.GroupInfo[groupid];\n"
2700
" var GColor = GroupColors ? g_Colors[S.GroupInfo[groupid].cid] : \'white\';\n"
2701
" if((!GroupsDisabled[Group.name]) && FilterMatch(FilterGroup, Group.name))\n"
2702
" {\n"
2703
" R = 0;\n"
2704
" var TimerArray = Group.TimerArray;\n"
2705
" var X = XBase;\n"
2706
" nColorIndex = 1-nColorIndex;\n"
2707
" bMouseIn = DetailedViewMouseY >= Y && DetailedViewMouseY < Y + BoxHeight;\n"
2708
" context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
2709
" context.fillRect(0, Y, Width, FontHeight+2);\n"
2710
" context.fillStyle = GColor;\n"
2711
" context.fillText(Group.name, 1, Y+Height-FontAscent);\n"
2712
" X += NameWidth;\n"
2713
" DrawTimer(Group.average, GColor);\n"
2714
" DrawTimer(Group.max, GColor);\n"
2715
" DrawTimer(Group.total, GColor);\n"
2716
"\n"
2717
" context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
2718
" context.fillRect(0, Y, NameWidth, FontHeight+2);\n"
2719
" context.fillStyle = GColor;\n"
2720
" context.fillText(Group.name, 1, Y+Height-FontAscent);\n"
2721
"\n"
2722
" Y += Height;\n"
2723
" let TimersGroups = Mode == ModeTimers_Threads || Mode == ModeTimers_Groups;\n"
2724
" if(TimersGroups)\n"
2725
" {\n"
2726
" for(var i = 0; i < S.ThreadNames.length; ++i)\n"
2727
" {\n"
2728
" R = 0;\n"
2729
" var PerThreadTimer = S.ThreadGroupTimeArray[i][groupid];\n"
2730
" var PerThreadTimerTotal = S.ThreadGroupTimeTotalArray[i][groupid];\n"
2731
" if((PerThreadTimer > 0.0001|| PerThreadTimerTotal>0.1) && (IsThreadActive(S.ThreadNames[i])) && FilterMatch(FilterTimer, S.ThreadNames[i]))\n"
2732
" {\n"
2733
" var YText = Y+Height-FontAscent;\n"
2734
" bMouseIn = DetailedViewMouseY >= Y && DetailedViewMouseY < Y + BoxHeight;\n"
2735
" nColorIndex = 1-nColorIndex;\n"
2736
" context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
2737
" context.fillRect(0, Y, Width, FontHeight+2);\n"
2738
" var ThreadColor = CSwitchColors[i % CSwitchColors.length];\n"
2739
" context.fillStyle = ThreadColor;\n"
2740
" context.textAlign = \'right\';\n"
2741
" context.fillText(S.ThreadNames[i], NameWidth - 5, YText);\n"
2742
" context.textAlign = \'left\';\n"
2743
" X = NameWidth;\n"
2744
" DrawTimer(PerThreadTimer, ThreadColor);\n"
2745
" X += nWidthBars + ColumnsWidth[R++];\n"
2746
" DrawTimer(PerThreadTimerTotal, ThreadColor);\n"
2747
" Y += Height;\n"
2748
" }\n"
2749
" }\n"
2750
" }\n"
2751
" else\n"
2752
" {\n"
2753
" for(var timerindex in TimerArray)\n"
2754
" {\n"
2755
" var timerid = TimerArray[timerindex];\n"
2756
" if(FilterMatch(FilterTimer, S.TimerInfo[timerid].name))\n"
2757
" {\n"
2758
" DrawTimerRow(timerid, 0);\n"
2759
" Y += Height;\n"
2760
" }\n"
2761
" }\n"
2762
" }\n"
2763
" }\n"
2764
" }\n"
2765
" }\n"
2766
" X = 0;\n"
2767
" R = 0;\n"
2768
" context.fillStyle = nBackColorOffset;\n"
2769
" context.fillRect(0, 0, Width, Height);\n"
2770
" context.fillStyle = \'white\';\n"
2771
" SortColumnMouseOverNext = null;\n"
2772
"\n"
2773
" if(Mode == ModeTimers_Threads || Mode == ModeTimers_Groups)\n"
2774
" {\n"
2775
" if(Mode == ModeTimers_Threads)\n"
2776
" {\n"
2777
" DrawHeaderSplitLeftRight(StrThread, StrGroup, NameWidth);\n"
2778
" DrawHeaderSplit(StrAverage);\n"
2779
" DrawHeaderSplit(StrTotal);\n"
2780
" }\n"
2781
" else\n"
2782
" {\n"
2783
" DrawHeaderSplitLeftRight(StrGroup, StrThread, NameWidth);\n"
2784
" DrawHeaderSplit(StrAverage);\n"
2785
" DrawHeaderSplit(StrMax);\n"
2786
" DrawHeaderSplit(StrTotal);\n"
2787
" }\n"
2788
" }\n"
2789
" else\n"
2790
" {\n"
2791
" X = NameWidth + XBase;\n"
2792
" DrawHeaderSplit(StrAverage);\n"
2793
" DrawHeaderSplit(StrMax);\n"
2794
" DrawHeaderSplit(StrTotal);\n"
2795
" DrawHeaderSplit(StrMin);\n"
2796
" DrawHeaderSplitSingle(StrSpike, R);\n"
2797
" DrawHeaderSplit(StrCallAverage);\n"
2798
" DrawHeaderSplitSingle(StrCount, R);\n"
2799
" DrawHeaderSplit(StrExclAverage);\n"
2800
" DrawHeaderSplit(StrExclMax);\n"
2801
" var Col = R;\n"
2802
" for(var i = 0; i < nMetaLen; ++i)\n"
2803
" {\n"
2804
" DrawHeaderSplitSingle(MetaNames[i], Col + i);\n"
2805
" DrawHeaderSplitSingle(MetaNames[i] + \" Avg\", Col + i);\n"
2806
" DrawHeaderSplitSingle(MetaNames[i] + \" Max\", Col + i);\n"
2807
" }\n"
2808
" X = 0;\n"
2809
" context.fillStyle = nBackColorOffset;\n"
2810
" context.fillRect(0, 0, NameWidth, Height);\n"
2811
" context.fillStyle = \'white\';\n"
2812
"\n"
2813
" DrawHeaderSplitLeftRight(StrGroup, StrTimer, NameWidth);\n"
2814
"\n"
2815
" }\n"
2816
"\n"
2817
" var ColumnsChanged = false;\n"
2818
" for(var i = 0; i < ColumnsWidth.length; ++i)\n"
2819
" {\n"
2820
" if(ColumnsWidthBefore[i] != ColumnsWidth[i])\n"
2821
" {\n"
2822
" ColumnsChanged = true;\n"
2823
" }\n"
2824
" }\n"
2825
" if(ColumnsChanged)\n"
2826
" {\n"
2827
" Invalidate = 0;\n"
2828
" }\n"
2829
"\n"
2830
"\n"
2831
"\n"
2832
"\n"
2833
" ProfileLeave();\n"
2834
"}\n"
2835
"\n"
2836
"var CounterNameWidth = 100;\n"
2837
"var CounterValueWidth = 100;\n"
2838
"var CounterLimitWidth = 100;\n"
2839
"\n"
2840
"var FormatCounterDefault = 0;\n"
2841
"var FormatCounterBytes = 1;\n"
2842
"var FormatCounterBytesExt = [ \"b\",\"kb\",\"mb\",\"gb\",\"tb\",\"pb\", \"eb\",\"zb\", \"yb\" ];\n"
2843
"\n"
2844
"function ShiftRight10(v)\n"
2845
"{\n"
2846
" if(v > 1024)\n"
2847
" {\n"
2848
" return v / 1024.0;\n"
2849
" }\n"
2850
" else\n"
2851
" {\n"
2852
" return v >> 10;\n"
2853
" }\n"
2854
"}\n"
2855
"\n"
2856
"\n"
2857
"function FormatCounter(Format, Counter)\n"
2858
"{\n"
2859
" if(!Counter)\n"
2860
" {\n"
2861
" return \'0\';\n"
2862
" }\n"
2863
" var Negative = 0;\n"
2864
" if(Counter < 0)\n"
2865
" {\n"
2866
" Counter = -Counter;\n"
2867
" Negative = 1;\n"
2868
" if(Counter < 0) // handle INT_MIN\n"
2869
" {\n"
2870
" Counter = -(Counter+1);\n"
2871
" if(Counter < 0)\n"
2872
" {\n"
2873
" return \'?\';\n"
2874
" }\n"
2875
" }\n"
2876
" }\n"
2877
" var str = Negative ? \'-\' :\'\' ;\n"
2878
" if(Format == FormatCounterDefault)\n"
2879
" {\n"
2880
" var Seperate = 0;\n"
2881
" var result = \'\';\n"
2882
" while (Counter)\n"
2883
" {\n"
2884
" if (Seperate)\n"
2885
" {\n"
2886
" result += \'.\';\n"
2887
" }\n"
2888
" Seperate = 1;\n"
2889
" for (var i = 0; Counter && i < 3; ++i)\n"
2890
" {\n"
2891
" var Digit = Math.floor(Counter % 10);\n"
2892
" Counter = Math.floor(Counter / 10);\n"
2893
" result += \'\' + Digit;\n"
2894
" }\n"
2895
" }\n"
2896
"\n"
2897
" for(var i = 0; i < result.length; ++i)\n"
2898
" {\n"
2899
" str += result[result.length-1-i];\n"
2900
" }\n"
2901
" return str;\n"
2902
" }\n"
2903
" else if(Format == FormatCounterBytes)\n"
2904
" {\n"
2905
" var Shift = 0;\n"
2906
" var Divisor = 1;\n"
2907
" var CountShifted = ShiftRight10(Counter);\n"
2908
" while(CountShifted)\n"
2909
" {\n"
2910
" Divisor <<= 10;\n"
2911
" CountShifted = ShiftRight10(CountShifted);\n"
2912
" Shift++;\n"
2913
" }\n"
2914
" if(Shift)\n"
2915
" {\n"
2916
" return str + (Counter / Divisor).toFixed(2) + \'\' + FormatCounterBytesExt[Shift];\n"
2917
" }\n"
2918
" else\n"
2919
" {\n"
2920
" return str + Counter.toFixed(2) + \'\' + FormatCounterBytesExt[0];\n"
2921
" }\n"
2922
" }\n"
2923
" return \'?\'\n"
2924
"}\n"
2925
"function DrawCounterView()\n"
2926
"{\n"
2927
" ProfileEnter(\"DrawCounterView\");\n"
2928
" Invalidate++;\n"
2929
" nHoverToken = -1;\n"
2930
" var context = CanvasDetailedView.getContext(\'2d\');\n"
2931
" context.clearRect(0, 0, nWidth, nHeight);\n"
2932
"\n"
2933
" var Height = BoxHeight;\n"
2934
" var Width = nWidth;\n"
2935
" //clamp offset to prevent scrolling into the void\n"
2936
" var nTotalRows = S.CounterInfo.length;\n"
2937
" var nTotalRowPixels = nTotalRows * Height;\n"
2938
" var nFrameRows = nHeight - BoxHeight;\n"
2939
" if(nOffsetCountersY + nFrameRows > nTotalRowPixels && nTotalRowPixels > nFrameRows)\n"
2940
" {\n"
2941
" nOffsetCountersY = nTotalRowPixels - nFrameRows;\n"
2942
" }\n"
2943
"\n"
2944
" var CounterNameWidthTemp = 10;\n"
2945
" var CounterValueWidthTemp = 10;\n"
2946
" var CounterLimitWidthTemp = 10;\n"
2947
"\n"
2948
" var CounterWidth = 150;\n"
2949
" var Y = -nOffsetCountersY + BoxHeight;\n"
2950
" var X = 0;\n"
2951
" var nColorIndex = 0;\n"
2952
" context.fillStyle = \'white\';\n"
2953
" context.font = Font;\n"
2954
" var bMouseIn = 0;\n"
2955
" function DrawHeaderSplitSingle(Header, Width)\n"
2956
" {\n"
2957
" context.fillStyle = \'white\';\n"
2958
" context.fillText(Header, X, Height-FontAscent);\n"
2959
" X += Width;\n"
2960
" context.fillStyle = nBackColorOffset;\n"
2961
" context.fillRect(X-3, 0, 1, nHeight);\n"
2962
" }\n"
2963
" function DrawHeaderSplitSingleRight(Header, Width)\n"
2964
" {\n"
2965
" X += Width;\n"
2966
" context.fillStyle = \'white\';\n"
2967
" context.textAlign = \'right\';\n"
2968
" context.fillText(Header, X - FontWidth, Height-FontAscent);\n"
2969
" context.fillStyle = nBackColorOffset;\n"
2970
" context.fillRect(X, 0, 1, nHeight);\n"
2971
" context.textAlign = \'left\';\n"
2972
" }\n"
2973
" var TimerLen = 6;\n"
2974
" var TimerWidth = TimerLen * FontWidth;\n"
2975
" nHoverCounter = -1;\n"
2976
" function CounterIndent(Level)\n"
2977
" {\n"
2978
" return Level * 4 * FontWidth;\n"
2979
" }\n"
2980
" function Max(a, b)\n"
2981
" {\n"
2982
" return a > b ? a : b;\n"
2983
" }\n"
2984
"\n"
2985
" function DrawCounterRecursive(Index)\n"
2986
" {\n"
2987
" var Counter = S.CounterInfo[Index];\n"
2988
" var Indent = CounterIndent(Counter.level);\n"
2989
" CounterNameWidthTemp = Max(CounterNameWidthTemp, Counter.name.length+1 + Indent / (FontWidth+1));\n"
2990
" CounterValueWidthTemp = Max(CounterValueWidthTemp, Counter.formatted.length);\n"
2991
" CounterLimitWidthTemp = Max(CounterLimitWidthTemp, Counter.formattedlimit.length);\n"
2992
"\n"
2993
" var X = 0;\n"
2994
" nColorIndex = 1-nColorIndex;\n"
2995
" var HeightExpanded = Counter.Expanded ? Height * 5 : Height\n"
2996
"\n"
2997
" bMouseIn = DetailedViewMouseY >= Y && DetailedViewMouseY < Y + HeightExpanded;\n"
2998
" if(bMouseIn)\n"
2999
" {\n"
3000
" nHoverCounter = Index;\n"
3001
" }\n"
3002
" var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
3003
" context.fillStyle = bgcolor;\n"
3004
" context.fillRect(0, Y, Width, HeightExpanded);\n"
3005
" context.fillStyle = \'white\';\n"
3006
" var c = Counter.";
3007
3008
const size_t g_MicroProfileHtml_end_1_size = sizeof(g_MicroProfileHtml_end_1);
3009
const char g_MicroProfileHtml_end_2[] =
3010
"closed ? \'*\' : \' \';\n"
3011
" context.fillText(c + Counter.name, Indent, Y+Height-FontAscent);\n"
3012
" X += CounterNameWidth;\n"
3013
" X += CounterValueWidth - FontWidth;\n"
3014
" context.textAlign = \'right\';\n"
3015
" context.fillText(Counter.formatted, X, Y+Height-FontAscent);\n"
3016
" context.textAlign = \'left\';\n"
3017
" X += FontWidth * 4;\n"
3018
" var Y0 = Y + 1;\n"
3019
" if(Counter.limit != 0)\n"
3020
" {\n"
3021
" context.fillText(Counter.formattedlimit, X, Y+Height-FontAscent);\n"
3022
" X += CounterLimitWidth;\n"
3023
" var X0 = X + 1;\n"
3024
" context.fillStyle = \'white\';\n"
3025
" context.fillRect(X0, Y0, Counter.boxprc * (CounterWidth-2), Height-2);\n"
3026
" context.fillStyle = bgcolor;\n"
3027
" context.fillRect(X0+1, Y0+1, Counter.boxprc * (CounterWidth-4), Height-4);\n"
3028
" context.fillStyle = \'cyan\';\n"
3029
" context.fillRect(X0+1, Y0+1, Counter.counterprc * (CounterWidth-4), Height-4);\n"
3030
" X += CounterWidth + 10;\n"
3031
" }\n"
3032
" else\n"
3033
" {\n"
3034
" X += CounterLimitWidth;\n"
3035
" X += CounterWidth + 10;\n"
3036
" }\n"
3037
" var CounterHistory = Counter.counterhistory;\n"
3038
" if(CounterHistory)\n"
3039
" {\n"
3040
" var Prc = CounterHistory.prc;\n"
3041
"\n"
3042
" context.fillStyle = \'cyan\';\n"
3043
" context.strokeStyle = \'cyan\';\n"
3044
" context.globalAlpha = 0.5;\n"
3045
" context.beginPath();\n"
3046
" var x = X;\n"
3047
" var YBase = Y0 + HeightExpanded-1;\n"
3048
" var YOffset = -(HeightExpanded-2);\n"
3049
"\n"
3050
" context.moveTo(X, Y0);\n"
3051
" for(var i = 0; i < Prc.length; ++i)\n"
3052
" {\n"
3053
" context.moveTo(x, YBase);\n"
3054
" context.lineTo(x, YBase + Prc[i] * YOffset);\n"
3055
"\n"
3056
" x += 1;\n"
3057
" }\n"
3058
" context.stroke();\n"
3059
"\n"
3060
" x = X;\n"
3061
" context.globalAlpha = 1.0;\n"
3062
" context.beginPath();\n"
3063
" context.moveTo(X, YBase);\n"
3064
"\n"
3065
" for(var i = 0; i < Prc.length; ++i)\n"
3066
" {\n"
3067
" context.lineTo(x, YBase + Prc[i] * YOffset);\n"
3068
" x += 1;\n"
3069
" }\n"
3070
" context.stroke();\n"
3071
" if(bMouseIn)\n"
3072
" {\n"
3073
" var MouseGraphX = Math.floor(DetailedViewMouseX - X);\n"
3074
" if(MouseGraphX >= 0 && MouseGraphX < CounterHistory.history.length)\n"
3075
" {\n"
3076
" context.fillStyle = \'white\';\n"
3077
" var Formatted = FormatCounter(Counter.format, CounterHistory.history[MouseGraphX]);\n"
3078
" context.fillText(Formatted, X, Y+Height-FontAscent);\n"
3079
" }\n"
3080
" context.strokeStyle = \'orange\';\n"
3081
" context.beginPath();\n"
3082
" var CrossX = X + MouseGraphX;\n"
3083
" var CrossY = YBase + Prc[MouseGraphX] * YOffset;\n"
3084
" context.moveTo(CrossX-2, CrossY-2);\n"
3085
" context.lineTo(CrossX+2, CrossY+2);\n"
3086
" context.moveTo(CrossX+2, CrossY-2);\n"
3087
" context.lineTo(CrossX-2, CrossY+2);\n"
3088
" context.stroke();\n"
3089
"\n"
3090
" }\n"
3091
" X += Prc.length + 5;\n"
3092
" context.fillStyle = \'white\';\n"
3093
" context.fillText( FormatCounter(Counter.format, Counter.minvalue), X, Y + Height - FontAscent);\n"
3094
" X += CounterWidth + 5;\n"
3095
" context.fillText( FormatCounter(Counter.format, Counter.maxvalue), X, Y + Height - FontAscent);\n"
3096
" X += CounterWidth + 5;\n"
3097
" }\n"
3098
"\n"
3099
" Y += HeightExpanded;\n"
3100
"\n"
3101
" if(!Counter.closed)\n"
3102
" {\n"
3103
" var ChildIndex = Counter.firstchild;\n"
3104
" while(ChildIndex != -1)\n"
3105
" {\n"
3106
" DrawCounterRecursive(ChildIndex);\n"
3107
" ChildIndex = S.CounterInfo[ChildIndex].sibling;\n"
3108
" }\n"
3109
" }\n"
3110
" }\n"
3111
"\n"
3112
" for(var i = 0; i < S.CounterInfo.length; ++i)\n"
3113
" {\n"
3114
" if(S.CounterInfo[i].parent == -1)\n"
3115
" {\n"
3116
" DrawCounterRecursive(i);\n"
3117
" }\n"
3118
" }\n"
3119
"\n"
3120
" X = 0;\n"
3121
" context.fillStyle = nBackColorOffset;\n"
3122
" context.fillRect(0, 0, Width, Height);\n"
3123
" context.fillStyle = \'white\';\n"
3124
" DrawHeaderSplitSingle(\'Name\', CounterNameWidth);\n"
3125
" DrawHeaderSplitSingleRight(\'Value\', CounterValueWidth + (FontWidth+1));\n"
3126
" DrawHeaderSplitSingle(\'Limit\', CounterLimitWidth + CounterWidth + 3 * (FontWidth+1));\n"
3127
"\n"
3128
"\n"
3129
"\n"
3130
"\n"
3131
"\n"
3132
" var CounterNameWidthNew = CounterNameWidthTemp * (FontWidth+1);\n"
3133
" var CounterValueWidthNew = CounterValueWidthTemp * (FontWidth+1);\n"
3134
" var CounterLimitWidthNew = CounterLimitWidthTemp * (FontWidth+1);\n"
3135
" if(CounterNameWidthNew != CounterNameWidth || CounterValueWidthNew != CounterValueWidth || CounterLimitWidthNew != CounterLimitWidth)\n"
3136
" {\n"
3137
" // console.log(\'requesting redraw 0\' + CounterNameWidthNew + \'= \' + CounterNameWidth );\n"
3138
" // console.log(\'requesting redraw 1\' + CounterValueWidthNew + \'= \' + CounterValueWidth );\n"
3139
" // console.log(\'requesting redraw 2\' + CounterLimitWidthNew + \'= \' + CounterLimitWidth );\n"
3140
" CounterNameWidth = CounterNameWidthNew;\n"
3141
" CounterValueWidth = CounterValueWidthNew;\n"
3142
" CounterLimitWidth = CounterLimitWidthNew;\n"
3143
" Invalidate = 0;\n"
3144
" }\n"
3145
"\n"
3146
" ProfileLeave();\n"
3147
"}\n"
3148
"\n"
3149
"\n"
3150
"//preprocess context switch data to contain array per thread\n"
3151
"function PreprocessContextSwitchCacheItem(ThreadId)\n"
3152
"{\n"
3153
" var CSObject = S.CSwitchCache[ThreadId];\n"
3154
" if(ThreadId > 0 && !CSObject)\n"
3155
" {\n"
3156
" CSArrayIn = new Array();\n"
3157
" CSArrayOut = new Array();\n"
3158
" CSArrayCpu = new Array();\n"
3159
" var nCount = S.CSwitchTime.length;\n"
3160
" var j = 0;\n"
3161
" var TimeIn = -1.0;\n"
3162
" for(var i = 0; i < nCount; ++i)\n"
3163
" {\n"
3164
" var ThreadIn = S.CSwitchThreadInOutCpu[j];\n"
3165
" var ThreadOut = S.CSwitchThreadInOutCpu[j+1];\n"
3166
" var Cpu = S.CSwitchThreadInOutCpu[j+2];\n"
3167
" if(TimeIn < 0)\n"
3168
" {\n"
3169
" if(ThreadIn == ThreadId)\n"
3170
" {\n"
3171
" TimeIn = S.CSwitchTime[i];\n"
3172
" }\n"
3173
" }\n"
3174
" else\n"
3175
" {\n"
3176
" if(ThreadOut == ThreadId)\n"
3177
" {\n"
3178
" var TimeOut = S.CSwitchTime[i];\n"
3179
" CSArrayIn.push(TimeIn);\n"
3180
" CSArrayOut.push(TimeOut);\n"
3181
" CSArrayCpu.push(Cpu);\n"
3182
" TimeIn = -1;\n"
3183
" }\n"
3184
" }\n"
3185
" j += 3;\n"
3186
" }\n"
3187
" CSObject = new Object();\n"
3188
" CSObject.Size = CSArrayIn.length;\n"
3189
" CSObject.In = CSArrayIn;\n"
3190
" CSObject.Out = CSArrayOut;\n"
3191
" CSObject.Cpu = CSArrayCpu;\n"
3192
" S.CSwitchCache[ThreadId] = CSObject;\n"
3193
" }\n"
3194
"\n"
3195
"}\n"
3196
"function PreprocessContextSwitchCache()\n"
3197
"{\n"
3198
" ProfileEnter(\"PreprocessContextSwitchCache\");\n"
3199
" var AllThreads = {};\n"
3200
" var nCount = S.CSwitchTime.length;\n"
3201
" for(var i = 0; i < nCount; ++i)\n"
3202
" {\n"
3203
" var nThreadIn = S.CSwitchThreadInOutCpu[i];\n"
3204
" if(!AllThreads[nThreadIn])\n"
3205
" {\n"
3206
" AllThreads[nThreadIn] = \'\' + nThreadIn;\n"
3207
" var FoundThread = false;\n"
3208
" for(var i = 0; i < S.ThreadIds.length; ++i)\n"
3209
" {\n"
3210
" if(S.ThreadIds[i] == nThreadIn)\n"
3211
" {\n"
3212
" FoundThread = true;\n"
3213
" }\n"
3214
" }\n"
3215
" if(!FoundThread)\n"
3216
" {\n"
3217
" S.CSwitchOnlyThreads.push(nThreadIn);\n"
3218
" }\n"
3219
" }\n"
3220
" }\n"
3221
" for(var i = 0; i < S.CSwitchOnlyThreads.length; ++i)\n"
3222
" {\n"
3223
" PreprocessContextSwitchCacheItem(S.CSwitchOnlyThreads[i]);\n"
3224
" }\n"
3225
" for(var i = 0; i < S.ThreadIds.length; ++i)\n"
3226
" {\n"
3227
" PreprocessContextSwitchCacheItem(S.ThreadIds[i]);\n"
3228
" }\n"
3229
" function HandleMissingThread(a)\n"
3230
" {\n"
3231
" if(!S.CSwitchThreads[a])\n"
3232
" {\n"
3233
" S.CSwitchThreads[a] = {\'tid\':a, \'pid\':-1, \'t\':\'?\', \'p\':\'?\'}\n"
3234
" }\n"
3235
" }\n"
3236
" function CompareThreadInfo(a, b)\n"
3237
" {\n"
3238
" if(a.pid != b.pid)\n"
3239
" return a.pid - b.pid;\n"
3240
" else\n"
3241
" return a.tid - b.tid;\n"
3242
" }\n"
3243
" S.CSwitchOnlyThreads.sort( function(a, b){\n"
3244
" HandleMissingThread(a);\n"
3245
" HandleMissingThread(b);\n"
3246
" return CompareThreadInfo(S.CSwitchThreads[a], S.CSwitchThreads[b]);\n"
3247
" } );\n"
3248
"\n"
3249
" ProfileLeave();\n"
3250
"}\n"
3251
"\n"
3252
"function DrawContextSwitchBars(context, ThreadId, fScaleX, fOffsetY, fDetailedOffset, nHoverColor, MinWidth, bDrawEnabled, bSecond)\n"
3253
"{\n"
3254
" ProfileEnter(\"DrawContextSwitchBars\");\n"
3255
" var CSObject = S.CSwitchCache[ThreadId];\n"
3256
" if(CSObject && CSObject.Size > 0)\n"
3257
" {\n"
3258
" var Size = CSObject.Size;\n"
3259
" var In = CSObject.In;\n"
3260
" var Out = CSObject.Out;\n"
3261
" var Cpu = CSObject.Cpu;\n"
3262
" let nNumColors = CSwitchColors.length;\n"
3263
" for(var i = 0; i < Size; ++i)\n"
3264
" {\n"
3265
" var TimeIn = In[i];\n"
3266
" var TimeOut = Out[i];\n"
3267
" var ActiveCpu = Cpu[i];\n"
3268
"\n"
3269
" var X = (TimeIn - fDetailedOffset) * fScaleX;\n"
3270
" if(X > nWidth)\n"
3271
" {\n"
3272
" break;\n"
3273
" }\n"
3274
" var W = (TimeOut - TimeIn) * fScaleX;\n"
3275
" if(W > MinWidth && X+W > 0)\n"
3276
" {\n"
3277
" if(nHoverCSCpu == ActiveCpu || bDrawEnabled)\n"
3278
" {\n"
3279
" if(nHoverCSCpu == ActiveCpu)\n"
3280
" {\n"
3281
" context.fillStyle = nHoverColor;\n"
3282
" }\n"
3283
" else\n"
3284
" {\n"
3285
" if(KeyHDown){\n"
3286
" context.fillStyle = CSwitchColors[S.CoreEfficiencyClass[ActiveCpu] % nNumColors];\n"
3287
" }else{\n"
3288
" context.fillStyle = CSwitchColors[ActiveCpu % nNumColors];\n"
3289
" }\n"
3290
" }\n"
3291
" context.fillRect(X, fOffsetY, W, CSwitchHeight);\n"
3292
" }\n"
3293
" if(DetailedViewMouseX >= X && DetailedViewMouseX <= X+W && DetailedViewMouseY < fOffsetY+CSwitchHeight && DetailedViewMouseY >= fOffsetY)\n"
3294
" {\n"
3295
" nHoverCSCpuNext = ActiveCpu;\n"
3296
" RangeCpuNext.Off = bSecond ? fDetailedOffsetSecond : 0;\n"
3297
" RangeCpuNext.Begin = TimeIn;\n"
3298
" RangeCpuNext.End = TimeOut;\n"
3299
" RangeCpuNext.Thread = ThreadId;\n"
3300
" RangeGpuNext.Begin = RangeGpuNext.End = -1;\n"
3301
" }\n"
3302
" }\n"
3303
" }\n"
3304
" }\n"
3305
" else\n"
3306
" {\n"
3307
" //debug: draw context switch without cswitch\n"
3308
" // for(var i = 0; i < 8; ++i)\n"
3309
" // {\n"
3310
" // context.fillStyle = CSwitchColors[i];\n"
3311
" // context.fillRect((nWidth * i / 8) + 10, fOffsetY, nWidth / 8 - 20, CSwitchHeight);\n"
3312
" // }\n"
3313
" }\n"
3314
" ProfileLeave();\n"
3315
"}\n"
3316
"\n"
3317
"function DrawDetailedButtons(context, X, Y, Names, Callbacks, Align)\n"
3318
"{\n"
3319
" if(!Align)\n"
3320
" {\n"
3321
" Align = \"left\";\n"
3322
" }\n"
3323
" var Dir = 1;\n"
3324
" var Offset = 0;\n"
3325
" var OffsetText = 0;\n"
3326
" if(Align == \"right\")\n"
3327
" {\n"
3328
" Dir = -1;\n"
3329
" }\n"
3330
" else if(Align == \"center\")\n"
3331
" {\n"
3332
" Offset = -0.5;\n"
3333
" Align = \"left\";\n"
3334
" }\n"
3335
" let W = Array(Names.length);\n"
3336
" var w = 0;\n"
3337
" for(let i = 0; i < Names.length; ++i)\n"
3338
" {\n"
3339
" W[i] = context.measureText(Names[i]).width;\n"
3340
" w += W[i];\n"
3341
" }\n"
3342
" X += w * Offset;\n"
3343
"\n"
3344
" // context.textBaseline = \'top\';\n"
3345
" context.textAlign = Align;\n"
3346
" context.fillStyle = \'white\';\n"
3347
" var mx = DetailedViewMouseX;\n"
3348
" var my = DetailedViewMouseY;\n"
3349
" for(let i = 0; i < Names.length; ++i)\n"
3350
" {\n"
3351
" let w = W[i];\n"
3352
" let x0_ = X + w * Dir;\n"
3353
" let x0 = Math.min(X, x0_);\n"
3354
" let x1 = Math.max(X, x0_);\n"
3355
" let y0 = Y;\n"
3356
" let y1 = Y + FontHeight;\n"
3357
" context.fillStyle = nBackColors[0];\n"
3358
" context.fillRect(x0, y0, x1 - x0, y1 - y0);\n"
3359
"\n"
3360
" if(mx >= x0 && mx <= x1 && my >= y0 && my <= y1)\n"
3361
" {\n"
3362
" DetailedMouseOverButton = 1;\n"
3363
" context.fillStyle = \'cyan\';\n"
3364
" DetailedAddMouseEvent(99, function(){ Callbacks[i](); } );\n"
3365
" }\n"
3366
" else\n"
3367
" {\n"
3368
" context.fillStyle = \'white\';\n"
3369
" }\n"
3370
"\n"
3371
" context.fillText(Names[i], X, Y + FontHeight - 2);\n"
3372
" X += Dir * (w+FontWidth);\n"
3373
" }\n"
3374
"\n"
3375
" context.fillStyle = \'white\';\n"
3376
" context.textAlign = \'left\';\n"
3377
"}\n"
3378
"\n"
3379
"function DrawDetailedViewLargeHeader(context, Text, Y)\n"
3380
"{\n"
3381
" context.textAlign = \"left\";\n"
3382
" context.fillStyle = \"grey\";\n"
3383
" context.strokeStyle = \"grey\";\n"
3384
" context.textBaseline = \"top\";\n"
3385
" context.font = FontLarge;\n"
3386
" context.beginPath();\n"
3387
" context.moveTo(0, Y);\n"
3388
" context.lineTo(nWidth, Y);\n"
3389
" context.stroke();\n"
3390
" context.fillText(Text, 0, Y + 2);\n"
3391
" context.font = Font;\n"
3392
" context.textBaseline = \"alphabetic\";\n"
3393
" return Y + 2 + FontHeightLarge;\n"
3394
"}\n"
3395
"\n"
3396
"function DrawDetailedView(S, S0, context, MinWidth, bDrawEnabled)\n"
3397
"{\n"
3398
" if(!S || !S.Frames)\n"
3399
" {\n"
3400
" return;\n"
3401
" }\n"
3402
" let bSecond = S != S0;\n"
3403
" if(bDrawEnabled && !bSecond)\n"
3404
" {\n"
3405
" DrawDetailedBackground(context);\n"
3406
" }\n"
3407
"\n"
3408
" let colors = [ \'#ff0000\', \'#ff00ff\', \'#ffff00\'];\n"
3409
" let fScaleX = nWidth / fDetailedRange;\n"
3410
" let fOffsetY = -nOffsetY + BoxHeight;\n"
3411
"\n"
3412
"\n"
3413
" let nHoverTokenStack = -1;\n"
3414
" if(S == S0)\n"
3415
" {\n"
3416
" nHoverCounter += nHoverCounterDelta;\n"
3417
" if(nHoverCounter >= 255)\n"
3418
" {\n"
3419
" nHoverCounter = 255;\n"
3420
" nHoverCounterDelta = -nHoverCounterDelta;\n"
3421
" }\n"
3422
" if(nHoverCounter < 128)\n"
3423
" {\n"
3424
" nHoverCounter = 128;\n"
3425
" nHoverCounterDelta = -nHoverCounterDelta;\n"
3426
" }\n"
3427
" }\n"
3428
" let nHoverHigh = nHoverCounter.toString(16);\n"
3429
" let nHoverLow = (127+255-nHoverCounter).toString(16);\n"
3430
" let nHoverColor = \'#\' + nHoverHigh + nHoverHigh + nHoverHigh;\n"
3431
" let nHoverColorIndex;\n"
3432
"\n"
3433
" context.fillStyle = \'black\';\n"
3434
" context.font = Font;\n"
3435
" // context.textBaseline = \'alphabetic\';\n"
3436
"\n"
3437
" let nNumLogs = S.Frames[0].ts.length;\n"
3438
" if(S0)\n"
3439
" {\n"
3440
" let l0 = S0.Frames[0].ts.length;\n"
3441
" let l1 = S.Frames[0].ts.length\n"
3442
" if(l1 != l0)\n"
3443
" debugger;\n"
3444
" }\n"
3445
" let Off = fDetailedOffset;\n"
3446
" let XOffset = 0;\n"
3447
" if(bSecond)\n"
3448
" {\n"
3449
" XOffset = fDetailedOffsetSecond;\n"
3450
" Off += XOffset;\n"
3451
" }\n"
3452
" let fTimeEnd = Off + fDetailedRange;\n"
3453
"\n"
3454
" let FirstFrame = 0;\n"
3455
" for(let i = 0; i < S.Frames.length ; i++)\n"
3456
" {\n"
3457
" if(S.Frames[i].frameend < Off)\n"
3458
" {\n"
3459
" FirstFrame = i;\n"
3460
" }\n"
3461
" }\n"
3462
"\n"
3463
" let BoxHeightScaled = BoxHeight;\n"
3464
" let Scale = 1;\n"
3465
" let fExtra = 0;\n"
3466
" let Padding = 15;\n"
3467
" let SecondReverseOffset = 0;\n"
3468
" if(DrawDetailedFlameMode == 1)\n"
3469
" {\n"
3470
" BoxHeightScaled = Math.ceil(BoxHeight*0.5);\n"
3471
" fExtra = 0.5;\n"
3472
" }\n"
3473
" else if(DrawDetailedFlameMode == 2)\n"
3474
" {\n"
3475
" BoxHeightScaled = 0;\n"
3476
" fExtra = 1;\n"
3477
" }\n"
3478
" if(DrawDetailedCompareReverse && bSecond)\n"
3479
" {\n"
3480
" Scale = -1;\n"
3481
" BoxHeightScaled = -BoxHeightScaled;\n"
3482
" SecondReverseOffset = 5-BoxHeight;\n"
3483
" }\n"
3484
" let BoxHeightScaledPos = Math.abs(BoxHeightScaled);\n"
3485
" let BatchesTxtColor = [\'#ffffff\', \'#333333\'];\n"
3486
" let TotalBatches = 0;\n"
3487
" let BatchData = {};\n"
3488
" {\n"
3489
" let L = BatchData;\n"
3490
" L.Batches = new Array(g_Colors.length+1);\n"
3491
" L.BatchesTxt = new Array();\n"
3492
" L.BatchesTxtPos = new Array();\n"
3493
" for(let i = 0; i < 2; ++i)\n"
3494
" {\n"
3495
" L.BatchesTxt[i] = Array();\n"
3496
" L.BatchesTxtPos[i] = Array();\n"
3497
" }\n"
3498
" for(let i = 0; i < L.Batches.length; ++i)\n"
3499
" {\n"
3500
" L.Batches[i] = Array();\n"
3501
" }\n"
3502
" }\n"
3503
" let AddBatch = function(StackPos, index, X, Y, W, Name, NameLen, Duration, Opacity)\n"
3504
" {\n"
3505
" TotalBatches++;\n"
3506
" let L = BatchData;\n"
3507
" let O = Opacity ? Opacity : 1.0;\n"
3508
" O = 1-((1-O)*(1-O));\n"
3509
" let B = L.Batches[index];\n"
3510
" let txtidx = g_ColorsTextIndex[index];\n"
3511
" if(txtidx < 0 || txtidx > 1)\n"
3512
" debugger;\n"
3513
" let BTxt = L.BatchesTxt[txtidx];\n"
3514
" let BTxtPos = L.BatchesTxtPos[txtidx];\n"
3515
" B.push(X);\n"
3516
" B.push(Y);\n"
3517
" B.push(W);\n"
3518
" B.push(O);\n"
3519
" DebugDrawQuadCount++;\n"
3520
"\n"
3521
" let XText = X < 0 ? 0 : X;\n"
3522
" let WText = W - (XText-X);\n"
3523
" if(XText + WText > nWidth)\n"
3524
" {\n"
3525
" WText = nWidth - XText;\n"
3526
" }\n"
3527
" let BarTextLen = Math.floor((WText-2)/FontWidth);\n"
3528
"\n"
3529
" if(BarTextLen >= 2)\n"
3530
" {\n"
3531
" let TimeText = TimeToMsString(Duration);\n"
3532
" let TimeTextLen = TimeText.length;\n"
3533
" if(BarTextLen < NameLen)\n"
3534
" Name = Name.substr(0, BarTextLen);\n"
3535
" let YPos = Y+BoxHeight-FontAscent;\n"
3536
" BTxt.push(Name);\n"
3537
" BTxtPos.push(XText+2);\n"
3538
"\n"
3539
" BTxtPos.push(YPos);\n"
3540
" DebugDrawTextCount++;\n"
3541
" if(BarTextLen - NameLen > TimeTextLen)\n"
3542
" {\n"
3543
" BTxt.push(TimeText);\n"
3544
" BTxtPos.push(XText+WText-2 - TimeTextLen * FontWidth);\n"
3545
" BTxtPos.push(YPos);\n"
3546
" DebugDrawTextCount++;\n"
3547
" }\n"
3548
" }\n"
3549
" };\n"
3550
" {\n"
3551
" let Times = Timeline.Times;\n"
3552
" let Colors = Timeline.Colors;\n"
3553
" let Ends = Timeline.Ends;\n"
3554
" let Positions = Timeline.Positions;\n"
3555
" let Names = Timeline.Names;\n"
3556
" let SearchMatch = Timeline.SearchMatch;\n"
3557
" let off = 0.7;\n"
3558
" let off2 = 2*off;\n"
3559
" let MaxPosition = 1;\n"
3560
" if(Timeline.Positions.length)\n"
3561
" {\n"
3562
" fOffsetY = DrawDetailedViewLargeHeader(context, \"Timeline\", fOffsetY);\n"
3563
" }\n"
3564
"\n"
3565
" for(let i = 0; i < Timeline.Positions.length; ++i)\n"
3566
" {\n"
3567
" let TimeStart = Times[i];\n"
3568
" let TimeEnd = Ends[i];\n"
3569
" let Position = Positions[i];\n"
3570
" if(Position >= 0)\n"
3571
" {\n"
3572
" MaxPosition = Math.max(Position, MaxPosition);\n"
3573
" let Color = Colors[i];\n"
3574
" let Name = Names[i];\n"
3575
" let P = Positions[i];\n"
3576
" let X = (TimeStart - Off) * fScaleX;\n"
3577
" let Y = fOffsetY + P * (BoxHeight+2);\n"
3578
" let W = (TimeEnd-TimeStart)*fScaleX;\n"
3579
" if(FilterInputSearchActive2)\n"
3580
" {\n"
3581
" Color = SearchMatch[i] ? CIDMatch : CIDFail;\n"
3582
" }\n"
3583
" if(!bSecond)\n"
3584
" {\n"
3585
" if(DetailedViewMouseX >= X && DetailedViewMouseX <= X+W && DetailedViewMouseY < Y+BoxHeight && DetailedViewMouseY >= Y)\n"
3586
" {\n"
3587
" RangeCpuNext.Off = 0;\n"
3588
" RangeCpuNext.Begin = TimeStart;\n"
3589
" RangeCpuNext.End = TimeEnd;\n"
3590
" RangeCpuNext.Thread = -1;\n"
3591
" nHoverColorIndex = Color;\n"
3592
" Color = cidhovercolor;\n"
3593
" }\n"
3594
" AddBatch(0, Color, X, Y, W, Name, Name.length, TimeEnd-TimeStart);\n"
3595
" }\n"
3596
" }\n"
3597
" }\n"
3598
" fOffsetY += (1+MaxPosition) * (BoxHeight+3);\n"
3599
" }\n"
3600
" let nMinTimeMs = MinWidth / fScaleX;\n"
3601
" let AutoHideCount = 0;\n"
3602
" let VisibleThreadCount = 0;\n"
3603
" let DrawGuides = 1;\n"
3604
" let CurrentHeading;\n"
3605
" {\n"
3606
" if(!ThreadYBegin)\n"
3607
" {\n"
3608
" ThreadYBegin = Array(S0.ThreadNames.length);\n"
3609
" ThreadYEnd = Array(S0.ThreadNames.length);\n"
3610
" }\n"
3611
"\n"
3612
" for(let i = 0; i < nNumLogs; i++)\n"
3613
" {\n"
3614
" let nLog = ThreadOrderT[i];\n"
3615
" let ThreadName = S0.ThreadNames[nLog];\n"
3616
" let LogIsGPU = S0.ISGPU[nLog];\n"
3617
" let HeadingString = LogIsGPU ? \"GPU\" : \"CPU\";\n"
3618
" let Active = IsThreadActive(ThreadName) && 0 == S.ThreadLogAutoHidden[nLog];\n"
3619
" let ThreadColors = S0.ThreadColors[nLog];\n"
3620
" if(HeadingString != CurrentHeading)\n"
3621
" {\n"
3622
" fOffsetY = DrawDetailedViewLargeHeader(context, HeadingString, fOffsetY);\n"
3623
" CurrentHeading = HeadingString;\n"
3624
" }\n"
3625
"\n"
3626
"\n"
3627
" if(0 != S.ThreadLogAutoHidden[nLog] && HideMode == HideModeFullyHidden)\n"
3628
" {\n"
3629
" AutoHideCount++;\n"
3630
" continue;\n"
3631
" }\n"
3632
" if(HideMode == HideModeFullyHidden && !Active)\n"
3633
" {\n"
3634
" AutoHideCount++;\n"
3635
" continue;\n"
3636
" }\n"
3637
" VisibleThreadCount++;\n"
3638
" let SMul = 2;\n"
3639
" let LogHeight = (S0.MaxStack[nLog]) * BoxHeightScaledPos + BoxHeight;\n"
3640
" let LogHeight2 = (S0.MaxStack2[nLog]) * BoxHeightScaledPos + BoxHeight;\n"
3641
" if(nContextSwitchEnabled)\n"
3642
" {\n"
3643
" LogHeight += (CSwitchHeight+4);\n"
3644
" LogHeight2 += (CSwitchHeight+4);\n"
3645
" }\n"
3646
" if(!S0.SecondActive)\n"
3647
" {\n"
3648
" LogHeight2 = 0;\n"
3649
" }\n"
3650
" let OY = fOffsetY;\n"
3651
" if(!bSecond)\n"
3652
" {\n"
3653
" OY += LogHeight2+1;\n"
3654
" }\n"
3655
" else\n"
3656
" {\n"
3657
" if(DrawDetailedCompareReverse)\n"
3658
" {\n"
3659
" OY += LogHeight2 - 5;\n"
3660
" }\n"
3661
" }\n"
3662
"\n"
3663
" let fOffsetYDelta = Active ? (LogHeight + LogHeight2 + Padding) : BoxHeight;\n"
3664
"\n"
3665
" ThreadYBegin[nLog] = fOffsetY;\n"
3666
" ThreadYEnd[nLog] = fOffsetY + fOffsetYDelta;\n"
3667
"\n"
3668
" let ThreadHover = false;\n"
3669
" if(bDrawEnabled)\n"
3670
" {\n"
3671
" if(Active || !bSecond)\n"
3672
" {\n"
3673
" let Color = bSecond ? ThreadColors.coloroff : ThreadColors.color;\n"
3674
" let ColorLine = !bSecond ? ThreadColors.colordark : ThreadColors.color;\n"
3675
" let BaseY = (bSecond||!Active) ? (fOffsetY+1) : (fOffsetY+1+LogHeight2);\n"
3676
" let HeightY = !Active ? BoxHeight : (bSecond ? LogHeight2 : (LogHeight + Padding));\n"
3677
" let TransparentLine = S2.Frames != null && !bSecond;\n"
3678
" if(TransparentLine)\n"
3679
" {\n"
3680
" context.globalAlpha = 0.4;\n"
3681
" }\n"
3682
" context.strokeStyle = ColorLine;\n"
3683
" context.beginPath();\n"
3684
" context.moveTo(0, BaseY+HeightY-1);\n"
3685
" context.lineTo(nWidth, BaseY+HeightY-1);\n"
3686
" context.stroke();\n"
3687
" if(TransparentLine)\n"
3688
" {\n"
3689
" context.globalAlpha = 1.0;\n"
3690
" }\n"
3691
" let Gradient = context.createLinearGradient(0,BaseY,0,40 + BaseY);\n"
3692
" Gradient.addColorStop(0, ThreadColors.colortrans);\n"
3693
" Gradient.addColorStop(1,\'transparent\');\n"
3694
" if(bSecond)\n"
3695
" ThreadColors.gradientoff = Gradient;\n"
3696
" else\n"
3697
" ThreadColors.gradient = Gradient;\n"
3698
" context.fillStyle = Gradient;\n"
3699
" context.fillRect(0,BaseY,nWidth,HeightY);\n"
3700
" }\n"
3701
" }\n"
3702
" let D = fOffsetY + BoxHeight - DetailedViewMouseY;\n"
3703
"\n"
3704
" if(!bSecond)\n"
3705
" {\n"
3706
" if(D > 0 && D < BoxHeight)\n"
3707
" {\n"
3708
" if(!bDrawEnabled)\n"
3709
" {\n"
3710
" context.globalAlpha = 0.3;\n"
3711
" context.fillStyle = \'grey\';\n"
3712
" context.fillRect(0, fOffsetY+2, nWidth, Active ? LogHeight2 + LogHeight + Padding : BoxHeight);\n"
3713
" context.globalAlpha = 1.0;\n"
3714
" }\n"
3715
" ThreadHover = 1;\n"
3716
" }\n"
3717
" }\n"
3718
" let HasSetHover = 0;\n"
3719
"\n"
3720
"\n"
3721
" if(Active)\n"
3722
" {\n"
3723
" if(DrawDetailedNewDraw)\n"
3724
" {\n"
3725
" OY += 4;\n"
3726
"\n"
3727
" if(nContextSwitchEnabled)\n"
3728
" {\n"
3729
" DrawContextSwitchBars(context, S.ThreadIds[nLog], fScaleX, OY, Off, nHoverColor, MinWidth, bDrawEnabled, bSecond);\n"
3730
" OY += Scale * (CSwitchHeight+2);\n"
3731
" }\n"
3732
" OY += SecondReverseOffset;\n"
3733
" // Duration of 1 pixel\n"
3734
" let ThresholdPixelDuration = fDetailedRange / nWidth;\n"
3735
" let ThresholdLimit = ThresholdPixelDuration * 1.0; // if below this we dont go further down\n"
3736
" let Rows = S.LogRows[nLog];\n"
3737
" for(let r in Rows)\n"
3738
" {\n"
3739
" {\n"
3740
" let Row = Rows[r];\n"
3741
" let Size = Row.Tree.length;\n"
3742
" let Tree = Row.Tree;\n"
3743
" const Y = OY + r * BoxHeightScaled;\n"
3744
" const MY = DetailedViewMouseY < Y+BoxHeight && DetailedViewMouseY >= Y;\n"
3745
"\n"
3746
"\n"
3747
" let DrawRange = function(Depth, Begin, End)\n"
3748
" {\n"
3749
" let TreeLevel = Tree[Depth];\n"
3750
" for(let j = Begin; j < End; ++j)\n"
3751
" {\n"
3752
" let TimeBegin = TreeLevel.Begin[j];\n"
3753
" let Duration = TreeLevel.Duration[j];\n"
3754
" let TimeEnd = TimeBegin + Duration;\n"
3755
" if(TimeBegin < fTimeEnd && TimeEnd > Off)\n"
3756
" {\n"
3757
"\n"
3758
" if(Depth > 0 && TreeLevel.Duration[j] > ThresholdLimit)\n"
3759
" {\n"
3760
" DrawRange(Depth-1, j*2, j*2 + 2);\n"
3761
" }\n"
3762
" else\n"
3763
" {\n"
3764
" let Index = TreeLevel.Index[j];\n"
3765
" let cid = TreeLevel.ColorIds[j];\n"
3766
" let Opacity = Depth == 0 ? 1.0 : TreeLevel.SumDuration[j] / TreeLevel.Duration[j];\n"
3767
"\n"
3768
" if(FilterInputSearchActive2)\n"
3769
" {\n"
3770
" if(Depth == 0)\n"
3771
" cid = S0.TimerInfo[Index].search;\n"
3772
" else\n"
3773
" cid = CIDFail;\n"
3774
" }\n"
3775
" else\n"
3776
" {\n"
3777
" if(GroupColors == 1 && Depth == 0)\n"
3778
" cid = S0.TimerInfo[Index].cid;\n"
3779
" if(GroupColors == 2)\n"
3780
" cid = ThreadColors.colordark_cid;\n"
3781
" if(GroupColors == 3)\n"
3782
" cid = TreeLevel.SectionColor[j];\n"
3783
" }\n"
3784
" if(Index == nHoverToken)\n"
3785
" {\n"
3786
" nHoverColorIndex = cid;\n"
3787
" cid = cidhovercolor;\n"
3788
" }\n"
3789
"\n"
3790
"\n"
3791
" let Name = Depth == 0 ? S0.TimerInfo[Index].name : \"\";\n"
3792
" let NameLen = Depth == 0 ? S0.TimerInfo[Index].len : 0;\n"
3793
" let X = (TimeBegin - Off) * fScaleX;\n"
3794
" let W = (TimeEnd-TimeBegin)*fScaleX;\n"
3795
" if(W > 1 || Opacity > 0.1)\n"
3796
" {\n"
3797
" AddBatch(Depth, cid, X, Y, W, Name, NameLen, TimeEnd-TimeBegin, Opacity);\n"
3798
" }\n"
3799
"\n"
3800
" const M = MY && DetailedViewMouseX >= X && DetailedViewMouseX <= X+W;\n"
3801
" if(Depth == 0 && M)\n"
3802
" {\n"
3803
" RangeCpuNext.Off = bSecond ? fDetailedOffsetSecond : 0;\n"
3804
" RangeCpuNext.Begin = TimeBegin;\n"
3805
" RangeCpuNext.End = TimeEnd;\n"
3806
" RangeCpuNext.Thread = nLog;\n"
3807
" RangeCpuNext.Off = XOffset;\n"
3808
" if(TreeLevel.CpuDuration && TreeLevel.CpuDuration[j]) // detect if its a gpu marker, with embedded cpu ticks.\n"
3809
" {\n"
3810
" RangeGpuNext.Begin = RangeCpuNext.Begin;\n"
3811
" RangeGpuNext.End = RangeCpuNext.End;\n"
3812
" RangeGpuNext.Thread = nLog;\n"
3813
" RangeGpuNext.Off = XOffset;\n"
3814
"\n"
3815
" RangeCpuNext.Begin = TreeLevel.CpuBegin[j];\n"
3816
" RangeCpuNext.End = TreeLevel.CpuBegin[j] + TreeLevel.CpuDuration[j];\n"
3817
" RangeCpuNext.Thread = TreeLevel.CpuThread[j];\n"
3818
" RangeCpuNext.Off = XOffset;\n"
3819
" }\n"
3820
" else\n"
3821
" {\n"
3822
" RangeGpuNext.Begin = -1;\n"
3823
" RangeGpuNext.End = -1\n"
3824
" }\n"
3825
" nHoverTokenNext = Index;\n"
3826
" nHoverTokenStack = r;\n"
3827
" nHoverTokenIndexNext = TreeLevel.Source[j];\n"
3828
" nHoverTokenLogIndexNext = nLog;\n"
3829
" HoverTokenNextOwner = S;\n"
3830
" HasSetHover = 1;\n"
3831
"\n"
3832
"\n"
3833
" if(Index == FilterSearchPassIndex)\n"
3834
" {\n"
3835
" console.log(\"kill this\");\n"
3836
" let Range = RangeInit();\n"
3837
" Range.Begin = TimeBegin;\n"
3838
" Range.End = TimeEnd;\n"
3839
" Range.Thread = nLog;\n"
3840
" Range.YBegin = Y - ThreadYBegin[nLog];\n"
3841
" Range.Second = bSecond;\n"
3842
"\n"
3843
" if(FilterSearchArray.length < 500)\n"
3844
" {\n"
3845
" FilterSearchArray.push(Range);\n"
3846
" if(FilterSearchArray.length == 500)\n"
3847
" {\n"
3848
" ShowFlashMessage(\'Capping Search Result to 500\', 30);\n"
3849
" }\n"
3850
" }\n"
3851
" }\n"
3852
"\n"
3853
"\n"
3854
"\n"
3855
" }\n"
3856
" }\n"
3857
" }\n"
3858
" }\n"
3859
" }\n"
3860
" DrawRange(Size-1, 0, Tree[Size-1].Length);\n"
3861
" // if tree is uneven, the tails won\'t have parents.\n"
3862
" for(let i = Size-2; i >= 0; --i)\n"
3863
" {\n"
3864
" let TreeLen = Tree[i].Length;\n"
3865
" if((TreeLen % 2) == 1)\n"
3866
" DrawRange(i, TreeLen-1, TreeLen);\n"
3867
" }\n"
3868
"\n"
3869
" }\n"
3870
" }\n"
3871
" }\n"
3872
" else\n"
3873
" {\n"
3874
"\n"
3875
" let LodIndex = 0;\n"
3876
" let MinDelta = 0;\n"
3877
" let NextLod = 1;\n"
3878
" while(NextLod < S.LodData.length && S.LodData[NextLod].MinDelta[nLog] < nMinTimeMs)\n"
3879
" {\n"
3880
" LodIndex = NextLod;\n"
3881
" NextLod = NextLod + 1;\n"
3882
" MinDelta = S.LodData[LodIndex].MinDelta[nLog];\n"
3883
" }\n"
3884
" if(LodIndex == S.LodData.length)\n"
3885
" {\n"
3886
" LodIndex = S.LodData.length-1;\n"
3887
" }\n"
3888
" if(DisableLod || FilterSearchPassIndex != -1)\n"
3889
" {\n"
3890
" LodIndex = 0;\n"
3891
" }\n"
3892
"\n"
3893
" OY += 4;\n"
3894
"\n"
3895
" if(nContextSwitchEnabled)\n"
3896
" {\n"
3897
" DrawContextSwitchBars(context, S.ThreadIds[nLog], fScaleX, OY, Off, nHoverColor, MinWidth, bDrawEnabled, bSecond);\n"
3898
" OY += Scale * (CSwitchHeight+2);\n"
3899
" }\n"
3900
" OY += SecondReverseOffset;\n"
3901
" let MaxDepth = 1;\n"
3902
" let StackPos = 0;\n"
3903
" let Stack = Array(20);\n"
3904
" let Lod = S.LodData[LodIndex];\n"
3905
"\n"
3906
" let TypeArray = Lod.TypeArray[nLog];\n"
3907
" let IndexArray = Lod.IndexArray[nLog];\n"
3908
" let TimeArray = Lod.TimeArray[nLog];\n"
3909
"\n"
3910
" let LocalFirstFrame = S.Frames[FirstFrame].FirstFrameIndex[nLog];\n"
3911
" let IndexStart = S.ISGPU[nLog] ? 0 : Lod.LogStart[LocalFirstFrame][nLog];\n"
3912
" let IndexEnd = TimeArray.length;\n"
3913
" IndexEnd = TimeArray.length;\n"
3914
"\n"
3915
"\n"
3916
"\n"
3917
" for(let j = IndexStart; j < IndexEnd; ++j)\n"
3918
" {\n"
3919
" let type = TypeArray[j];\n"
3920
" let index = IndexArray[j];\n"
3921
" let time = TimeArray[j];\n"
3922
" if(type == 1)\n"
3923
" {\n"
3924
" //push\n"
3925
" Stack[StackPos] = j;\n"
3926
" StackPos++;\n"
3927
" if(StackPos > MaxDepth)\n"
3928
" {\n"
3929
" MaxDepth = StackPos;\n"
3930
" }\n"
3931
" }\n"
3932
" else if(type == 0)\n"
3933
" {\n"
3934
" if(StackPos>0)\n"
3935
" {\n"
3936
" StackPos--;\n"
3937
"\n"
3938
" let StartIndex = Stack[StackPos];\n"
3939
" let timestart = TimeArray[StartIndex];\n"
3940
" let timeend = time;\n"
3941
" let X = (timestart - Off) * fScaleX;\n"
3942
" let Y = OY + StackPos * BoxHeightScaled;\n"
3943
"\n"
3944
" let W = (timeend-timestart)*fScaleX;\n"
3945
"\n"
3946
" if(X < nWidth && X+W > 0)\n"
3947
" {\n"
3948
" if(index == FilterSearchPassIndex)\n"
3949
" {\n"
3950
" let Range = RangeInit();\n"
3951
" Range.Begin = timestart;\n"
3952
" Range.End = timeend;\n"
3953
" Range.Thread = nLog;\n"
3954
" Range.YBegin = Y - ThreadYBegin[nLog];\n"
3955
" Range.Second = bSecond;\n"
3956
"\n"
3957
" if(FilterSearchArray.length < 500)\n"
3958
" {\n"
3959
" FilterSearchArray.push(Range);\n"
3960
" if(FilterSearchArray.length == 500)\n"
3961
" {\n"
3962
" ShowFlashMessage(\'Capping Search Result to 500\', 30);\n"
3963
" }\n"
3964
" }\n"
3965
" }\n"
3966
" if(W > MinWidth)\n"
3967
" {\n"
3968
" if(bDrawEnabled || index == nHoverToken)\n"
3969
" {\n"
3970
" let cid = GroupColors == 2 ? ThreadColors.colordark_cid : S0.TimerInfo[index].cid;\n"
3971
" if(index == nHoverToken)\n"
3972
" {\n"
3973
" nHoverColorIndex = cid;\n"
3974
" cid = cidhovercolor;\n"
3975
" }\n"
3976
" AddBatch(StackPos, cid, X, Y, W, S0.TimerInfo[index].name, S0.TimerInfo[index].len, timeend-timestart);\n"
3977
" }\n"
3978
"\n"
3979
"\n"
3980
" if(DetailedViewMouseX >= X && DetailedViewMouseX <= X+W && DetailedViewMouseY < Y+BoxHeight && DetailedViewMouseY >= Y && StackPos > nHoverTokenStack)\n"
3981
" {\n"
3982
" RangeCpuNext.Off = bSecond ? fDetailedOffsetSecond : 0;\n"
3983
" RangeCpuNext.Begin = timestart;\n"
3984
" RangeCpuNext.End = timeend;\n"
3985
" RangeCpuNext.Thread = nLog;\n"
3986
" RangeCpuNext.Off = XOffset;\n"
3987
" if((TypeArray[StartIndex+1]&3) == 3 && (TypeArray[j+1]&3) == 3)\n"
3988
" {\n"
3989
" RangeGpuNext.Begin = RangeCpuNext.Begin;\n"
3990
" RangeGpuNext.End = RangeCpuNext.End;\n"
3991
" RangeGpuNext.Thread = nLog;\n"
3992
" RangeGpuNext.Off = XOffset;\n"
3993
" //cpu tick is stored following\n"
3994
" RangeCpuNext.Begin = TimeArray[StartIndex+1];\n"
3995
" RangeCpuNext.End = TimeArray[j+1];\n"
3996
" RangeCpuNext.Thread = IndexArray[StartIndex+1];\n"
3997
" RangeCpuNext.Off = XOffset;\n"
3998
" }\n"
3999
" else\n"
4000
" {\n"
4001
" RangeGpuNext.Begin = -1;\n"
4002
" RangeGpuNext.End = -1\n"
4003
" }\n"
4004
"\n"
4005
" nHoverTokenNext = index;\n"
4006
" nHoverTokenStack = StackPos;\n"
4007
" nHoverTokenIndexNext = j;\n"
4008
" nHoverTokenLogIndexNext = nLog;\n"
4009
" HoverTokenNextOwner = S;\n"
4010
" HasSetHover = 1;\n"
4011
" }\n"
4012
" }\n"
4013
" }\n"
4014
" if(StackPos == 0 && time > fTimeEnd)\n"
4015
" break;\n"
4016
" }\n"
4017
" }\n"
4018
" }\n"
4019
" // if(HasSetHover)\n"
4020
" // {\n"
4021
" // for(let i = 0; i < S.Frames.length-1; ++i)\n"
4022
" // {\n"
4023
" // let IndexStart = Lod.LogStart[i][nLog];\n"
4024
" // if(nHoverTokenIndexNext >= IndexStart)\n"
4025
" // {\n"
4026
" // nHoverFrame = i;\n"
4027
" // }\n"
4028
" // }\n"
4029
" // }\n"
4030
" }\n"
4031
" }\n"
4032
" let w = context.measureText(ThreadName).width;\n"
4033
" context.fillStyle = nBackColors[0];\n"
4034
" context.fillStyle = \'white\';\n"
4035
" context.fillText(ThreadName, 0, fOffsetY+FontHeight-1);\n"
4036
" if(ThreadHover)\n"
4037
" {\n"
4038
" DrawDetailedButtons(context, nWidth, fOffsetY+1, [\"\\u2191\\u2191\\u2191\", \"\\u2193\\u2193\\u2193\", \"\\u2191\", \"\\u2193\"],\n"
4039
" [function(){ThreadOrderMoveUp(ThreadName,1);}, function(){ThreadOrderMoveDown(ThreadName,1);},\n"
4040
" function(){ThreadOrderMoveUp(ThreadName);}, function(){ThreadOrderMoveDown(ThreadName);}],\n"
4041
" \"right\");\n"
4042
" // DetailedAddMouseEvent(1, function(){ Callbacks[i](); } );\n"
4043
" DetailedAddMouseEvent(1, function()\n"
4044
" {\n"
4045
" ToggleThread(ThreadName);\n"
4046
" });\n"
4047
" }\n"
4048
" // context.textBaseline = \'alphabetic\';\n"
4049
" fOffsetY += fOffsetYDelta;\n"
4050
" // ThreadY[nLog+1] = fOffsetY;\n"
4051
" }\n"
4052
" if(AutoHideCount)\n"
4053
" {\n"
4054
" fOffsetY += FontHeight;\n"
4055
" let Text = AutoHideCount + \" Threads Auto Hidden. Toggle in Thread Menu to show\";\n"
4056
" let w = context.measureText(Text).width;\n"
4057
" context.fillStyle = \"orange\";\n"
4058
" context.fillText(Text, 0, fOffsetY+FontHeight-1);\n"
4059
" }\n"
4060
" if(VisibleThreadCount == 0 && HideMode == HideModeFullyHidden)\n"
4061
" {\n"
4062
" fOffsetY += FontHeight;\n"
4063
" let Text = \"All Threads Hidden. Toggle in Thread Menu to show\";\n"
4064
" let w = context.measureText(Text).width;\n"
4065
" context.fillStyle = \"red\";\n"
4066
" context.fillText(Text, 0, fOffsetY+FontHeight-1);\n"
4067
" }\n"
4068
"\n"
4069
" if(nContextSwitchEnabled && !bSecond) //non instrumented threads.\n"
4070
" {\n"
4071
" let CurrentPid = -112;\n"
4072
" let ContextSwitchThreads = S.CSwitchOnlyThreads;\n"
4073
" function DrawHeader(str, X, Y)\n"
4074
" {\n"
4075
" let width = str.length * FontWidth;\n"
4076
" context.globalAlpha = 0.5;\n"
4077
" context.fillStyle = \'grey\';\n"
4078
" context.fillRect(X, Y-FontHeight + 2, width, FontHeight);\n"
4079
" context.globalAlpha = 1.0;\n"
4080
" context.fillStyle = \'white\';\n"
4081
" context.fillText(str, X, Y);\n"
4082
"\n"
4083
"\n"
4084
" }\n"
4085
" for(let i = 0; i < ContextSwitchThreads.length; ++i)\n"
4086
" {\n"
4087
" let ThreadId = ContextSwitchThreads[i];\n"
4088
" let ThreadName = \'\' + ThreadId;\n"
4089
" let TI = S.CSwitchThreads[ThreadId];\n"
4090
"\n"
4091
" if(TI)\n"
4092
" {\n"
4093
" if(CurrentPid != TI.pid)\n"
4094
" {\n"
4095
" fOffsetY += BoxHeight + 1;\n"
4096
" CurrentPid = TI.pid;\n"
4097
" let str = TI.pid.toString(16) +\':\' +TI.p;\n"
4098
" DrawHeader(str, 0, fOffsetY+5);\n"
4099
" fOffsetY += BoxHeight + 1;\n"
4100
" }\n"
4101
" }\n"
4102
"\n"
4103
" DrawContextSwitchBars(context, ThreadId, fScaleX, fOffsetY, Off, nHoverColor, MinWidth, bDrawEnabled);\n"
4104
"\n"
4105
" if(TI)\n"
4106
" {\n"
4107
" DrawHeader(TI.tid.toString(16) +\':\' +TI.t, 10, fOffsetY+5);\n"
4108
" }\n"
4109
" fOffsetY += BoxHeight + 1;\n"
4110
" }\n"
4111
" }\n"
4112
" {\n"
4113
" let h = nHeight;\n"
4114
"\n"
4115
" }\n"
4116
" let TOP_LIMIT = 100;\n"
4117
" if(fOffsetY < TOP_LIMIT)\n"
4118
" {\n"
4119
" let Diff = fOffsetY - TOP_LIMIT;\n"
4120
" nOffsetY += Math.floor(Diff);\n"
4121
" nOffsetY = Math.max(0, nOffsetY);\n"
4122
" }\n"
4123
" let FillRects = function(a, color, colordark)\n"
4124
" {\n"
4125
" context.fillStyle = color;\n"
4126
" let opac = -1;\n"
4127
" for(let j = 0; j < a.length; j += 4)\n"
4128
" {\n"
4129
" let X = a[j];\n"
4130
" let Y = a[j+1];\n"
4131
" let W = a[j+2];\n"
4132
" let O = a[j+3];\n"
4133
" if(O != opac)\n"
4134
" {\n"
4135
" opac = O;\n"
4136
" context.globalAlpha = opac;\n"
4137
" }\n"
4138
" context.fillRect(X, Y, W, BoxHeight-1);\n"
4139
" }\n"
4140
" };\n"
4141
" let rect_calls = 0;\n"
4142
" let text_calls = 0;\n"
4143
"\n"
4144
" {\n"
4145
" let Batches = BatchData.Batches;\n"
4146
" for(let i = 0; i < Batches.length; ++i)\n"
4147
" {\n"
4148
" let a = Batches[i];\n"
4149
" if(a.length)\n"
4150
" {\n"
4151
" let Color = i == 0 ? nHoverColor : g_Colors[i];\n"
4152
" let ColorDark = i == 0 ? nHoverColor : g_ColorsDark[i];\n"
4153
" if(i == 0)\n"
4154
" {\n"
4155
" if(nHoverColorIndex)\n"
4156
" {\n"
4157
" let mult = nHoverCounter / 255.0;\n"
4158
" let m2 =mult -0.5;\n"
4159
" let m4 = m2 * 0.5;\n"
4160
" let f = function()\n"
4161
" {\n"
4162
" let H = g_ColorH[nHoverColorIndex];\n"
4163
" let S = g_ColorS[nHoverColorIndex];\n"
4164
" let L = g_ColorL[nHoverColorIndex];\n"
4165
" let offset = 0;\n"
4166
" if(S> 0.5)\n"
4167
" offset = 0.5 - S;\n"
4168
" let offsetL = 0;\n"
4169
" if(L > 0.75)\n"
4170
" offsetL = 0.75 - L;\n"
4171
" L = L + m4 + offsetL;\n"
4172
" L = L > 1 ? 1 : (L < 0 ? 0 : L);\n"
4173
" S = S + m2 + offset;\n"
4174
" S = S > 1 ? 1 : (S < 0 ? 0 : S);\n"
4175
" return ConvertHslToColor(H, S, L);\n"
4176
" };\n"
4177
" let ColorCV = f();\n"
4178
" ColorDark = Color = ColorCV; ;\n"
4179
" }\n"
4180
" }\n"
4181
" FillRects(a, Color, ColorDark);\n"
4182
" rect_calls += a.length;\n"
4183
"\n"
4184
" }\n"
4185
" }\n"
4186
" context.globalAlpha = 1.0;\n"
4187
" let BatchesTxt = BatchData.BatchesTxt;\n"
4188
" let BatchesTxtPos = BatchData.BatchesTxtPos;\n"
4189
" for(let i = 0; i < BatchesTxt.length; ++i)\n"
4190
" {\n"
4191
" context.fillStyle = BatchesTxtColor[i];\n"
4192
" let TxtArray = BatchesTxt[i];\n"
4193
" let PosArray = BatchesTxtPos[i];\n"
4194
" for(let j = 0; j < TxtArray.length; ++j)\n"
4195
" {\n"
4196
" let k = j * 2;\n"
4197
" context.fillText(TxtArray[j], PosArray[k],PosArray[k+1]);\n"
4198
"\n"
4199
" }\n"
4200
" text_calls += TxtArray.length;\n"
4201
" }\n"
4202
"\n"
4203
" }\n"
4204
" // console.log(\"rect_calls \", rect_calls, \" text_calls \", text_calls);\n"
4205
"\n"
4206
" }\n"
4207
"// console.log(\"Total Batches \", TotalBatches);\n"
4208
"\n"
4209
"}\n"
4210
"\n"
4211
"\n"
4212
"function DrawTextBox(context, text, x, y, align)\n"
4213
"{\n"
4214
" let textsize = context.measureText(text).width;\n"
4215
" let offsetx = 0;\n"
4216
" let offsety = -FontHeight;\n"
4217
" if(align == \'center\')\n"
4218
" {\n"
4219
" offsetx = -textsize / 2.0;\n"
4220
" }\n"
4221
" else if(align == \'right\')\n"
4222
" {\n"
4223
" offsetx = -textsize;\n"
4224
" }\n"
4225
" context.fillStyle = nBackColors[0];\n"
4226
" context.fillRect(x + offsetx, y + offsety, textsize+2, FontHeight + 2);\n"
4227
" context.fillStyle = \'white\';\n"
4228
" context.fillText(text, x, y);\n"
4229
"\n"
4230
"}\n"
4231
"\n"
4232
"function DrawFilterSearchRanges(context, Ranges, ColorBack, ColorFront, ThreadY)\n"
4233
"{\n"
4234
" if(0 == Ranges.length)\n"
4235
" return;\n"
4236
" //todo: arrow key support\n"
4237
" var MarginTop = 1.0 * FontHeight;\n"
4238
" var MarginBottom = nHeight - 1.0 * FontHeight;\n"
4239
"\n"
4240
"\n"
4241
" var Time = new Date();\n"
4242
" var Delta = Time - FilterSearchStartTime;\n"
4243
" var BlinkTime = 2.5 * 1000;\n"
4244
" var Blinks = 5;\n"
4245
" var HoverFloat = 0.2;\n"
4246
" var Blinking = 0;\n"
4247
" if(Delta < BlinkTime)\n"
4248
" {\n"
4249
" Blinking = 1;\n"
4250
" var b0 = Blinks* Math.PI * Delta;\n"
4251
" var b1 = b0 / BlinkTime;\n"
4252
" var Mag = Math.abs(Math.sin(b1));\n"
4253
" HoverFloat = ";
4254
4255
const size_t g_MicroProfileHtml_end_2_size = sizeof(g_MicroProfileHtml_end_2);
4256
const char g_MicroProfileHtml_end_3[] =
4257
"Mag * 0.5 + 0.2;\n"
4258
" }\n"
4259
" var Lines = new Array();\n"
4260
" var Rects = new Array();\n"
4261
"\n"
4262
"\n"
4263
" for(var i = 0; i < Ranges.length; ++i)\n"
4264
" {\n"
4265
" var Range = Ranges[i];\n"
4266
" let Off = Range.Second ? fDetailedOffsetSecond : 0\n"
4267
" var fBegin = Range.Begin - Off;\n"
4268
" var fEnd = Range.End - Off;\n"
4269
" var OffsetTop = Range.YBegin + ThreadY[Range.Thread];\n"
4270
" var OffsetBottom = OffsetTop + BoxHeight;\n"
4271
"\n"
4272
" if(fBegin < fEnd)\n"
4273
" {\n"
4274
" {\n"
4275
" OffsetTop = Math.max(OffsetTop, 0);\n"
4276
" OffsetBottom = Math.max(OffsetBottom, MarginTop);\n"
4277
" OffsetTop = Math.min(OffsetTop, MarginBottom);\n"
4278
" OffsetBottom = Math.min(OffsetBottom, nHeight);\n"
4279
" var fScaleX = nWidth / fDetailedRange;\n"
4280
" var X = (fBegin - fDetailedOffset) * fScaleX;\n"
4281
" var Y = OffsetTop;\n"
4282
" var W = (fEnd - fBegin) * fScaleX;\n"
4283
" if(W > 1)\n"
4284
" {\n"
4285
" Rects.push(X-3);\n"
4286
" Rects.push(OffsetTop-3);\n"
4287
" Rects.push(W+5);\n"
4288
" Rects.push(5 + OffsetBottom - OffsetTop);\n"
4289
" }\n"
4290
" else\n"
4291
" {\n"
4292
" X += W * 0.5;\n"
4293
" Lines.push(X);\n"
4294
" context.beginPath();\n"
4295
" context.moveTo(X, 0);\n"
4296
" context.lineTo(X, nHeight);\n"
4297
" context.stroke();\n"
4298
" }\n"
4299
" }\n"
4300
" }\n"
4301
" }\n"
4302
"\n"
4303
" context.fillStyle = ColorBack;\n"
4304
" context.strokeStyle = ColorBack;\n"
4305
"\n"
4306
" context.globalAlpha = HoverFloat;\n"
4307
"\n"
4308
" for(var i = 0; i < Rects.length;)\n"
4309
" {\n"
4310
" var X = Rects[i++];\n"
4311
" var Y = Rects[i++];\n"
4312
" var W = Rects[i++];\n"
4313
" var H = Rects[i++];\n"
4314
" context.fillRect(X, Y, W, H);\n"
4315
" }\n"
4316
" context.globalAlpha = 1;\n"
4317
" for(var i = 0; i < Rects.length;)\n"
4318
" {\n"
4319
" var X = Rects[i++];\n"
4320
" var Y = Rects[i++];\n"
4321
" var W = Rects[i++];\n"
4322
" var H = Rects[i++];\n"
4323
" context.strokeRect(X, Y, W, H);\n"
4324
" }\n"
4325
"\n"
4326
" for(var i = 0; i < Lines.length; ++i)\n"
4327
" {\n"
4328
" context.beginPath();\n"
4329
" context.moveTo(Lines[i], 0);\n"
4330
" context.lineTo(Lines[i], nHeight);\n"
4331
" context.stroke();\n"
4332
" }\n"
4333
" if(Blinking>0)\n"
4334
" {\n"
4335
" Invalidate = 1;\n"
4336
" }\n"
4337
"\n"
4338
"}\n"
4339
"\n"
4340
"\n"
4341
"function DrawRange(context, Range, ColorBack, ColorFront, Name, Offset)\n"
4342
"{\n"
4343
" if(!Offset)\n"
4344
" Offset = 0;\n"
4345
"\n"
4346
" let XOffset = Range.Second ? fDetailedOffsetSecond : 0;\n"
4347
" let fBegin = Range.Begin - XOffset;\n"
4348
" let fEnd = Range.End - XOffset;\n"
4349
" let OffsetTop = Range.YBegin;\n"
4350
" let OffsetBottom = Range.YEnd;\n"
4351
" let Off = Range.Off + fDetailedOffset;\n"
4352
" if(fBegin < fEnd)\n"
4353
" {\n"
4354
" let MarginTop = (1.0+Offset) * (FontHeight+1);\n"
4355
" let MarginBottom = nHeight - (Offset+1.5) * (FontHeight+1);\n"
4356
" if(OffsetTop < MarginTop)\n"
4357
" {\n"
4358
" Offset += 1;\n"
4359
" OffsetTop = MarginTop;\n"
4360
" }\n"
4361
" if(OffsetBottom > MarginBottom)\n"
4362
" {\n"
4363
" OffsetBottom = MarginBottom;\n"
4364
" }\n"
4365
" let fRulerOffset = FontHeight * 0.5;\n"
4366
" let fScaleX = nWidth / fDetailedRange;\n"
4367
" let X = (fBegin - Off) * fScaleX;\n"
4368
" let YSpace = (FontHeight+2);\n"
4369
" let Y = OffsetTop;\n"
4370
" let YBottom = OffsetBottom;\n"
4371
" let W = (fEnd - fBegin) * fScaleX;\n"
4372
" context.globalAlpha = 0.1;\n"
4373
" context.fillStyle = ColorBack;\n"
4374
" context.fillRect(X, OffsetTop + fRulerOffset, W, OffsetBottom - OffsetTop);\n"
4375
" context.globalAlpha = 1;\n"
4376
" context.strokeStyle = ColorFront;\n"
4377
" context.beginPath();\n"
4378
" context.moveTo(X, 0);\n"
4379
" context.lineTo(X, nHeight);\n"
4380
" context.moveTo(X+W, 0);\n"
4381
" context.lineTo(X+W, nHeight);\n"
4382
" context.stroke();\n"
4383
" let Duration = (fEnd - fBegin).toFixed(2) + \"ms\";\n"
4384
" let Center = ((fBegin + fEnd) / 2.0) - Off;\n"
4385
" let DurationWidth = context.measureText(Duration+ \" \").width;\n"
4386
"\n"
4387
" context.fillStyle = \'white\';\n"
4388
" context.textAlign = \'right\';\n"
4389
" let TextPosY = Y + YSpace;\n"
4390
" DrawTextBox(context, (fBegin-Range.Off).toFixed(2), X-3, TextPosY, \'right\');\n"
4391
" let YS = [Y, YBottom];\n"
4392
" for(let i = 0; i < YS.length; ++i)\n"
4393
" {\n"
4394
" let Y = YS[i];\n"
4395
" let Y0 = Y + fRulerOffset;\n"
4396
" let W0 = W - DurationWidth + FontWidth*1.5;\n"
4397
" if(W0 > 6)\n"
4398
" {\n"
4399
" context.textAlign = \'center\';\n"
4400
" DrawTextBox(context, Duration,Center * fScaleX, Y + YSpace, \'center\');\n"
4401
" W0 = W0 / 2.0;\n"
4402
" let X0 = X + W0;\n"
4403
" let X1 = X + W - W0;\n"
4404
" context.strokeStyle = ColorFront;\n"
4405
" context.beginPath();\n"
4406
" context.moveTo(X, Y0);\n"
4407
" context.lineTo(X0, Y0);\n"
4408
" context.moveTo(X0, Y0-2);\n"
4409
" context.lineTo(X0, Y0+2);\n"
4410
" context.moveTo(X1, Y0-2);\n"
4411
" context.lineTo(X1, Y0+2);\n"
4412
" context.moveTo(X1, Y0);\n"
4413
" context.lineTo(X + W, Y0);\n"
4414
" context.stroke();\n"
4415
" }\n"
4416
" else\n"
4417
" {\n"
4418
" if(i == 1)\n"
4419
" {\n"
4420
" context.textAlign = \'right\';\n"
4421
" DrawTextBox(context, Duration, X - 3, Y0, \'right\');\n"
4422
" context.textAlign = \'left\';\n"
4423
" DrawTextBox(context, Duration, X + W + 2, Y0, \'left\');\n"
4424
" }\n"
4425
" context.strokeStyle = ColorFront;\n"
4426
" context.beginPath();\n"
4427
" context.moveTo(X, Y0);\n"
4428
" context.lineTo(X+W, Y0);\n"
4429
" context.stroke();\n"
4430
" }\n"
4431
" }\n"
4432
" context.textAlign = \'left\';\n"
4433
" DrawTextBox(context, (fEnd-Range.Off).toFixed(2), X + W + 2, TextPosY, \'left\');\n"
4434
" DrawTextBox(context, Name, X + W + 2, OffsetTop + YSpace + FontHeight, \'left\');\n"
4435
" }\n"
4436
" return Offset;\n"
4437
"}\n"
4438
"function DetailedAddMouseEvent(P, E)\n"
4439
"{\n"
4440
" if(!DetailedMouseEvent)\n"
4441
" {\n"
4442
" DetailedMouseEvent = {\"P\":P, \"E\":E};\n"
4443
" }\n"
4444
" else if(DetailedMouseEvent.P < P)\n"
4445
" {\n"
4446
" DetailedMouseEvent.P = P;\n"
4447
" DetailedMouseEvent.E = E;\n"
4448
" }\n"
4449
"\n"
4450
"}\n"
4451
"\n"
4452
"function CreateGraphData(Samples, Name, Color)\n"
4453
"{\n"
4454
" let gd = {};\n"
4455
" gd.Samples = Samples;\n"
4456
" gd.Name = Name;\n"
4457
" gd.Color = Color;\n"
4458
" return gd;\n"
4459
"}\n"
4460
"\n"
4461
"function CreateDrawGraphParameters()\n"
4462
"{\n"
4463
" let P = {};\n"
4464
" P.Rect = WindowRect(0, 0, 1, 1);\n"
4465
" P.RangeMin = 0.0;\n"
4466
" P.RangeMax = 0.0;\n"
4467
" P.Mark = [16.66, 33.33];\n"
4468
" P.Ext = \"ms\";\n"
4469
" P.Border = 2;\n"
4470
" P.Frame = 1;\n"
4471
" return P;\n"
4472
"}\n"
4473
"\n"
4474
"\n"
4475
"\n"
4476
"function DrawGraph(context, Parameters, data, Mouse)\n"
4477
"{\n"
4478
"\n"
4479
" ProfileEnter(\"DrawGraph\");\n"
4480
" let Rect = Parameters.Rect;\n"
4481
" let RangeMin = Parameters.RangeMin;\n"
4482
" let RangeMax = Parameters.RangeMax;\n"
4483
" let MaxLen = 0;\n"
4484
" let MaxSample = 0;\n"
4485
" let MinSample = 1e25;\n"
4486
" for(let i in data)\n"
4487
" {\n"
4488
" let d = data[i];\n"
4489
" MaxLen = Math.max(MaxLen, d.Samples.length);\n"
4490
" for(let j in d.Samples)\n"
4491
" {\n"
4492
" MaxSample = Math.max(MaxSample, d.Samples[j]);\n"
4493
" MinSample = Math.max(MinSample, d.Samples[j]);\n"
4494
" }\n"
4495
" }\n"
4496
" if(0 == MaxLen)\n"
4497
" return;\n"
4498
"\n"
4499
" if(RangeMax <= RangeMin)\n"
4500
" {\n"
4501
" RangeMin = MinSample;\n"
4502
" RangeMax = MaxSample;\n"
4503
" }\n"
4504
"\n"
4505
"\n"
4506
" let Ext = Parameters.Ext;\n"
4507
" let Border = Parameters.Border;\n"
4508
" let Frame = Parameters.Frame;\n"
4509
" if(Frame)\n"
4510
" Border += 10;\n"
4511
"\n"
4512
" let wx = Rect.x;\n"
4513
" let wy = Rect.y;\n"
4514
" let wh = Rect.h;\n"
4515
" let ww = Rect.w;\n"
4516
"\n"
4517
" let x = Rect.x + Border;\n"
4518
" let y = Rect.y + Border;\n"
4519
" let h = Rect.h - 2*Border;\n"
4520
" let w = Rect.w - 2*Border;\n"
4521
"\n"
4522
" let MouseX = Mouse.X-x;\n"
4523
" let MouseY = Mouse.Y-y;\n"
4524
" let MouseInside = Mouse.X >= x && Mouse.Y >= y && Mouse.X < x + w && Mouse.Y < y + h;\n"
4525
" let MouseXPrc = (Mouse.X - x) / (w-1);\n"
4526
"\n"
4527
" context.clearRect(wx, wy, ww, wh);\n"
4528
"\n"
4529
"\n"
4530
" let SampleWidth = w / (MaxLen-1);\n"
4531
" let MouseIndex = Math.max(0, Math.min(MaxLen-1, Math.floor(MouseXPrc * MaxLen)));\n"
4532
"\n"
4533
" let HeightScale = h / (RangeMax-RangeMin);\n"
4534
" let Y = y + h;\n"
4535
" let YStart = Y;\n"
4536
"\n"
4537
" for(let dataindex in data)\n"
4538
" {\n"
4539
" let LocalElement = data[dataindex];\n"
4540
" let Samples = LocalElement.Samples;\n"
4541
" let X = x + w - (Samples.length-1)*SampleWidth;\n"
4542
" Y = y + h;\n"
4543
"\n"
4544
" context.globalAlpha = 1;\n"
4545
" context.strokeStyle = LocalElement.Color;\n"
4546
" context.fillStyle = LocalElement.Color;\n"
4547
" context.beginPath();\n"
4548
" for(let i = 0; i < Samples.length; ++i)\n"
4549
" {\n"
4550
" Y = Math.max(YStart - Samples[i] * HeightScale, y);\n"
4551
" if(i == 0)\n"
4552
" context.moveTo(X, Y);\n"
4553
" else\n"
4554
" context.lineTo(X, Y);\n"
4555
" X += SampleWidth;\n"
4556
"\n"
4557
" }\n"
4558
" let GRAPH_ALPHA = 0.2;\n"
4559
" context.stroke();\n"
4560
" context.lineTo(X-SampleWidth, YStart);\n"
4561
" context.lineTo(x, YStart);\n"
4562
" context.globalAlpha = GRAPH_ALPHA;\n"
4563
" context.fill();\n"
4564
"\n"
4565
" if(MouseInside)\n"
4566
" {\n"
4567
" let MouseSample = Samples[MouseIndex];\n"
4568
" let Y = Math.max(YStart - MouseSample * HeightScale, y);\n"
4569
" let X = x + w + (MouseIndex - (Samples.length-1))*SampleWidth;\n"
4570
"\n"
4571
" context.globalAlpha = 0.8;\n"
4572
" context.beginPath();\n"
4573
" context.arc(X, Y, 2, 0, 2 * Math.PI);\n"
4574
" context.fill();\n"
4575
"\n"
4576
" context.globalAlpha = 1;\n"
4577
"\n"
4578
" context.beginPath();\n"
4579
" context.arc(X, Y, 3, 0, 2 * Math.PI);\n"
4580
" context.stroke();\n"
4581
" }\n"
4582
"\n"
4583
"\n"
4584
" }\n"
4585
" context.globalAlpha = 1;\n"
4586
" context.fillStyle = \'wheat\';\n"
4587
" context.strokeStyle = \'wheat\';\n"
4588
" context.textAlign=\'right\';\n"
4589
" context.fillText(RangeMax + Ext, x+w, y + FontHeight);\n"
4590
" for(let m in Parameters.Mark)\n"
4591
" {\n"
4592
" let Sample = Parameters.Mark[m];\n"
4593
" let Y = YStart - Sample * HeightScale;\n"
4594
" context.fillText(Sample + Ext, x+w, Y + FontHeight);\n"
4595
" }\n"
4596
"\n"
4597
"\n"
4598
" context.globalAlpha = 0.4;\n"
4599
" for(let m in Parameters.Mark)\n"
4600
" {\n"
4601
" let Sample = Parameters.Mark[m];\n"
4602
" let Y = YStart - Sample * HeightScale;\n"
4603
" {\n"
4604
" context.beginPath();\n"
4605
" context.moveTo(x-(Frame?5:0), Y);\n"
4606
" context.lineTo(x+w, Y);\n"
4607
" context.stroke();\n"
4608
" }\n"
4609
" }\n"
4610
" context.globalAlpha = 1;\n"
4611
" if(Frame)\n"
4612
" {\n"
4613
" context.beginPath();\n"
4614
" context.moveTo(x-5, YStart);\n"
4615
" context.lineTo(x+w+5, YStart);\n"
4616
" context.stroke();\n"
4617
"\n"
4618
" context.beginPath();\n"
4619
" context.moveTo(x, YStart+5);\n"
4620
" context.lineTo(x, YStart-h-5);\n"
4621
" context.stroke();\n"
4622
"\n"
4623
" context.beginPath();\n"
4624
" context.moveTo(x, YStart-h);\n"
4625
" context.lineTo(x-5, YStart-h);\n"
4626
" context.stroke();\n"
4627
" }\n"
4628
"\n"
4629
" for(let dataindex = 0; dataindex < data.length; ++dataindex)\n"
4630
" {\n"
4631
" let LocalElement = data[dataindex];\n"
4632
" context.textAlign=\'left\';\n"
4633
" context.strokeStyle = LocalElement.Color;\n"
4634
" context.fillStyle = LocalElement.Color;\n"
4635
" context.fillText(LocalElement.Name, x+2, y + FontHeight * (dataindex+1));\n"
4636
" }\n"
4637
"\n"
4638
" if(MouseInside)\n"
4639
" {\n"
4640
" ToolTipImmediate = new Array();\n"
4641
" for(let dataindex in data)\n"
4642
" {\n"
4643
" let LocalElement = data[dataindex];\n"
4644
" let Samples = LocalElement.Samples;\n"
4645
" ToolTipImmediate.push(LocalElement.Name);\n"
4646
" ToolTipImmediate.push(FormatTime(Samples[MouseIndex])+ Parameters.Ext);\n"
4647
" }\n"
4648
" }\n"
4649
"\n"
4650
" ProfileLeave();\n"
4651
"}\n"
4652
"\n"
4653
"function DrawDetailed(Animation)\n"
4654
"{\n"
4655
" DetailedMouseEvent = null;\n"
4656
"\n"
4657
" if(!Initialized)\n"
4658
" {\n"
4659
" return;\n"
4660
" }\n"
4661
" ProfileEnter(\"DrawDetailed\");\n"
4662
" DetailedMouseOverButton = false;\n"
4663
"\n"
4664
" DebugDrawQuadCount = 0;\n"
4665
" DebugDrawTextCount = 0;\n"
4666
" nHoverCSCpuNext = -1;\n"
4667
"\n"
4668
" RangeCpuNext = RangeInit();\n"
4669
" RangeGpuNext = RangeInit();\n"
4670
"\n"
4671
" var start = new Date();\n"
4672
" nDrawCount++;\n"
4673
"\n"
4674
" var context = CanvasDetailedView.getContext(\'2d\');\n"
4675
" var offscreen = CanvasDetailedOffscreen.getContext(\'2d\');\n"
4676
" var fScaleX = nWidth / fDetailedRange;\n"
4677
" var fOffsetY = -nOffsetY + BoxHeight;\n"
4678
" if(DetailedRedrawState.fOffsetY == fOffsetY && DetailedRedrawState.fDetailedOffset == fDetailedOffset && DetailedRedrawState.fDetailedRange == fDetailedRange && !KeyCtrlDown && !KeyShiftDown && !KeyAltDown && !MouseDragButton && !RedrawRequested)\n"
4679
" {\n"
4680
" Invalidate++;\n"
4681
" }\n"
4682
" else\n"
4683
" {\n"
4684
" Invalidate = 0;\n"
4685
" DetailedRedrawState.fOffsetY = fOffsetY;\n"
4686
" DetailedRedrawState.fDetailedOffset = fDetailedOffset;\n"
4687
" DetailedRedrawState.fDetailedRange = fDetailedRange;\n"
4688
" }\n"
4689
" if(nHoverTokenDrawn != nHoverToken)\n"
4690
" {\n"
4691
" Invalidate = 1;\n"
4692
" }\n"
4693
" nHoverTokenDrawn = nHoverToken;\n"
4694
" nHoverTokenNext = -1;\n"
4695
" HoverTokenNextOwner = null;\n"
4696
" nHoverTokenLogIndexNext = -1;\n"
4697
" nHoverTokenIndexNext = -1;\n"
4698
"\n"
4699
"\n"
4700
"\n"
4701
" if(DrawDetailedNewDraw || Invalidate == 0) //when panning, only draw bars that are a certain width to keep decent framerate\n"
4702
" {\n"
4703
" context.clearRect(0, 0, CanvasDetailedView.width, CanvasDetailedView.height);\n"
4704
" DrawDetailedView(S, S, context, nMinWidthPan, true);\n"
4705
" DrawDetailedView(S2, S, context, nMinWidthPan, true, 1);\n"
4706
" ProfileRedraw0++;\n"
4707
" }\n"
4708
" else if(Invalidate == 1) //draw full and store\n"
4709
" {\n"
4710
" offscreen.clearRect(0, 0, CanvasDetailedView.width, CanvasDetailedView.height);\n"
4711
" DrawDetailedView(S, S, offscreen, nMinWidth, true);\n"
4712
" DrawDetailedView(S2, S, offscreen, nMinWidth, true, 1);\n"
4713
" OffscreenData = offscreen.getImageData(0, 0, CanvasDetailedOffscreen.width, CanvasDetailedOffscreen.height);\n"
4714
" ProfileRedraw1++;\n"
4715
" }\n"
4716
" else//reuse stored result untill next time viewport is changed.\n"
4717
" {\n"
4718
" context.clearRect(0, 0, CanvasDetailedView.width, CanvasDetailedView.height);\n"
4719
" context.putImageData(OffscreenData, 0, 0);\n"
4720
" DrawDetailedView(S, S, context, nMinWidth, false);\n"
4721
" DrawDetailedView(S2, S, context, nMinWidth, false, 1);\n"
4722
" ProfileRedraw2++;\n"
4723
" }\n"
4724
"\n"
4725
" if(KeyShiftDown || KeyCtrlDown || MouseDragSelectRange() || ZoomActive || FilterSearchActive)\n"
4726
" {\n"
4727
" nHoverToken = -1;\n"
4728
" nHoverTokenIndex = -1;\n"
4729
" nHoverTokenLogIndex = -1;\n"
4730
" HoverTokenOwner = null;\n"
4731
" RangeCpu = RangeInit();\n"
4732
" RangeGpu = RangeInit();\n"
4733
" }\n"
4734
" else\n"
4735
" {\n"
4736
" nHoverToken = nHoverTokenNext;\n"
4737
" HoverTokenOwner = HoverTokenNextOwner;\n"
4738
" nHoverTokenIndex = nHoverTokenIndexNext;\n"
4739
" nHoverTokenLogIndex = nHoverTokenLogIndexNext;\n"
4740
" if(RangeValid(RangeCpuHistory))\n"
4741
" {\n"
4742
" RangeCopy(RangeCpu, RangeCpuHistory);\n"
4743
" RangeCopy(RangeGpu, RangeGpuHistory);\n"
4744
" }\n"
4745
" else\n"
4746
" {\n"
4747
" RangeCopy(RangeCpu, RangeCpuNext);\n"
4748
" RangeCopy(RangeGpu, RangeGpuNext);\n"
4749
" }\n"
4750
" }\n"
4751
"\n"
4752
" DrawTextBox(context, TimeToMsString(fDetailedOffset), 0, FontHeight, \'left\');\n"
4753
" context.textAlign = \'right\';\n"
4754
" DrawTextBox(context, TimeToMsString(fDetailedOffset + fDetailedRange), nWidth, FontHeight, \'right\');\n"
4755
" context.textAlign = \'left\';\n"
4756
"\n"
4757
" if(!FilterSearchActive && !IgnoreInput && SubMenuActive == -1)\n"
4758
" {\n"
4759
" let Colors = GroupColors == 3 ? \"Color[Section]\" : (GroupColors == 2 ? \"Color[thread]\" : (GroupColors ? \"Color[group]\" : \"Color[timer]\"));\n"
4760
" DrawDetailedButtons(context, nWidth * 0.5, 0, [Colors],[function(){ToggleGroupColors(1);}], \"center\");\n"
4761
" }\n"
4762
"\n"
4763
"\n"
4764
" var YBegin = ThreadYBegin[fRangeThreadIdNext];\n"
4765
" var YEnd = ThreadYEnd[fRangeThreadIdNext];\n"
4766
" var YBeginGpu = YBegin;\n"
4767
" var YEndGpu = YEnd;\n"
4768
" function RangeSet(R)\n"
4769
" {\n"
4770
" if(R.Thread >= 0)\n"
4771
" {\n"
4772
" R.YBegin = ThreadYBegin[R.Thread];\n"
4773
" R.YEnd = ThreadYEnd[R.Thread];\n"
4774
" }\n"
4775
" else\n"
4776
" {\n"
4777
" R.YBegin = 0;\n"
4778
" R.YEnd = nHeight;\n"
4779
" }\n"
4780
" }\n"
4781
" RangeSet(RangeSelect);\n"
4782
" RangeSet(RangeCpu);\n"
4783
" RangeSet(RangeGpu);\n"
4784
" var Offset = 0;\n"
4785
" Offset = DrawRange(context, RangeSelect, \'#59d0ff\', \'#00ddff\', \"Selection\", Offset);\n"
4786
" Offset = DrawRange(context, RangeCpu, \'#009900\', \'#00ff00\', \"Cpu\", Offset);\n"
4787
" Offset = DrawRange(context, RangeGpu, \'#996600\', \'#775500\', \"Gpu\", Offset);\n"
4788
"\n"
4789
" DrawFilterSearchRanges(context, FilterSearchArray, \'#ff9900\', \'#ff9900\', ThreadYBegin);\n"
4790
"\n"
4791
" nHoverCSCpu = nHoverCSCpuNext;\n"
4792
"\n"
4793
" DrawFilterSearch();\n"
4794
"\n"
4795
" ProfileDrawFrameTimeGraph(context);\n"
4796
"\n"
4797
" ProfileLeave();\n"
4798
"}\n"
4799
"function ZoomToHighlight(NoGpu)\n"
4800
"{\n"
4801
" if(RangeValid(RangeGpu) && !NoGpu)\n"
4802
" {\n"
4803
" ZoomToRange(RangeGpu);\n"
4804
" }\n"
4805
" else if(RangeValid(RangeCpu))\n"
4806
" {\n"
4807
" ZoomToRange(RangeCpu);\n"
4808
" }\n"
4809
" RangeCpu = RangeInit();\n"
4810
" RangeGpu = RangeInit();\n"
4811
"}\n"
4812
"\n"
4813
"function MoveToNext(Direction) //1 forward, -1 backwards\n"
4814
"{\n"
4815
" let fTimeBegin, fTimeEnd, nLog;\n"
4816
" let Index = nHoverToken;\n"
4817
" let Source = S;\n"
4818
" let Offset = 0;\n"
4819
" if(RangeValid(RangeSelect))\n"
4820
" {\n"
4821
" fTimeBegin = RangeSelect.Begin;\n"
4822
" fTimeEnd = RangeSelect.End;\n"
4823
" nLog = RangeSelect.Thread;\n"
4824
" Index = RangeSelect.Index;\n"
4825
" if(RangeSelect.Second)\n"
4826
" {\n"
4827
" Source = S2;\n"
4828
" Offset = -fDetailedOffsetSecond;\n"
4829
" }\n"
4830
" }\n"
4831
" else if(nHoverToken != -1 && nHoverTokenLogIndex != -1)\n"
4832
" {\n"
4833
" fTimeBegin = RangeCpu.Begin;\n"
4834
" fTimeEnd = RangeCpu.End;\n"
4835
" nLog = nHoverTokenLogIndex;\n"
4836
" }\n"
4837
" else\n"
4838
" {\n"
4839
" return;\n"
4840
" }\n"
4841
" if(nLog<0)\n"
4842
" {\n"
4843
" return;\n"
4844
" }\n"
4845
" let Forward = Direction && Direction < 0 ? 0 : 1;\n"
4846
" let bFound = false;\n"
4847
" let nStackPos = 0;\n"
4848
" let fResultTimeBegin, fResultTimeEnd;\n"
4849
" let TypeBegin = Forward ? 1 : 0;\n"
4850
" let TypeEnd = Forward ? 0 : 1;\n"
4851
" let SearchTimeBegin = Forward ? fTimeBegin : fTimeEnd;\n"
4852
"\n"
4853
" let istart = Forward ? 0 : Source.Frames.length-1;\n"
4854
" let iend = Forward ? Source.Frames.length : -1;\n"
4855
" let idelta = Forward ? 1 : -1;\n"
4856
" for(let i = istart; i != iend; i += idelta)\n"
4857
" {\n"
4858
" let fr = Source.Frames[i];\n"
4859
" let ts = fr.ts[nLog];\n"
4860
" let ti = fr.ti[nLog];\n"
4861
" let tt = fr.tt[nLog];\n"
4862
" let jstart = Forward ? 0 : ts.length-1;\n"
4863
" let jend = Forward ? ts.length : -1;\n"
4864
" let jdelta = Forward ? 1 : -1;\n"
4865
" for(let j = jstart; j != jend; j += jdelta)\n"
4866
" {\n"
4867
" if(!bFound)\n"
4868
" {\n"
4869
" if(tt[j] == TypeBegin && Index == ti[j])\n"
4870
" {\n"
4871
" if(SearchTimeBegin == ts[j])\n"
4872
" {\n"
4873
" bFound = true;\n"
4874
" }\n"
4875
" }\n"
4876
" }\n"
4877
" else\n"
4878
" {\n"
4879
" if(Index == ti[j])\n"
4880
" {\n"
4881
" let type = tt[j];\n"
4882
" if(type == TypeBegin)\n"
4883
" {\n"
4884
" if(0 == nStackPos)\n"
4885
" {\n"
4886
" fResultTimeBegin = ts[j];\n"
4887
" }\n"
4888
" nStackPos++;\n"
4889
" }\n"
4890
" else if(type == TypeEnd && nStackPos)\n"
4891
" {\n"
4892
" nStackPos--;\n"
4893
" if(0 == nStackPos)\n"
4894
" {\n"
4895
" fResultTimeEnd = ts[j];\n"
4896
" if(0 == Forward)\n"
4897
" {\n"
4898
" let Tmp = fResultTimeBegin;\n"
4899
" fResultTimeBegin = fResultTimeEnd;\n"
4900
" fResultTimeEnd = Tmp;\n"
4901
" }\n"
4902
" RangeSelect.Begin = fResultTimeBegin;\n"
4903
" RangeSelect.End = fResultTimeEnd;\n"
4904
" RangeSelect.Thread = nLog;\n"
4905
" RangeSelect.Index = Index;\n"
4906
" MoveTo(fResultTimeBegin + Offset,fResultTimeEnd + Offset);\n"
4907
" return;\n"
4908
" }\n"
4909
" }\n"
4910
" }\n"
4911
" }\n"
4912
" }\n"
4913
" }\n"
4914
"}\n"
4915
"\n"
4916
"\n"
4917
"function MoveTo(fMoveBegin, fMoveEnd, YTop, YBottom)\n"
4918
"{\n"
4919
" var nOffsetYBottom = YBottom - nHeight;\n"
4920
" var nOffsetYDest = nOffsetY;\n"
4921
" if(nOffsetYDest < nOffsetYBottom)\n"
4922
" {\n"
4923
" nOffsetYDest = nOffsetYBottom;\n"
4924
" }\n"
4925
" if(nOffsetYDest > YTop)\n"
4926
" {\n"
4927
" nOffsetYDest = YTop;\n"
4928
" }\n"
4929
" var fRange = fDetailedRange;\n"
4930
" var fMinRange = (fMoveEnd-fMoveBegin) * 2.0;\n"
4931
" if(fRange < fMinRange)\n"
4932
" {\n"
4933
" fRange = fMinRange;\n"
4934
" }\n"
4935
" var fMoveCenter = (fMoveBegin + fMoveEnd) * 0.5;\n"
4936
" fMoveBegin = fMoveCenter - 0.5 * fRange;\n"
4937
" fMoveEnd = fMoveCenter + 0.5 * fRange;\n"
4938
" var nOffset;\n"
4939
" if(nOffsetYDest != nOffsetY)\n"
4940
" nOffset = nOffsetYDest;\n"
4941
" ZoomTo(fMoveBegin, fMoveEnd, nOffsetYDest, -1);\n"
4942
"}\n"
4943
"\n"
4944
"function ZoomToRange(R)\n"
4945
"{\n"
4946
" ZoomTo(R.Begin, R.End, 0, 0, R.Off);\n"
4947
"}\n"
4948
"\n"
4949
"let ZoomCallback = null;\n"
4950
"\n"
4951
"function ZoomTo(fZoomBegin, fZoomEnd, OffsetYDest, ZoomTime, fOffset)\n"
4952
"{\n"
4953
" if(fZoomBegin < fZoomEnd)\n"
4954
" {\n"
4955
" if(fOffset)\n"
4956
" {\n"
4957
" fZoomBegin -= fOffset;\n"
4958
" fZoomEnd -= fOffset;\n"
4959
" }\n"
4960
" AnimationActive = true;\n"
4961
" var fDetailedOffsetOriginal = fDetailedOffset;\n"
4962
" var fDetailedRangeOriginal = fDetailedRange;\n"
4963
" var fDetailedOffsetTarget = fZoomBegin;\n"
4964
" var fDetailedRangeTarget = fZoomEnd - fZoomBegin;\n"
4965
" var OffsetYOriginal = nOffsetY;\n"
4966
" var OffsetYTarget = OffsetYDest;\n"
4967
" var TimestampStart = new Date();\n"
4968
" var count = 0;\n"
4969
" if(!ZoomTime)\n"
4970
" {\n"
4971
" ZoomTime = ZOOM_TIME;\n"
4972
" }\n"
4973
"\n"
4974
" function ZoomFunc()\n"
4975
" {\n"
4976
" ZoomActive = 1;\n"
4977
" var fPrc = (new Date() - TimestampStart) / (ZoomTime * 1000.0);\n"
4978
" if(fPrc > 1.0 || ZoomTime < 0.01)\n"
4979
" {\n"
4980
" fPrc = 1.0;\n"
4981
" }\n"
4982
" fPrc = Math.pow(fPrc, 0.3);\n"
4983
" fDetailedOffset = fDetailedOffsetOriginal + (fDetailedOffsetTarget - fDetailedOffsetOriginal) * fPrc;\n"
4984
" fDetailedRange = fDetailedRangeOriginal + (fDetailedRangeTarget - fDetailedRangeOriginal) * fPrc;\n"
4985
" if(OffsetYDest)\n"
4986
" {\n"
4987
" nOffsetY = OffsetYOriginal + (OffsetYTarget - OffsetYOriginal) * fPrc;\n"
4988
" }\n"
4989
" if(fPrc >= 1.0)\n"
4990
" {\n"
4991
" AnimationActive = false;\n"
4992
" fDetailedOffset = fDetailedOffsetTarget;\n"
4993
" fDetailedRange = fDetailedRangeTarget;\n"
4994
" if(OffsetYDest)\n"
4995
" {\n"
4996
" nOffsetY = OffsetYTarget;\n"
4997
" }\n"
4998
" ZoomCallback = null;\n"
4999
" }\n"
5000
" else\n"
5001
" {\n"
5002
" RequestRedraw();\n"
5003
" }\n"
5004
" return 1;\n"
5005
" }\n"
5006
" ZoomCallback = ZoomFunc;\n"
5007
" RequestRedraw();\n"
5008
" }\n"
5009
"}\n"
5010
"\n"
5011
"function RequestAnimationFrame(cb)\n"
5012
"{\n"
5013
" if(!RedrawRequested)\n"
5014
" {\n"
5015
" let RedrawCallback = function(foo)\n"
5016
" {\n"
5017
" RedrawRequested = 0;\n"
5018
" cb(foo);\n"
5019
" };\n"
5020
" RedrawRequested = 1;\n"
5021
" requestAnimationFrame(RedrawCallback);\n"
5022
" }\n"
5023
"}\n"
5024
"\n"
5025
"function RequestRedraw(FullRedraw)\n"
5026
"{\n"
5027
" if(!RedrawRequested)\n"
5028
" {\n"
5029
" RequestAnimationFrame(Draw);\n"
5030
" }\n"
5031
"}\n"
5032
"\n"
5033
"function UpdateFilterSearch()\n"
5034
"{\n"
5035
" let Value = FilterInputSearch2.value;\n"
5036
" if(Value != FilterInputSearchValue)\n"
5037
" {\n"
5038
" FilterInputSearchValue = Value;\n"
5039
" let FilterSearch = CreateFilter(FilterInputSearchValue);\n"
5040
" if(!FilterSearch)\n"
5041
" {\n"
5042
" FilterInputSearchActive2 = false;\n"
5043
" }\n"
5044
" else\n"
5045
" {\n"
5046
" FilterInputSearchActive2 = true;\n"
5047
" let States = new Array();\n"
5048
" States.push(S);\n"
5049
" if(S2 && S2.TimerInfo)\n"
5050
" States.push(S2);\n"
5051
" for(let i in States)\n"
5052
" {\n"
5053
" let State = States[i];\n"
5054
" for(let j in State.TimerInfo)\n"
5055
" {\n"
5056
" let TI = State.TimerInfo[j];\n"
5057
" let Name = TI.name;\n"
5058
" if(FilterMatch(FilterSearch, Name))\n"
5059
" {\n"
5060
" TI.search = CIDMatch;\n"
5061
" }\n"
5062
" else\n"
5063
" {\n"
5064
" TI.search = CIDFail;\n"
5065
" }\n"
5066
" }\n"
5067
" }\n"
5068
" for(let i = 0; i < Timeline.Names.length; ++i)\n"
5069
" {\n"
5070
" Timeline.SearchMatch[i] = FilterMatch(FilterSearch, Timeline.Names[i]);\n"
5071
" }\n"
5072
" }\n"
5073
" }\n"
5074
"}\n"
5075
"\n"
5076
"\n"
5077
"function Draw()\n"
5078
"{\n"
5079
" let ProfileDrawStart = new Date();\n"
5080
"\n"
5081
" UpdateFilterSearch();\n"
5082
" let RedrawMode = 1;\n"
5083
" let RedrawAgain = 0;\n"
5084
" RedrawMode = 1;\n"
5085
" if(Mode == ModeDetailed)\n"
5086
" {\n"
5087
" if(ProfileMode == 2 || ((nHoverCSCpu >= 0 || nHoverToken != -1) && !KeyCtrlDown && !KeyShiftDown && !MouseDragButton)||(Invalidate<2 && !KeyCtrlDown && !KeyShiftDown && !MouseDragButton))\n"
5088
" {\n"
5089
" RedrawMode = 1;\n"
5090
" RedrawAgain = 1;\n"
5091
" }\n"
5092
" }\n"
5093
" else\n"
5094
" {\n"
5095
" if(Invalidate < 1)\n"
5096
" {\n"
5097
" RedrawMode = 1;\n"
5098
" }\n"
5099
" }\n"
5100
"\n"
5101
" if(!Initialized)\n"
5102
" {\n"
5103
" return;\n"
5104
" }\n"
5105
" if(InsideDraw)\n"
5106
" {\n"
5107
" debugger;\n"
5108
" return;\n"
5109
" }\n"
5110
" let ZoomActive = 0;\n"
5111
" if(ZoomCallback)\n"
5112
" {\n"
5113
" ZoomActive = ZoomCallback();\n"
5114
" }\n"
5115
" InsideDraw = 1;\n"
5116
" if(ProfileMode)\n"
5117
" {\n"
5118
" ProfileModeClear();\n"
5119
" ProfileEnter(\"Total\");\n"
5120
" }\n"
5121
"\n"
5122
" if(ZoomActive)\n"
5123
" {\n"
5124
" DrawDetailed(true);\n"
5125
" }\n"
5126
" else if(RedrawMode == 1)\n"
5127
" {\n"
5128
" if(Mode == ModeTimers || Mode == ModeTimers_Threads || Mode == ModeTimers_Groups)\n"
5129
" {\n"
5130
" DrawBarView();\n"
5131
" DrawHoverToolTip();\n"
5132
" }\n"
5133
" else if(Mode == ModeDetailed)\n"
5134
" {\n"
5135
" DrawDetailed(false);\n"
5136
" DrawHoverToolTip();\n"
5137
" }\n"
5138
" else if(Mode == ModeCounters)\n"
5139
" {\n"
5140
" DrawCounterView();\n"
5141
" DrawHoverToolTip();\n"
5142
" }\n"
5143
" }\n"
5144
" DrawDetailedFrameHistory();\n"
5145
" DrawMenu();\n"
5146
"\n"
5147
"\n"
5148
" if(ProfileMode)\n"
5149
" {\n"
5150
" ProfileLeave();\n"
5151
" ProfileModeDraw(CanvasDetailedView);\n"
5152
" }\n"
5153
"\n"
5154
" InsideDraw = 0;\n"
5155
" {\n"
5156
" let ProfileDrawEnd = new Date();\n"
5157
" let DrawTime = ProfileDrawEnd - ProfileDrawStart;\n"
5158
" let Delta = ProfileDrawStart - ProfileDrawStartLast;\n"
5159
" let Draw2Draw = ProfileDrawStart - ProfileDrawEndLast;\n"
5160
"\n"
5161
" if(ProfileMode != 3)\n"
5162
" {\n"
5163
" PushIntoArray(ProfileDrawTime, DrawTime);\n"
5164
" PushIntoArray(ProfileDeltaTime, Delta);\n"
5165
" PushIntoArray(ProfileDraw2Draw, Draw2Draw);\n"
5166
" }\n"
5167
" ProfileDrawStartLast = ProfileDrawStart;\n"
5168
" ProfileDrawEndLast = ProfileDrawEnd;\n"
5169
" }\n"
5170
"\n"
5171
" if(RedrawAgain)\n"
5172
" {\n"
5173
" RequestRedraw();\n"
5174
" }\n"
5175
" MouseReleased = false;\n"
5176
"}\n"
5177
"\n"
5178
"function MoveFilterInputMenuDiv(x, y, w)\n"
5179
"{\n"
5180
" if(FilterInputMenuDivPos.x != x || FilterInputMenuDivPos.y != y || FilterInputMenuDivPos.w != w)\n"
5181
" {\n"
5182
" FilterInputMenuDivPos.x = x;\n"
5183
" FilterInputMenuDivPos.y = y;\n"
5184
" FilterInputMenuDivPos.w = w;\n"
5185
" FilterInputMenuDiv.style[\'left\'] = x + \'px\';\n"
5186
" FilterInputMenuDiv.style[\'top\'] = y + \'px\';\n"
5187
" FilterInputMenu.style[\'width\'] = w + \'px\';\n"
5188
" }\n"
5189
"}\n"
5190
"function MoveFilterInputDiv(x, y, w)\n"
5191
"{\n"
5192
" if(FilterInputDivPos.x != x || FilterInputDivPos.y != y || FilterInputDivPos.w != w)\n"
5193
" {\n"
5194
" FilterInputDivPos.x = x;\n"
5195
" FilterInputDivPos.y = y;\n"
5196
" FilterInputDivPos.w = w;\n"
5197
" FilterInputDiv.style[\'left\'] = x + \'px\';\n"
5198
" FilterInputDiv.style[\'top\'] = (y + (CanvasHistory.height / DPR)) + \'px\';\n"
5199
" FilterInput.style[\'width\'] = w + \'px\';\n"
5200
" }\n"
5201
"}\n"
5202
"\n"
5203
"\n"
5204
"function MakeMenuItem(name, f, visible)\n"
5205
"{\n"
5206
" var Item = {};\n"
5207
" Item.name = name;\n"
5208
" Item.f = f;\n"
5209
" Item.w = name.length;\n"
5210
" Item.x = 0;\n"
5211
" Item.y = 0;\n"
5212
" Item.visible = visible;\n"
5213
" return Item;\n"
5214
"}\n"
5215
"function EnableMenu(m)\n"
5216
"{\n"
5217
" if(m != SubMenuActive)\n"
5218
" {\n"
5219
" if(SubMenuActive == SubMenuThreads)\n"
5220
" {\n"
5221
" FilterInputMenuThreadsValue = FilterInputMenu.value;\n"
5222
" }\n"
5223
" else if(SubMenuActive == SubMenuGroups)\n"
5224
" {\n"
5225
" FilterInputMenuGroupsValue = FilterInputMenu.value;\n"
5226
" }\n"
5227
"\n"
5228
" SubMenuActive = m;\n"
5229
" SubMenuTimeout = new Date();\n"
5230
"\n"
5231
" if(SubMenuActive == SubMenuThreads)\n"
5232
" {\n"
5233
" FilterInputMenu.value = FilterInputMenuThreadsValue;\n"
5234
" FilterInputMenu.focus();\n"
5235
" }\n"
5236
" else if(SubMenuActive == SubMenuGroups)\n"
5237
" {\n"
5238
" FilterInputMenu.value = FilterInputMenuGroupsValue;\n"
5239
" FilterInputMenu.focus();\n"
5240
" }\n"
5241
" FilterInputMenuValueLast = FilterInput.value;\n"
5242
" // if(m == SubMenuHelp)\n"
5243
" {\n"
5244
" let info = document.getElementById(\"divFrameInfo\");\n"
5245
" info.display = \'inline\';\n"
5246
" }\n"
5247
" }\n"
5248
" if(m == -1)\n"
5249
" {\n"
5250
" SubMenuTimeout = 0;\n"
5251
" }\n"
5252
" if(SubMenuActive == SubMenuGroups || SubMenuActive == SubMenuThreads)\n"
5253
" {\n"
5254
" FilterInputMenuDiv.style[\'display\'] = \'inline\';\n"
5255
" FilterInputMenu.focus();\n"
5256
" }\n"
5257
" else\n"
5258
" {\n"
5259
" FilterInputMenuDiv.style[\'display\'] = \'none\';\n"
5260
" }\n"
5261
"}\n"
5262
"function InitMenu()\n"
5263
"{\n"
5264
" MenuItems = [];\n"
5265
" MenuItems.push(MakeMenuItem(\"?\", function(){EnableMenu(SubMenuHelp); } ));\n"
5266
" MenuItems.push(MakeMenuItem(\"Mode\", function(){EnableMenu(SubMenuMode); } ));\n"
5267
" MenuItems.push(MakeMenuItem(\"Reference\", function(){EnableMenu(SubMenuReference); } ));\n"
5268
" MenuItems.push(MakeMenuItem(\"Target\", function(){EnableMenu(SubMenuTarget); } ));\n"
5269
" MenuItems.push(MakeMenuItem(\"Threads\", function(){ EnableMenu(SubMenuThreads); }, function(){ return Mode != ModeCounters && Mode != ModeTimers_Groups; }));\n"
5270
" MenuItems.push(MakeMenuItem(\"Groups\", function(){ EnableMenu(SubMenuGroups); }, function() { return Mode != ModeDetailed && Mode != ModeCounters && Mode != ModeTimers_Threads; } ));\n"
5271
" MenuItems.push(MakeMenuItem(\"Columns\", function(){ EnableMenu(SubMenuColumns); }, function(){return Mode == ModeTimers; } ));\n"
5272
" MenuItems.push(MakeMenuItem(\"Options\", function(){ EnableMenu(SubMenuOptions); } ));\n"
5273
" MenuItems.push(MakeMenuItem(\"Compare\", function(){ EnableMenu(SubMenuCompare); } ));\n"
5274
"}\n"
5275
"function DrawTopMenu(context)\n"
5276
"{\n"
5277
" MenuItems[SubMenuMode].name = \"Mode[\" + ModeItems[Mode] + \"]\";\n"
5278
" let X = 2;\n"
5279
" let Y = 0;\n"
5280
" let MouseInY = GlobalMouseY < BoxHeight;\n"
5281
" for(let i = 0; i < MenuItems.length; ++i)\n"
5282
" {\n"
5283
" let Item = MenuItems[i];\n"
5284
" if(Item.visible == null || Item.visible())\n"
5285
" {\n"
5286
" let w = context.measureText(Item.name).width + 4;\n"
5287
" let MouseIn = MouseInY && GlobalMouseX >= X && GlobalMouseX < X + w;\n"
5288
" let color = MouseIn ? nBackColors[1] : \"black\";\n"
5289
" Item.x = X;\n"
5290
" Item.y = Y + BoxHeight;\n"
5291
" if(MouseIn)\n"
5292
" {\n"
5293
" context.fillStyle = \'white\';\n"
5294
" context.fillRect(X-2, Y, w+4, BoxHeight);\n"
5295
" // Enable\n"
5296
" EnableMenu(i);\n"
5297
" }\n"
5298
" context.fillStyle = color;\n"
5299
" context.fillRect(X, Y, w, BoxHeight);\n"
5300
" context.fillStyle = \"white\";\n"
5301
" context.fillText(Item.name, X+2, Y+BoxHeight-FontAscent);\n"
5302
" if(MouseIn && MouseReleased)\n"
5303
" {\n"
5304
" Item.f();\n"
5305
" }\n"
5306
" X += w + 6;\n"
5307
" }\n"
5308
" }\n"
5309
"\n"
5310
" return WindowRect(0, 0, X, BoxHeight);\n"
5311
"}\n"
5312
"function MenuSize(w)\n"
5313
"{\n"
5314
" return WindowRect(nWidth / 2 - w / 2, HistoryHeight + 50,w, nHeight);\n"
5315
"}\n"
5316
"function MouseInRect(Rect)\n"
5317
"{\n"
5318
" return MouseInside(Rect.x, Rect.y, Rect.w, Rect.h);\n"
5319
"}\n"
5320
"function MouseInside(X, Y, W, H)\n"
5321
"{\n"
5322
" return GlobalMouseX >= X && GlobalMouseX <= X + W && GlobalMouseY >= Y && GlobalMouseY <= Y + H;\n"
5323
"}\n"
5324
"\n"
5325
"function DrawMenuGeneric(Elements, Active, OnClick, x, y, Elements2)\n"
5326
"{\n"
5327
" let context = CanvasMenu.getContext(\'2d\');\n"
5328
" let nColorIndex = 0;\n"
5329
" if(Elements2 && Elements2.length != Elements.length)\n"
5330
" {\n"
5331
" Elements2 = null;\n"
5332
" }\n"
5333
" let h = FontHeight * Elements.length;\n"
5334
" let w = 20;\n"
5335
" let w2 = 0;\n"
5336
" for(let i = 0; i < Elements.length; ++i)\n"
5337
" {\n"
5338
" let m = context.measureText(Elements[i]).width;\n"
5339
" w = w > m ? w : m;\n"
5340
" if(Elements2)\n"
5341
" {\n"
5342
" m = context.measureText(Elements2[i]).width;\n"
5343
" w2 = w2 > m ? w2 : m;\n"
5344
" }\n"
5345
" }\n"
5346
" w += 10 + w2;\n"
5347
" let SizeInfo = MenuSize(w);\n"
5348
" SizeInfo.x = x;\n"
5349
" SizeInfo.y = y;\n"
5350
" let X = x;\n"
5351
" let Y = y;\n"
5352
"\n"
5353
"\n"
5354
" for(let i = 0; i < Elements.length; ++i)\n"
5355
" {\n"
5356
" let Selected = Active(i);\n"
5357
" let Name = Elements[i];\n"
5358
" let bMouseIn = GlobalMouseY >= Y && GlobalMouseY < Y + BoxHeight;\n"
5359
" let bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
5360
" let TextY = Y+BoxHeight-FontAscent;\n"
5361
" context.fillStyle = Selected?\'white\':bgcolor;\n"
5362
" context.fillRect(X-2, Y, w+4, BoxHeight);\n"
5363
" context.fillStyle = bgcolor;\n"
5364
" context.fillRect(X, Y, w, BoxHeight);\n"
5365
" context.fillStyle = \'white\';\n"
5366
" context.fillText(Name, X + 2, TextY);\n"
5367
" if(Elements2)\n"
5368
" {\n"
5369
" context.textAlign = \"right\";\n"
5370
" context.fillText(Elements2[i], X + w , TextY);\n"
5371
" context.textAlign = \"left\";\n"
5372
" }\n"
5373
" context.fillText(Name, X + 2, TextY);\n"
5374
" if(bMouseIn && MouseReleased)\n"
5375
" {\n"
5376
" OnClick(i, Name);\n"
5377
" }\n"
5378
" Y += BoxHeight;\n"
5379
" nColorIndex = 1-nColorIndex;\n"
5380
" }\n"
5381
" SizeInfo.h = Y - SizeInfo.y;\n"
5382
" return SizeInfo;\n"
5383
"}\n"
5384
"\n"
5385
"function DrawMenuReference()\n"
5386
"{\n"
5387
" let Names = [];\n"
5388
" let ActiveIdx = 0;\n"
5389
" for(let i in ReferenceTimes)\n"
5390
" {\n"
5391
" let v = ReferenceTimes[i];\n"
5392
" if(v < 0)\n"
5393
" {\n"
5394
" Names.push(ReferenceTimeAutoString);\n"
5395
" }\n"
5396
" else\n"
5397
" {\n"
5398
" if(ReferenceTime == ReferenceTimes[i])\n"
5399
" {\n"
5400
" ActiveIdx = i;\n"
5401
" }\n"
5402
" Names.push(v + \"ms\");\n"
5403
" }\n"
5404
" }\n"
5405
" let Click = function(idx, name)\n"
5406
" {\n"
5407
" SetReferenceTime(Names[idx]);\n"
5408
" RequestRedraw();\n"
5409
" Invalidate = 0;\n"
5410
"\n"
5411
" };\n"
5412
" let x = MenuItems[SubMenuReference].x;\n"
5413
" let y = MenuItems[SubMenuReference].y;\n"
5414
" let Active = function(Idx) { return ActiveIdx == Idx; };\n"
5415
" return DrawMenuGeneric(Names, Active, Click, x, y, null);\n"
5416
"}\n"
5417
"function DrawMenuTarget()\n"
5418
"{\n"
5419
" let Names = [];\n"
5420
" for(let i in TargetTimes)\n"
5421
" {\n"
5422
" Names.push(TargetTimes[i] + \"ms\");\n"
5423
" }\n"
5424
" let Click = function(idx, name)\n"
5425
" {\n"
5426
" SetTargetTime(Names[idx]);\n"
5427
" RequestRedraw();\n"
5428
" Invalidate = 0;\n"
5429
"\n"
5430
" };\n"
5431
" let x = MenuItems[SubMenuTarget].x;\n"
5432
" let y = MenuItems[SubMenuTarget].y;\n"
5433
" let Active = function(Idx) { return TargetTimes[Idx] == TargetTime; };\n"
5434
" return DrawMenuGeneric(Names, Active, Click, x, y, null);\n"
5435
"}\n"
5436
"\n"
5437
"function DrawMenuMode()\n"
5438
"{\n"
5439
" let Click = function(idx, name)\n"
5440
" {\n"
5441
" SetMode(idx,false);\n"
5442
" MenuItems[SubMenuMode].name = \"Mode[\" + ModeItems[idx] + \"]\";\n"
5443
" RequestRedraw();\n"
5444
" Invalidate = 0;\n"
5445
"\n"
5446
" };\n"
5447
" let x = MenuItems[SubMenuMode].x;\n"
5448
" let y = MenuItems[SubMenuMode].y;\n"
5449
" let Active = function(Idx) { return Idx == Mode; };\n"
5450
" return DrawMenuGeneric(ModeItems, Active, Click, x, y, null);\n"
5451
"}\n"
5452
"function DrawMenuOptions()\n"
5453
"{\n"
5454
" let DrawMode = DrawDetailedNewDraw ? \"DrawMode[New]\":\"DrawMode[Old]\";\n"
5455
" let OptionNames =[\"Context Switch\", \"MergeDisable\", \"LodDisable\", \"Flame Mode\", \"Compare Reverse\", \"Help\",DrawMode];\n"
5456
" let Click = function(idx, name)\n"
5457
" {\n"
5458
" switch(idx)\n"
5459
" {\n"
5460
" case 0: ToggleContextSwitch(); break;\n"
5461
" case 1: ToggleDisableMerge(); break;\n"
5462
" case 2: ToggleDisableLod(); break;\n"
5463
" case 3: ToggleDetailedFlameMode(); break;\n"
5464
" case 4: ToggleDetailedSecondReverse(); break;\n"
5465
" case 5: ShowHelp(1,1); break;\n"
5466
" case 6: ToggleDetailedNewDraw(); break;\n"
5467
" }\n"
5468
" RequestRedraw();\n"
5469
" Invalidate = 0;\n"
5470
"\n"
5471
" };\n"
5472
" let x = MenuItems[SubMenuOptions].x;\n"
5473
" let y = MenuItems[SubMenuOptions].y;\n"
5474
" let Active = function(Idx) { return false; };\n"
5475
" return DrawMenuGeneric(OptionNames, Active, Click, x, y, null);\n"
5476
"}\n"
5477
"\n"
5478
"function DrawMenuColumns()\n"
5479
"{\n"
5480
" let Click = function(idx, name)\n"
5481
" {\n"
5482
" ToggleColumn(idx);\n"
5483
"\n"
5484
" };\n"
5485
" let x = MenuItems[SubMenuColumns].x;\n"
5486
" let y = MenuItems[SubMenuColumns].y;\n"
5487
" let Active = function(Idx) { return ColumnsEnabled[Idx]; };\n"
5488
" return DrawMenuGeneric(ColumnNames, Active, Click, x, y, null);\n"
5489
"\n"
5490
"}\n"
5491
"\n"
5492
"function GroupMenuSize()\n"
5493
"{\n"
5494
" return MenuSize(300);\n"
5495
"}\n"
5496
"\n"
5497
"function ThreadMenuSize()\n"
5498
"{\n"
5499
" return MenuSize(S.ThreadNameWidth + S.ThreadCategoryWidth + 10);\n"
5500
"}\n"
5501
"\n"
5502
"function DrawMenuSeparator(context, X, Y, W, Height)\n"
5503
"{\n"
5504
" context.fillStyle = \'grey\';\n"
5505
" context.fillRect(X-2, Y, W+2, Height);\n"
5506
"}\n"
5507
"\n"
5508
"function DrawMultiMenu(context, X, Y, W, Elements, Callbacks)\n"
5509
"{\n"
5510
" let A = Array();\n"
5511
" let wtemp = W;\n"
5512
" let bMouseIn = GlobalMouseY >= Y && GlobalMouseY < Y + BoxHeight;\n"
5513
"\n"
5514
" for(let i = 0; i < Elements.length; ++i)\n"
5515
" {\n"
5516
" let wElement = context.measureText(Elements[i]).width;\n"
5517
" if(i > 0)\n"
5518
" {\n"
5519
" wElement += 15;\n"
5520
" wtemp -= wElement;\n"
5521
" }\n"
5522
" A.push(wElement);\n"
5523
" }\n"
5524
" A[0] = Math.max(wtemp, 0);\n"
5525
"\n"
5526
" context.fillStyle = nBackColors[0];\n"
5527
" context.fillRect(X-2, Y, W, BoxHeight);\n"
5528
" let XOff = 0;\n"
5529
" let TextY = Y+BoxHeight-FontAscent;\n"
5530
" for(let i = 0; i < Elements.length; ++i)\n"
5531
" {\n"
5532
" let width = A[i];\n"
5533
" let Inside = i != 0 && bMouseIn && GlobalMouseX > XOff + X && GlobalMouseX <= XOff + X + width;\n"
5534
" context.fillStyle = Inside ? nBackColorOffset : nBackColors[0];\n"
5535
" context.fillRect(X+XOff, Y, width, BoxHeight);\n"
5536
" context.fillStyle = \'white\';\n"
5537
" context.textAlign = \'center\';\n"
5538
" context.fillText(Elements[i], X+XOff + width * 0.5, TextY);\n"
5539
" XOff += width;\n"
5540
" if(Inside && MouseReleased && Callbacks[i])\n"
5541
" {\n"
5542
" Callbacks[i]();\n"
5543
" }\n"
5544
" }\n"
5545
" context.textAlign = \'left\';\n"
5546
"}\n"
5547
"\n"
5548
"function DrawMenuThreads()\n"
5549
"{\n"
5550
" if(FilterInputMenuValueLast != FilterInputMenu.value)\n"
5551
" {\n"
5552
" nOffsetMenuThreads = 0;\n"
5553
" }\n"
5554
" FilterInputMenuValueLast = FilterInputMenu.value;\n"
5555
" let FilterArray = CreateFilter(FilterInputMenu.value);\n"
5556
" let context = CanvasMenu.getContext(\'2d\');\n"
5557
" let nColorIndex = 0;\n"
5558
" let SizeInfo = ThreadMenuSize();\n"
5559
" SizeInfo.x = MenuItems[SubMenuThreads].x;\n"
5560
" SizeInfo.y = MenuItems[SubMenuThreads].y;\n"
5561
" let Y = SizeInfo.y;\n"
5562
" let Width = SizeInfo.w;\n"
5563
" let Selection = null;\n"
5564
" let X = SizeInfo.x;\n"
5565
" MoveFilterInputMenuDiv(SizeInfo.x, SizeInfo.y, SizeInfo.w);\n"
5566
" Y += 35;\n"
5567
"\n"
5568
" let bMouseIn = GlobalMouseY >= Y && GlobalMouseY < Y + BoxHeight;\n"
5569
" let bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
5570
" let TextY = Y+BoxHeight-FontAscent;\n"
5571
" let YClear = Y;\n"
5572
" let TextYClear = TextY;\n"
5573
" let YStart = Y;\n"
5574
" let MatchCount = 0;\n"
5575
" let MouseTaken = bMouseIn;\n"
5576
"\n"
5577
" Y += (BoxHeight) * 5 + 3 * 2;\n"
5578
" nColorIndex = 1-nColorIndex;\n"
5579
"\n"
5580
" Y -= nOffsetMenuThreads;\n"
5581
" let CPULogs = [];\n"
5582
" let GPULogs = [];\n"
5583
" for(let i = 0; i < S.ThreadNames.length; ++i)\n"
5584
" {\n"
5585
" let Name = S.ThreadNames[i];\n"
5586
" if(S.ISGPU[i])\n"
5587
" GPULogs.push(Name);\n"
5588
" else\n"
5589
" CPULogs.push(Name);\n"
5590
" let ParentName = \"ThreadCategory\";\n"
5591
" if(FilterMatch(FilterArray, ParentName + \" \" + Name))\n"
5592
" {\n"
5593
" if(Y > YStart)\n"
5594
" {\n"
5595
" let ParentColor = \'white\';\n"
5596
" let E = IsThreadActive(Name);\n"
5597
" let AutoHidden = S.ThreadLogAutoHidden[i];\n"
5598
" bMouseIn = GlobalMouseY >= Y && GlobalMouseY < Y + BoxHeight && !MouseTaken;\n"
5599
" bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
5600
" TextY = Y+BoxHeight-FontAscent;\n"
5601
" context.fillStyle = E ? (AutoHidden?\'orange\':\'white\') :bgcolor;\n"
5602
" context.fillRect(X-2, Y, Width+4, BoxHeight);\n"
5603
" context.fillStyle = bgcolor;\n"
5604
" context.fillRect(X, Y, Width, BoxHeight);\n"
5605
" context.fillStyle = ParentColor;\n"
5606
" context.fillText(ParentName, X + 2, TextY);\n"
5607
" context.fillStyle = S.ThreadColors[i].color;\n"
5608
" context.textAlign = \'right\';\n"
5609
" context.fillText(Name, X + Width - 2, TextY);\n"
5610
" context.textAlign = \'left\';\n"
5611
" if(bMouseIn && MouseReleased)\n"
5612
" {\n"
5613
" ToggleThread(Name);\n"
5614
" RequestRedraw();\n"
5615
" }\n"
5616
" }\n"
5617
" Y += BoxHeight;\n"
5618
" nColorIndex = 1-nColorIndex;\n"
5619
" MatchCount++;\n"
5620
" }\n"
5621
" }\n"
5622
" let TextAll = \"All [\" + S.ThreadNames.length + \"]\";\n"
5623
" let TextFiltered = \"Filtered [\" + MatchCount +\"]\";\n"
5624
" let TextCPU = \"CPU [\" + CPULogs.length + \"]\";\n"
5625
" let TextGPU = \"GPU [\" + GPULogs.length + \"]\";\n"
5626
"\n"
5627
" let ElementsAll = [TextAll, \"Off\", \"Flip\", \"On\"];\n"
5628
" let Elements";
5629
5630
const size_t g_MicroProfileHtml_end_3_size = sizeof(g_MicroProfileHtml_end_3);
5631
const char g_MicroProfileHtml_end_4[] =
5632
"Filtered = [TextFiltered, \"Off\", \"Flip\", \"On\"];\n"
5633
" let ElementsCPU = [TextCPU, \"Off\", \"Flip\", \"On\"];\n"
5634
" let ElementsGPU = [TextGPU, \"Off\", \"Flip\", \"On\"];\n"
5635
" \n"
5636
" let CallbacksAll = [null,\n"
5637
" function(){ ToggleThread(0, 1, 0, 0); },\n"
5638
" function(){ ToggleThread(0, 1, 0, 1); },\n"
5639
" function(){ ToggleThread(0, 1, 0, 2); },\n"
5640
" ];\n"
5641
"\n"
5642
" let CallbacksCPU = [null,\n"
5643
" function(){ ToggleThread(0, 0, CPULogs, 0); },\n"
5644
" function(){ ToggleThread(0, 0, CPULogs, 1); },\n"
5645
" function(){ ToggleThread(0, 0, CPULogs, 2); },\n"
5646
" ];\n"
5647
" let CallbacksGPU = [null,\n"
5648
" function(){ ToggleThread(0, 0, GPULogs, 0); },\n"
5649
" function(){ ToggleThread(0, 0, GPULogs, 1); },\n"
5650
" function(){ ToggleThread(0, 0, GPULogs, 2); },\n"
5651
" ];\n"
5652
"\n"
5653
"\n"
5654
" let CreateFilteredArray = function()\n"
5655
" {\n"
5656
" if(!FilterArray) return S.ThreadNames;\n"
5657
" let A = [];\n"
5658
" for(let i = 0; i < S.ThreadNames.length; ++i)\n"
5659
" {\n"
5660
" let Name = S.ThreadNames[i];\n"
5661
" let ParentName = \"ThreadCategory\";\n"
5662
" if(FilterMatch(FilterArray, ParentName + \" \" + Name))\n"
5663
" {\n"
5664
" A.push(Name);\n"
5665
" }\n"
5666
" }\n"
5667
" return A;\n"
5668
" };\n"
5669
" let CallbacksFiltered = [null,\n"
5670
" function(){let F = CreateFilteredArray(); ToggleThread(0, 0, F, 0); },\n"
5671
" function(){let F = CreateFilteredArray(); ToggleThread(0, 0, F, 1); },\n"
5672
" function(){let F = CreateFilteredArray(); ToggleThread(0, 0, F, 2); },\n"
5673
" ];\n"
5674
"\n"
5675
"\n"
5676
" let ElementsOptions = [\"Options\", \"Hide mode:\" + (HideMode==HideModeCollapsed ? \"Collapsed\" : \"Invisible\"), \"AutoHide Empty:\" + (ThreadLogAutoHide ? \"On\": \"Off\")];\n"
5677
" let CallbacksOptions = [null,\n"
5678
" function(){\n"
5679
" HideMode = HideMode == HideModeCollapsed ? HideModeFullyHidden : HideModeCollapsed;\n"
5680
" RequestRedraw();\n"
5681
" Invalidate = 0;\n"
5682
" },\n"
5683
" function(){\n"
5684
" ThreadLogAutoHide = ThreadLogAutoHide ? 0 : 1; UpdateThreadLogAutoHide()\n"
5685
" RequestRedraw();\n"
5686
" Invalidate = 0;\n"
5687
" }\n"
5688
" ];\n"
5689
"\n"
5690
" DrawMultiMenu(context, X, YClear, Width, ElementsOptions, CallbacksOptions);\n"
5691
" YClear += BoxHeight;\n"
5692
" DrawMenuSeparator(context, X, YClear, Width, 2);\n"
5693
" YClear += 2;\n"
5694
" DrawMultiMenu(context, X, YClear, Width, ElementsAll, CallbacksAll);\n"
5695
" YClear += BoxHeight;\n"
5696
" DrawMultiMenu(context, X, YClear, Width, ElementsFiltered, CallbacksFiltered);\n"
5697
" YClear += BoxHeight;\n"
5698
" DrawMenuSeparator(context, X, YClear, Width, 2);\n"
5699
" YClear += 2;\n"
5700
" DrawMultiMenu(context, X, YClear, Width, ElementsGPU, CallbacksGPU);\n"
5701
" YClear += BoxHeight;\n"
5702
" DrawMultiMenu(context, X, YClear, Width, ElementsCPU, CallbacksCPU);\n"
5703
" YClear += BoxHeight;\n"
5704
" DrawMenuSeparator(context, X, YClear, Width, 2);\n"
5705
" YClear += 2;\n"
5706
"\n"
5707
" SizeInfo.h = Y-SizeInfo.y;\n"
5708
" return SizeInfo;\n"
5709
"}\n"
5710
"\n"
5711
"function DrawMenuGroups()\n"
5712
"{\n"
5713
" if(FilterInputMenuValueLast != FilterInputMenu.value)\n"
5714
" {\n"
5715
" nOffsetMenuThreads = 0;\n"
5716
" }\n"
5717
" FilterInputMenuValueLast = FilterInputMenu.value;\n"
5718
" let FilterArray = CreateFilter(FilterInputMenu.value);\n"
5719
" let context = CanvasMenu.getContext(\'2d\');\n"
5720
" let nColorIndex = 0;\n"
5721
" let SizeInfo = ThreadMenuSize();\n"
5722
" SizeInfo.x = MenuItems[SubMenuGroups].x;\n"
5723
" SizeInfo.y = MenuItems[SubMenuGroups].y;\n"
5724
" let Y = SizeInfo.y;\n"
5725
" let Width = SizeInfo.w;\n"
5726
" let Selection = null;\n"
5727
" let X = SizeInfo.x;\n"
5728
" MoveFilterInputMenuDiv(SizeInfo.x, SizeInfo.y, SizeInfo.w);\n"
5729
" Y += 35;\n"
5730
"\n"
5731
" let bMouseIn = GlobalMouseY >= Y && GlobalMouseY < Y + BoxHeight;\n"
5732
" let bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
5733
" let TextY = Y+BoxHeight-FontAscent;\n"
5734
" let YClear = Y;\n"
5735
" let TextYClear = TextY;\n"
5736
" let YStart = Y;\n"
5737
" let MatchCount = 0;\n"
5738
" let MouseTaken = bMouseIn;\n"
5739
"\n"
5740
" Y += BoxHeight * 2;\n"
5741
" nColorIndex = 1-nColorIndex;\n"
5742
"\n"
5743
" Y -= nOffsetMenuThreads;\n"
5744
"\n"
5745
"\n"
5746
"\n"
5747
" for(var i = 0; i < S.GroupInfo.length; ++i)\n"
5748
" {\n"
5749
" let Name = S.GroupInfo[i].name;\n"
5750
" let ParentName = S.CategoryInfo[S.GroupInfo[i].category];\n"
5751
" let Color = g_Colors[ S.GroupInfo[i].cid ];\n"
5752
" if(FilterMatch(FilterArray, ParentName + \" \" + Name))\n"
5753
" {\n"
5754
" if(Y > YStart)\n"
5755
" {\n"
5756
" var ParentColor = \'white\';\n"
5757
" let E = !GroupsDisabled[Name];\n"
5758
" bMouseIn = GlobalMouseY >= Y && GlobalMouseY < Y + BoxHeight && !MouseTaken;\n"
5759
" bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
5760
" TextY = Y+BoxHeight-FontAscent;\n"
5761
" context.fillStyle = E ? \'white\' :bgcolor;\n"
5762
" context.fillRect(X-2, Y, Width+4, BoxHeight);\n"
5763
" context.fillStyle = bgcolor;\n"
5764
" context.fillRect(X, Y, Width, BoxHeight);\n"
5765
" context.fillStyle = ParentColor;\n"
5766
" context.fillText(ParentName, X + 2, TextY);\n"
5767
" context.fillStyle = Color;\n"
5768
" context.textAlign = \'right\';\n"
5769
" context.fillText(Name, X + Width - 2, TextY);\n"
5770
" context.textAlign = \'left\';\n"
5771
" if(bMouseIn && MouseReleased)\n"
5772
" {\n"
5773
" ToggleGroup(Name);\n"
5774
" RequestRedraw();\n"
5775
" }\n"
5776
" }\n"
5777
" Y += BoxHeight;\n"
5778
" nColorIndex = 1-nColorIndex;\n"
5779
" MatchCount++;\n"
5780
" }\n"
5781
" }\n"
5782
" let TextAll = \"All [\" + S.GroupInfo.length + \"]\";\n"
5783
" let TextFiltered = \"Filtered [\" + MatchCount +\"]\";\n"
5784
"\n"
5785
"\n"
5786
"\n"
5787
" let ElementsAll = [TextAll, \"Off\", \"Flip\", \"On\"];\n"
5788
" let CallbacksAll = [null,\n"
5789
" function(){ ToggleGroup(0, 1, 0, 0); },\n"
5790
" function(){ ToggleGroup(0, 1, 0, 1); },\n"
5791
" function(){ ToggleGroup(0, 1, 0, 2); },\n"
5792
" ];\n"
5793
" let ElementsFiltered = [TextFiltered, \"Off\", \"Flip\", \"On\"];\n"
5794
" let CreateFilteredArray = function()\n"
5795
" {\n"
5796
" let A = [];\n"
5797
" for(let i = 0; i < S.GroupInfo.length; ++i)\n"
5798
" {\n"
5799
" let Name = S.GroupInfo[i].name;\n"
5800
" let ParentName = S.CategoryInfo[S.GroupInfo[i].category];\n"
5801
" if(FilterMatch(FilterArray, ParentName + \" \" + Name))\n"
5802
" {\n"
5803
" A.push(Name);\n"
5804
" }\n"
5805
" }\n"
5806
" return A;\n"
5807
" };\n"
5808
" let CallbacksFiltered = [null,\n"
5809
" function(){let F = CreateFilteredArray(); ToggleGroup(0, 0, F, 0); },\n"
5810
" function(){let F = CreateFilteredArray(); ToggleGroup(0, 0, F, 1); },\n"
5811
" function(){let F = CreateFilteredArray(); ToggleGroup(0, 0, F, 2); },\n"
5812
" ];\n"
5813
"\n"
5814
"\n"
5815
" DrawMultiMenu(context, X, YClear, Width, ElementsAll, CallbacksAll);\n"
5816
" DrawMultiMenu(context, X, YClear+BoxHeight, Width, ElementsFiltered, CallbacksFiltered);\n"
5817
"\n"
5818
" SizeInfo.h = Y-SizeInfo.y;\n"
5819
" return SizeInfo;\n"
5820
"\n"
5821
"\n"
5822
"}\n"
5823
"\n"
5824
"function DrawMenu()\n"
5825
"{\n"
5826
" MenuRedraw = 0;\n"
5827
"\n"
5828
" var context = CanvasMenu.getContext(\'2d\');\n"
5829
" context.clearRect(0, 0, CanvasMenu.width, CanvasMenu.height);\n"
5830
"\n"
5831
" var nColorIndex = 0;\n"
5832
" var Y = 50;\n"
5833
" var Width = 300;\n"
5834
" var Selection = null;\n"
5835
"\n"
5836
" ProfileEnter(\"DrawMenu\");\n"
5837
" let MenuRect = DrawTopMenu(context);\n"
5838
" if(SubMenuActive != -1)\n"
5839
" {\n"
5840
" MouseMoveTime = new Date();\n"
5841
" }\n"
5842
" if(SubMenuActive == SubMenuHelp)\n"
5843
" {\n"
5844
" if(MouseReleased)\n"
5845
" {\n"
5846
" ToggleDebugMode();\n"
5847
" }\n"
5848
" }\n"
5849
" if(SubMenuActive == SubMenuMode)\n"
5850
" {\n"
5851
" MenuRect = DrawMenuMode();\n"
5852
" }\n"
5853
" else if(SubMenuActive == SubMenuReference)\n"
5854
" {\n"
5855
" MenuRect = DrawMenuReference();\n"
5856
" }\n"
5857
" else if(SubMenuActive == SubMenuTarget)\n"
5858
" {\n"
5859
" MenuRect = DrawMenuTarget();\n"
5860
" }\n"
5861
" else if(SubMenuActive == SubMenuThreads)\n"
5862
" {\n"
5863
" MenuRect = DrawMenuThreads();\n"
5864
" }\n"
5865
" else if(SubMenuActive == SubMenuGroups)\n"
5866
" {\n"
5867
" MenuRect = DrawMenuGroups();\n"
5868
" }\n"
5869
" else if(SubMenuActive == SubMenuOptions)\n"
5870
" {\n"
5871
" MenuRect = DrawMenuOptions();\n"
5872
" }\n"
5873
" else if(SubMenuActive == SubMenuCompare)\n"
5874
" {\n"
5875
" if(MouseReleased)\n"
5876
" {\n"
5877
" ComparePrompt();\n"
5878
" }\n"
5879
" }\n"
5880
" else if(SubMenuActive == SubMenuColumns)\n"
5881
" {\n"
5882
" MenuRect = DrawMenuColumns();\n"
5883
" }\n"
5884
" var Grow = 10;\n"
5885
" MenuRect.x -= Grow;\n"
5886
" MenuRect.y -= Grow;\n"
5887
" MenuRect.h += 2*Grow;\n"
5888
" MenuRect.w += 2*Grow;\n"
5889
" var MouseMoved = GlobalMouseX != SubMenuMouseX || GlobalMouseY != SubMenuMouseY;\n"
5890
"\n"
5891
" if(MouseInRect(MenuRect) || !MouseMoved)\n"
5892
" {\n"
5893
" SubMenuTimeout = new Date();\n"
5894
" SubMenuMouseX = GlobalMouseX;\n"
5895
" SubMenuMouseY = GlobalMouseY;\n"
5896
" }\n"
5897
" else\n"
5898
" {\n"
5899
" var Time = new Date() - SubMenuTimeout;\n"
5900
" var Dest = SubMenuTimeoutBase * 1000;\n"
5901
" if(Time > Dest)\n"
5902
" {\n"
5903
" EnableMenu(-1);\n"
5904
" }\n"
5905
" }\n"
5906
" if(0)//debugging of menu extents. dont delete\n"
5907
" {\n"
5908
" context.strokeStyle = \'red\';\n"
5909
" context.beginPath();\n"
5910
" context.moveTo(MenuRect.x,MenuRect.y);\n"
5911
" context.lineTo(MenuRect.x + MenuRect.w,MenuRect.y);\n"
5912
" context.lineTo(MenuRect.x + MenuRect.w,MenuRect.y+MenuRect.h);\n"
5913
" context.lineTo(MenuRect.x,MenuRect.y+MenuRect.h);\n"
5914
" context.lineTo(MenuRect.x,MenuRect.y);\n"
5915
" context.stroke();\n"
5916
" } // SpinnerDraw(SpinnerShow(), context, SpinnerCorner, 0, nHeight-20, 20, 20);\n"
5917
" ProfileLeave();\n"
5918
"}\n"
5919
"\n"
5920
"\n"
5921
"function ZoomGraph(nZoom)\n"
5922
"{\n"
5923
" var fOldRange = fDetailedRange;\n"
5924
" if(nZoom>0)\n"
5925
" {\n"
5926
" fDetailedRange *= Math.pow(nModDown ? 1.40 : 1.03, nZoom);\n"
5927
" }\n"
5928
" else\n"
5929
" {\n"
5930
" var fNewDetailedRange = fDetailedRange / Math.pow((nModDown ? 1.40 : 1.03), -nZoom);\n"
5931
" if(fNewDetailedRange < 0.0001) //100ns\n"
5932
" fNewDetailedRange = 0.0001;\n"
5933
" fDetailedRange = fNewDetailedRange;\n"
5934
" }\n"
5935
"\n"
5936
" var fDiff = fOldRange - fDetailedRange;\n"
5937
" var fMousePrc = DetailedViewMouseX / nWidth;\n"
5938
" if(fMousePrc < 0)\n"
5939
" {\n"
5940
" fMousePrc = 0;\n"
5941
" }\n"
5942
" fDetailedOffset += fDiff * fMousePrc;\n"
5943
"\n"
5944
"}\n"
5945
"\n"
5946
"function MeasureFont()\n"
5947
"{\n"
5948
" var context = CanvasDetailedView.getContext(\'2d\');\n"
5949
" context.font = Font;\n"
5950
" FontWidth = context.measureText(\'W\').width;\n"
5951
"\n"
5952
"}\n"
5953
"function ResizeCanvas()\n"
5954
"{\n"
5955
" nWidth = window.innerWidth;\n"
5956
" nHeight = window.innerHeight - CanvasHistory.height-2;\n"
5957
" DPR = window.devicePixelRatio;\n"
5958
"\n"
5959
" if(DPR)\n"
5960
" {\n"
5961
" nHeight = window.innerHeight - (CanvasHistory.height / DPR)-2;\n"
5962
" CanvasDetailedView.style.width = nWidth + \'px\';\n"
5963
" CanvasDetailedView.style.height = nHeight + \'px\';\n"
5964
" CanvasDetailedView.width = nWidth * DPR;\n"
5965
" CanvasDetailedView.height = nHeight * DPR;\n"
5966
" CanvasHistory.style.width = window.innerWidth + \'px\';\n"
5967
" CanvasHistory.style.height = 70 + \'px\';\n"
5968
" CanvasHistory.width = window.innerWidth * DPR;\n"
5969
" CanvasHistory.height = 70 * DPR;\n"
5970
" CanvasMenu.style.width = window.innerWidth + \'px\';\n"
5971
" CanvasMenu.style.height = window.innerHeight + \'px\';\n"
5972
" CanvasMenu.width = window.innerWidth * DPR;\n"
5973
" CanvasMenu.height = window.innerHeight * DPR;\n"
5974
" CanvasHistory.getContext(\'2d\').scale(DPR,DPR);\n"
5975
" CanvasDetailedView.getContext(\'2d\').scale(DPR,DPR);\n"
5976
" CanvasMenu.getContext(\'2d\').scale(DPR,DPR);\n"
5977
"\n"
5978
" CanvasDetailedOffscreen.style.width = nWidth + \'px\';\n"
5979
" CanvasDetailedOffscreen.style.height = nHeight + \'px\';\n"
5980
" CanvasDetailedOffscreen.width = nWidth * DPR;\n"
5981
" CanvasDetailedOffscreen.height = nHeight * DPR;\n"
5982
" CanvasDetailedOffscreen.getContext(\'2d\').scale(DPR,DPR);\n"
5983
"\n"
5984
" }\n"
5985
" else\n"
5986
" {\n"
5987
" DPR = 1;\n"
5988
" CanvasDetailedView.width = nWidth;\n"
5989
" CanvasDetailedView.height = nHeight;\n"
5990
" CanvasDetailedOffscreen.width = nWidth;\n"
5991
" CanvasDetailedOffscreen.height = nHeight;\n"
5992
"\n"
5993
" CanvasMenu.width = window.innerWidth;\n"
5994
" CanvasMenu.height = window.innerHeight;\n"
5995
" CanvasHistory.width = window.innerWidth;\n"
5996
" }\n"
5997
" RequestRedraw();\n"
5998
"}\n"
5999
"\n"
6000
"\n"
6001
"var MouseDragOff = 0;\n"
6002
"var MouseDragDown = 1;\n"
6003
"var MouseDragUp = 2;\n"
6004
"var MouseDragMove = 3;\n"
6005
"var MouseDragState = MouseDragOff;\n"
6006
"var MouseDragTarget = 0;\n"
6007
"var MouseDragButton = 0;\n"
6008
"var MouseDragButtonNext = 0;\n"
6009
"var MouseDragKeyShift = 0;\n"
6010
"var MouseDragKeyCtrl = 0;\n"
6011
"var MouseDragKeyAlt = 0;\n"
6012
"var MouseDragX = 0;\n"
6013
"var MouseDragY = 0;\n"
6014
"var MouseDragXLast = 0;\n"
6015
"var MouseDragYLast = 0;\n"
6016
"var MouseDragXStart = 0;\n"
6017
"var MouseDragYStart = 0;\n"
6018
"\n"
6019
"function clamp(number, min, max)\n"
6020
"{\n"
6021
" return Math.max(min, Math.min(number, max));\n"
6022
"}\n"
6023
"\n"
6024
"function MouseDragPan()\n"
6025
"{\n"
6026
" return (MouseDragButton == 1 && !MouseDragKeyCtrl) || MouseDragKeyShift || MouseDragKeyAlt;\n"
6027
"}\n"
6028
"function MouseDragSelectRange()\n"
6029
"{\n"
6030
" return MouseDragState == MouseDragMove && (MouseDragButton == 3 || (MouseDragKeyShift && MouseDragKeyCtrl));\n"
6031
"}\n"
6032
"function MouseHandleDrag()\n"
6033
"{\n"
6034
" if(MouseDragTarget == CanvasDetailedView)\n"
6035
" {\n"
6036
" if(Mode == ModeDetailed)\n"
6037
" {\n"
6038
"\n"
6039
" if(FilterSearchActive)\n"
6040
" {\n"
6041
" if(MouseDragKeyShift || MouseDragButton == 1)\n"
6042
" {\n"
6043
" var Y = MouseDragY - MouseDragYLast;\n"
6044
" nOffsetFilterSearch -= Y;\n"
6045
" if(nOffsetFilterSearch < 0)\n"
6046
" {\n"
6047
" nOffsetFilterSearch = 0;\n"
6048
" }\n"
6049
" }\n"
6050
" }\n"
6051
" else\n"
6052
" {\n"
6053
" if(MouseDragSelectRange())\n"
6054
" {\n"
6055
" var xStart = MouseDragXStart;\n"
6056
" var xEnd = MouseDragX;\n"
6057
" if(xStart > xEnd)\n"
6058
" {\n"
6059
" var Temp = xStart;\n"
6060
" xStart = xEnd;\n"
6061
" xEnd = Temp;\n"
6062
" }\n"
6063
" if(xEnd - xStart > 1)\n"
6064
" {\n"
6065
" RangeCpu.Begin = fDetailedOffset + fDetailedRange * (xStart / nWidth);\n"
6066
" RangeCpu.End = fDetailedOffset + fDetailedRange * (xEnd / nWidth);\n"
6067
" RangeSelect.Begin = fDetailedOffset + fDetailedRange * (xStart / nWidth);\n"
6068
" RangeSelect.End = fDetailedOffset + fDetailedRange * (xEnd / nWidth);\n"
6069
" RangeSelect.Thread = -1;\n"
6070
" RangeSelect.Index = -1;\n"
6071
" }\n"
6072
" }\n"
6073
" else if(MouseDragPan())\n"
6074
" {\n"
6075
" var X = MouseDragX - MouseDragXLast;\n"
6076
" var Y = MouseDragY - MouseDragYLast;\n"
6077
" if(X)\n"
6078
" {\n"
6079
" if(MouseDragKeyAlt)\n"
6080
" {\n"
6081
" fDetailedOffsetSecond += -X * fDetailedRange / nWidth;\n"
6082
" }\n"
6083
" else\n"
6084
" {\n"
6085
" fDetailedOffset += -X * fDetailedRange / nWidth;\n"
6086
" }\n"
6087
" }\n"
6088
" if(!MouseDragKeyAlt)\n"
6089
" {\n"
6090
" nOffsetY -= Y;\n"
6091
" }\n"
6092
" if(nOffsetY < 0)\n"
6093
" {\n"
6094
" nOffsetY = 0;\n"
6095
" }\n"
6096
" }\n"
6097
" else if(MouseDragKeyCtrl)\n"
6098
" {\n"
6099
" if(MouseDragY != MouseDragYLast)\n"
6100
" {\n"
6101
" ZoomGraph(MouseDragY - MouseDragYLast);\n"
6102
" }\n"
6103
" }\n"
6104
" }\n"
6105
" }\n"
6106
" else if(Mode == ModeTimers || Mode == ModeTimers_Threads || Mode == ModeTimers_Groups)\n"
6107
" {\n"
6108
" if(MouseDragKeyShift || MouseDragButton == 1)\n"
6109
" {\n"
6110
" var X = MouseDragX - MouseDragXLast;\n"
6111
" var Y = MouseDragY - MouseDragYLast;\n"
6112
" nOffsetBarsY -= Y;\n"
6113
" nOffsetBarsX -= X;\n"
6114
" if(nOffsetBarsY < 0)\n"
6115
" {\n"
6116
" nOffsetBarsY = 0;\n"
6117
" }\n"
6118
" if(nOffsetBarsX < 0)\n"
6119
" {\n"
6120
" nOffsetBarsX = 0;\n"
6121
" }\n"
6122
" }\n"
6123
" }\n"
6124
" else if(Mode == ModeCounters)\n"
6125
" {\n"
6126
" if(MouseDragKeyShift || MouseDragButton == 1)\n"
6127
" {\n"
6128
" var Y = MouseDragY - MouseDragYLast;\n"
6129
" nOffsetCountersY -= Y;\n"
6130
" if(nOffsetCountersY < 0)\n"
6131
" {\n"
6132
" nOffsetCountersY = 0;\n"
6133
" }\n"
6134
" }\n"
6135
" }\n"
6136
"\n"
6137
" }\n"
6138
" else if(MouseDragTarget == CanvasHistory)\n"
6139
" {\n"
6140
" function HistoryFrameTime(x)\n"
6141
" {\n"
6142
" var NumFrames = S.Frames.length;\n"
6143
" var fBarWidth = nWidth / NumFrames;\n"
6144
" var Index = clamp(Math.floor(NumFrames * x / nWidth), 0, NumFrames-1);\n"
6145
" var Lerp = clamp((x/fBarWidth - Index) , 0, 1);\n"
6146
" var time = S.Frames[Index].framestart + (S.Frames[Index].frameend - S.Frames[Index].framestart) * Lerp;\n"
6147
" return time;\n"
6148
" }\n"
6149
" if(MouseDragSelectRange())\n"
6150
" {\n"
6151
" RangeCpu = RangeInit();\n"
6152
" RangeGpu = RangeInit();\n"
6153
"\n"
6154
" var xStart = MouseDragXStart;\n"
6155
" var xEnd = MouseDragX;\n"
6156
" if(xStart > xEnd)\n"
6157
" {\n"
6158
" var Temp = xStart;\n"
6159
" xStart = xEnd;\n"
6160
" xEnd = Temp;\n"
6161
" }\n"
6162
" if(xEnd - xStart > 2)\n"
6163
" {\n"
6164
" var timestart = HistoryFrameTime(xStart);\n"
6165
" var timeend = HistoryFrameTime(xEnd);\n"
6166
" fDetailedOffset = timestart;\n"
6167
" fDetailedRange = timeend-timestart;\n"
6168
" }\n"
6169
" }\n"
6170
" else if(MouseDragPan())\n"
6171
" {\n"
6172
" var Time = HistoryFrameTime(MouseDragX);\n"
6173
" fDetailedOffset = Time - fDetailedRange / 2.0;\n"
6174
" }\n"
6175
" }\n"
6176
"}\n"
6177
"function MouseHandleDragEnd()\n"
6178
"{\n"
6179
" if(MouseDragTarget == CanvasDetailedView)\n"
6180
" {\n"
6181
"\n"
6182
" }\n"
6183
" else if(MouseDragTarget == CanvasHistory)\n"
6184
" {\n"
6185
" if(!MouseDragSelectRange() && !MouseDragPan())\n"
6186
" {\n"
6187
" ZoomToHighlight(1);\n"
6188
" }\n"
6189
" }\n"
6190
"}\n"
6191
"\n"
6192
"function MouseHandleDragClick()\n"
6193
"{\n"
6194
" if(MouseDragTarget == CanvasDetailedView)\n"
6195
" {\n"
6196
" if(Mode == ModeCounters)\n"
6197
" {\n"
6198
" if(nHoverCounter != -1)\n"
6199
" {\n"
6200
" if(S.CounterInfo[nHoverCounter].firstchild != -1)\n"
6201
" {\n"
6202
" S.CounterInfo[nHoverCounter].closed = !S.CounterInfo[nHoverCounter].closed;\n"
6203
" }\n"
6204
" else\n"
6205
" {\n"
6206
" S.CounterInfo[nHoverCounter].Expanded = !S.CounterInfo[nHoverCounter].Expanded;\n"
6207
" }\n"
6208
" Draw(1);\n"
6209
" }\n"
6210
" }\n"
6211
" else if(Mode == ModeDetailed && FilterSearchSelection >= 0)\n"
6212
" {\n"
6213
" FilterInputCommit();\n"
6214
" }\n"
6215
" else\n"
6216
" {\n"
6217
" if(DetailedMouseEvent)\n"
6218
" {\n"
6219
" DetailedMouseEvent.E();\n"
6220
" }\n"
6221
" else if(!DetailedMouseOverButton)\n"
6222
" {\n"
6223
" ZoomToHighlight();\n"
6224
" }\n"
6225
" }\n"
6226
" }\n"
6227
" else if(MouseDragTarget == CanvasHistory)\n"
6228
" {\n"
6229
" if(Mode == ModeDetailed)\n"
6230
" {\n"
6231
" ZoomToHighlight(1);\n"
6232
" }\n"
6233
" }\n"
6234
"}\n"
6235
"\n"
6236
"function MapMouseButton(event)\n"
6237
"{\n"
6238
" if(event.button == 1 || event.which == 1)\n"
6239
" {\n"
6240
" return 1;\n"
6241
" }\n"
6242
" else if(event.button == 3 || event.which == 3)\n"
6243
" {\n"
6244
" return 3;\n"
6245
" }\n"
6246
" else\n"
6247
" {\n"
6248
" return 0;\n"
6249
" }\n"
6250
"}\n"
6251
"\n"
6252
"function MouseDragIsActive()\n"
6253
"{\n"
6254
" return MouseDragState != MouseDragOff && MouseDragState != MouseDragDown;\n"
6255
"}\n"
6256
"function MouseDragReset()\n"
6257
"{\n"
6258
" MouseDragState = MouseDragOff;\n"
6259
" MouseDragTarget = 0;\n"
6260
" MouseDragKeyShift = 0;\n"
6261
" MouseDragKeyCtrl = 0;\n"
6262
" MouseDragKeyAlt = 0;\n"
6263
" MouseDragButton = 0;\n"
6264
"}\n"
6265
"function MouseDragKeyUp()\n"
6266
"{\n"
6267
" if((MouseDragKeyShift && !KeyShiftDown) || (MouseDragKeyCtrl && !KeyCtrlDown) || (MouseDragKeyAlt && !KeyAltDown) || SubMenuActive != -1)\n"
6268
" {\n"
6269
" MouseHandleDragEnd();\n"
6270
" MouseDragReset();\n"
6271
" }\n"
6272
"}\n"
6273
"function MouseDrag(Source, Event)\n"
6274
"{\n"
6275
" if(Source == MouseDragOff || (MouseDragTarget && MouseDragTarget != Event.target) || SubMenuActive != -1)\n"
6276
" {\n"
6277
" MouseDragReset();\n"
6278
" return;\n"
6279
" }\n"
6280
" var LocalRect = Event.target.getBoundingClientRect();\n"
6281
" MouseDragX = Event.clientX - LocalRect.left;\n"
6282
" MouseDragY = Event.clientY - LocalRect.top;\n"
6283
" if(MouseDragState == MouseDragMove)\n"
6284
" {\n"
6285
" var dx = Math.abs(MouseDragX - MouseDragXStart);\n"
6286
" var dy = Math.abs(MouseDragY - MouseDragYStart);\n"
6287
" if((Source == MouseDragUp && MapMouseButton(Event) == MouseDragButton) ||\n"
6288
" (MouseDragKeyCtrl && !KeyCtrlDown) ||\n"
6289
" (MouseDragKeyShift && !KeyShiftDown) ||\n"
6290
" (MouseDragKeyAlt && !KeyAltDown))\n"
6291
" {\n"
6292
" MouseHandleDragEnd();\n"
6293
" MouseDragReset();\n"
6294
" return;\n"
6295
" }\n"
6296
" else\n"
6297
" {\n"
6298
" MouseHandleDrag();\n"
6299
" }\n"
6300
" }\n"
6301
" else if(MouseDragState == MouseDragOff)\n"
6302
" {\n"
6303
" if(Source == MouseDragDown || KeyShiftDown || KeyCtrlDown|| KeyAltDown)\n"
6304
" {\n"
6305
" MouseDragTarget = Event.target;\n"
6306
" MouseDragButton = MapMouseButton(Event);\n"
6307
" MouseDragState = MouseDragDown;\n"
6308
" MouseDragXStart = MouseDragX;\n"
6309
" MouseDragYStart = MouseDragY;\n"
6310
" MouseDragKeyCtrl = 0;\n"
6311
" MouseDragKeyShift = 0;\n"
6312
" MouseDragKeyAlt = 0;\n"
6313
"\n"
6314
" if(KeyShiftDown || KeyCtrlDown || KeyAltDown)\n"
6315
" {\n"
6316
" MouseDragKeyAlt = KeyAltDown;\n"
6317
" MouseDragKeyShift = KeyShiftDown;\n"
6318
" MouseDragKeyCtrl = KeyCtrlDown;\n"
6319
" MouseDragState = MouseDragMove;\n"
6320
" }\n"
6321
" }\n"
6322
" }\n"
6323
" else if(MouseDragState == MouseDragDown)\n"
6324
" {\n"
6325
" if(Source == MouseDragUp)\n"
6326
" {\n"
6327
" MouseHandleDragClick();\n"
6328
" MouseDragReset();\n"
6329
" }\n"
6330
" else if(Source == MouseDragMove)\n"
6331
" {\n"
6332
" var dx = Math.abs(MouseDragX - MouseDragXStart);\n"
6333
" var dy = Math.abs(MouseDragY - MouseDragYStart);\n"
6334
" if(dx+dy>1)\n"
6335
" {\n"
6336
" MouseDragState = MouseDragMove;\n"
6337
" }\n"
6338
" }\n"
6339
" }\n"
6340
" MouseDragXLast = MouseDragX;\n"
6341
" MouseDragYLast = MouseDragY;\n"
6342
"}\n"
6343
"\n"
6344
"function MouseMove(evt)\n"
6345
"{\n"
6346
" evt.preventDefault();\n"
6347
" KeyCtrlDown = evt.ctrlKey;\n"
6348
" KeyShiftDown = evt.shiftKey;\n"
6349
" KeyAltDown = evt.altKey;\n"
6350
" ZoomActive = 0;\n"
6351
" MouseDrag(MouseDragMove, evt);\n"
6352
" MouseHistory = 0;\n"
6353
" MouseDetailed = 0;\n"
6354
" HistoryViewMouseX = HistoryViewMouseY = -1;\n"
6355
" let rect = evt.target.getBoundingClientRect();\n"
6356
" let x = evt.clientX - rect.left;\n"
6357
" let y = evt.clientY - rect.top;\n"
6358
" GlobalMouseX = evt.pageX;\n"
6359
" GlobalMouseY = evt.pageY;\n"
6360
" if(evt.target == CanvasDetailedView)\n"
6361
" {\n"
6362
" if(!MouseDragSelectRange())\n"
6363
" {\n"
6364
" RangeCpu = RangeInit();\n"
6365
" }\n"
6366
" DetailedViewMouseX = x;\n"
6367
" DetailedViewMouseY = y;\n"
6368
" }\n"
6369
" else if(evt.target = CanvasHistory)\n"
6370
" {\n"
6371
" HistoryViewMouseX = x;\n"
6372
" HistoryViewMouseY = y;\n"
6373
"\n"
6374
" DetailedViewMouseX = -1;\n"
6375
" DetailedViewMouseY = -1;\n"
6376
"\n"
6377
" }\n"
6378
" RequestRedraw();\n"
6379
"}\n"
6380
"\n"
6381
"function MouseSortClick()\n"
6382
"{\n"
6383
" if(SortColumnMouseOverNext)\n"
6384
" {\n"
6385
" if(SortColumnMouseOverNext == SortColumnMouseOver)\n"
6386
" {\n"
6387
" SortColumnOrderFlip = 1 - SortColumnOrderFlip;\n"
6388
" }\n"
6389
" else\n"
6390
" {\n"
6391
" SortColumnOrderFlip = 0;\n"
6392
" }\n"
6393
"\n"
6394
" SortColumnMouseOver = SortColumnMouseOverNext;\n"
6395
" SortColumnMouseOverNext = null;\n"
6396
" if(SortColumnMouseOver == StrAverage)\n"
6397
" {\n"
6398
" SortColumn = 1;\n"
6399
" }\n"
6400
" else if(SortColumnMouseOver == StrMax)\n"
6401
" {\n"
6402
" SortColumn = 2;\n"
6403
" }\n"
6404
" else if(SortColumnMouseOver == StrTotal)\n"
6405
" {\n"
6406
" SortColumn = 3;\n"
6407
" }\n"
6408
" else if(SortColumnMouseOver == StrMin)\n"
6409
" {\n"
6410
" SortColumn = 4;\n"
6411
" }\n"
6412
" else if(SortColumnMouseOver == StrSpike)\n"
6413
" {\n"
6414
" SortColumn = 5;\n"
6415
" }\n"
6416
" else if(SortColumnMouseOver == StrCallAverage)\n"
6417
" {\n"
6418
" SortColumn = 6;\n"
6419
" }\n"
6420
" else if(SortColumnMouseOver == StrCount)\n"
6421
" {\n"
6422
" SortColumn = 7;\n"
6423
" }\n"
6424
" else if(SortColumnMouseOver == StrExclAverage)\n"
6425
" {\n"
6426
" SortColumn = 8;\n"
6427
" }\n"
6428
" else if(SortColumnMouseOver == StrExclMax)\n"
6429
" {\n"
6430
" SortColumn = 9;\n"
6431
" }\n"
6432
" else if(SortColumnMouseOver == StrGroup)\n"
6433
" {\n"
6434
" SortColumn = 0;\n"
6435
" }\n"
6436
" RequestRedraw();\n"
6437
" }\n"
6438
"}\n"
6439
"\n"
6440
"function MouseButton(bPressed, evt)\n"
6441
"{\n"
6442
" evt.preventDefault();\n"
6443
" MouseReleased = !bPressed;\n"
6444
" MouseDrag(bPressed ? MouseDragDown : MouseDragUp, evt);\n"
6445
" if(!bPressed && SubMenuActive == -1)\n"
6446
" MouseSortClick();\n"
6447
" RequestRedraw();\n"
6448
"}\n"
6449
"\n"
6450
"function MouseOut(evt)\n"
6451
"{\n"
6452
" MouseDrag(MouseDragOff, evt);\n"
6453
" KeyCtrlDown = 0;\n"
6454
" KeyShiftDown = 0;\n"
6455
" KeyAltDown = 0;\n"
6456
" KeyHDown = 0;\n"
6457
" MouseDragButton = 0;\n"
6458
" nHoverToken = -1;\n"
6459
" RangeCpu = RangeInit();\n"
6460
" RequestRedraw();\n"
6461
"}\n"
6462
"\n"
6463
"function MouseWheel(e)\n"
6464
"{\n"
6465
" var e = window.event || e;\n"
6466
" var delta = (e.wheelDelta || e.detail * (-120));\n"
6467
" ZoomGraph((-4 * delta / 120.0) | 0);\n"
6468
" Draw(1);\n"
6469
"}\n"
6470
"\n"
6471
"function ShowDetailedSearch(bShow)\n"
6472
"{\n"
6473
" if(bShow)\n"
6474
" {\n"
6475
" FilterInputSearch2.style[\'display\'] = \'block\';\n"
6476
" FilterInputSearch2.focus();\n"
6477
" FilterInputSearch2.select();\n"
6478
"\n"
6479
" }\n"
6480
" else\n"
6481
" {\n"
6482
" FilterInputSearch2.style[\'display\'] = \'none\';\n"
6483
" }\n"
6484
"}\n"
6485
"\n"
6486
"function ShowFilterInput(bShow)\n"
6487
"{\n"
6488
" if(bShow)\n"
6489
" {\n"
6490
" document.getElementById(\'filterinput\').style[\'display\'] = \'block\';\n"
6491
" }\n"
6492
" else\n"
6493
" {\n"
6494
" document.getElementById(\'filterinput\').style[\'display\'] = \'none\';\n"
6495
" }\n"
6496
"}\n"
6497
"\n"
6498
"function SetFilterInput(group, timer)\n"
6499
"{\n"
6500
" FilterInputGroupString = group;\n"
6501
" FilterInputTimerString = timer;\n"
6502
" FilterInputGroup.value = group?group:\'\';\n"
6503
" FilterInputTimer.value = timer?timer:\'\';\n"
6504
" FilterUpdate();\n"
6505
" if(group || timer)\n"
6506
" {\n"
6507
" ShowFilterInput(1);\n"
6508
" }\n"
6509
" else\n"
6510
" {\n"
6511
" ShowFilterInput(0);\n"
6512
" }\n"
6513
"\n"
6514
"}\n"
6515
"\n"
6516
"function ToggleFilterInput(escape)\n"
6517
"{\n"
6518
" var ActiveElement = -1;\n"
6519
" for(var i = 0; i < FilterInputArray.length; ++i)\n"
6520
" {\n"
6521
" if(FilterInputArray[i] == document.activeElement)\n"
6522
" {\n"
6523
" ActiveElement = i;\n"
6524
" }\n"
6525
" }\n"
6526
" var OldActiveElement = ActiveElement;\n"
6527
" if(ActiveElement >= 0)\n"
6528
" {\n"
6529
" FilterInputArray[ActiveElement].blur();\n"
6530
" }\n"
6531
" ActiveElement++;\n"
6532
" if(!escape)\n"
6533
" {\n"
6534
" if(ActiveElement < FilterInputArray.length)\n"
6535
" {\n"
6536
" ShowFilterInput(1);\n"
6537
" FilterInputArray[ActiveElement].focus();\n"
6538
" }\n"
6539
" }\n"
6540
" else\n"
6541
" {\n"
6542
" if(-1 == OldActiveElement)\n"
6543
" {\n"
6544
" SetFilterInput();\n"
6545
" }\n"
6546
" }\n"
6547
"}\n"
6548
"\n"
6549
"function KeyUp(evt)\n"
6550
"{\n"
6551
" //console.log(\"keyup \", evt.keyCode);\n"
6552
" if(evt.keyCode == 18)\n"
6553
" {\n"
6554
" ToolTipFlip = 0;\n"
6555
" }\n"
6556
" if(!FilterSearchActive && !IgnoreInput && SubMenuActive == -1)\n"
6557
" {\n"
6558
" if(evt.keyCode == 112)\n"
6559
" {\n"
6560
" ShowHelp(1, 0);\n"
6561
" }\n"
6562
" if(evt.keyCode == 39)\n"
6563
" {\n"
6564
" MoveToNext(1);\n"
6565
" }\n"
6566
" if(evt.keyCode == 37)\n"
6567
" {\n"
6568
" MoveToNext(-1);\n"
6569
" }\n"
6570
" if(evt.keyCode == 90)\n"
6571
" {\n"
6572
" ToolTipCorner = 1-ToolTipCorner;\n"
6573
" }\n"
6574
" if(evt.keyCode == 187)\n"
6575
" {\n"
6576
" DrawDetailedFlameMode = (DrawDetailedFlameMode+1) % 3;\n"
6577
" FilterSearchReset();\n"
6578
" }\n"
6579
" if(evt.keyCode == 189)\n"
6580
" {\n"
6581
" DrawDetailedCompareReverse = 1-DrawDetailedCompareReverse;\n"
6582
" FilterSearchReset();\n"
6583
" }\n"
6584
" if(evt.keyCode == 32)\n"
6585
" {\n"
6586
" if(RangeSelect.Begin < RangeSelect.End)\n"
6587
" {\n"
6588
" ZoomToRange(RangeSelect);\n"
6589
" RangeSelect = RangeInit();\n"
6590
" MouseHandleDragEnd();\n"
6591
" }\n"
6592
" }\n"
6593
" if(evt.keyCode == 192)\n"
6594
" {\n"
6595
" if(Mode == ModeDetailed)\n"
6596
" {\n"
6597
" ShowDetailedSearch(true);\n"
6598
" }\n"
6599
" else if(Mode == ModeTimers || Mode == ModeTimers_Threads || Mode == ModeTimers_Groups)\n"
6600
" {\n"
6601
" ToggleFilterInput(0);\n"
6602
" evt.preventDefault();\n"
6603
" }\n"
6604
" }\n"
6605
" if(evt.keyCode == 9)\n"
6606
" {\n"
6607
" evt.preventDefault();\n"
6608
" if(Mode == ModeDetailed)\n"
6609
" {\n"
6610
" let Token = nHoverToken;\n"
6611
" if(Token == -1 && RangeValid(RangeSelect) && RangeSelect.Index >= 0)\n"
6612
" {\n"
6613
" Token = RangeSelect.Index;\n"
6614
" }\n"
6615
" if(Token != -1)\n"
6616
" {\n"
6617
" let Source = HoverTokenOwner ? HoverTokenOwner : S;\n"
6618
" if(Token < Source.TimerInfo.length)\n"
6619
" {\n"
6620
" let start = Source.TimerInfo[Token].worststart;\n"
6621
" let end = Source.TimerInfo[Token].worstend;\n"
6622
" RangeSelect.Begin = start;\n"
6623
" RangeSelect.End = end;\n"
6624
" RangeSelect.Thread = Source.TimerInfo[Token].worstthread;\n"
6625
" RangeSelect.Index = Token;\n"
6626
" RangeSelect.Second = Source == S2 ? 1 : 0;\n"
6627
" ShowFlashMessage(\'Worst: \' + (end-start).toFixed(2) + \'ms\', 100);\n"
6628
" let Offset = Source == S2 ? -fDetailedOffsetSecond : 0;\n"
6629
" MoveTo(RangeSelect.Begin + Offset, RangeSelect.End + Offset, ThreadYBegin[RangeSelect.Thread] + nOffsetY, ThreadYEnd[RangeSelect.Thread+1] + nOffsetY);\n"
6630
" MouseHandleDragEnd();\n"
6631
" }\n"
6632
" }\n"
6633
"\n"
6634
" }\n"
6635
" else if(Mode == ModeTimers || Mode == ModeTimers_Threads || Mode == ModeTimers_Groups)\n"
6636
" {\n"
6637
" ToggleFilterInput(0);\n"
6638
" evt.preventDefault();\n"
6639
" }\n"
6640
"\n"
6641
" }\n"
6642
" if(evt.keyCode == 88)\n"
6643
" {\n"
6644
" ToggleMode();\n"
6645
" }\n"
6646
" if(evt.keyCode == 220 && Mode == ModeDetailed)\n"
6647
" {\n"
6648
" ToggleGroupColors(true);\n"
6649
" }\n"
6650
" if(evt.keyCode == 67 && Mode == ModeDetailed)\n"
6651
" {\n"
6652
" HideMode = HideMode == HideModeCollapsed ? HideModeFullyHidden : HideModeCollapsed;\n"
6653
" RequestRedraw();\n"
6654
" Invalidate = 0;\n"
6655
" }\n"
6656
" }\n"
6657
" if(evt.keyCode == 18)\n"
6658
" {\n"
6659
" KeyAltDown = 0;\n"
6660
" MouseDragKeyUp();\n"
6661
" }\n"
6662
" else if(evt.keyCode == 17)\n"
6663
" {\n"
6664
" KeyCtrlDown = 0;\n"
6665
" MouseDragKeyUp();\n"
6666
" }\n"
6667
" else if(evt.keyCode == 16)\n"
6668
" {\n"
6669
" KeyShiftDown = 0;\n"
6670
" MouseDragKeyUp();\n"
6671
" }\n"
6672
"\n"
6673
" if(evt.keyCode == 72)\n"
6674
" {\n"
6675
" KeyHDown = 0;\n"
6676
" RequestRedraw();\n"
6677
" }\n"
6678
"\n"
6679
"\n"
6680
" if(evt.keyCode == 27)\n"
6681
" {\n"
6682
" if(Mode == ModeDetailed)\n"
6683
" {\n"
6684
" let SearchString = FilterInputSearch2.value;\n"
6685
" if(document.activeElement == FilterInputSearch2)\n"
6686
" {\n"
6687
" document.activeElement.blur();\n"
6688
" if(!SearchString.length)\n"
6689
" ShowDetailedSearch(false);\n"
6690
" }\n"
6691
" else if(SearchString.length > 0)\n"
6692
" {\n"
6693
" //when search is active, esc clears in the following order:\n"
6694
" //focus from search\n"
6695
" //clears active range\n"
6696
" //clears search\n"
6697
" if(RangeValid(RangeSelect))\n"
6698
" {\n"
6699
" RangeSelect = RangeInit();\n"
6700
" }\n"
6701
" else\n"
6702
" {\n"
6703
" FilterInputSearch2.value = \"\";\n"
6704
" ShowDetailedSearch(false);\n"
6705
" }\n"
6706
" }\n"
6707
" else\n"
6708
" {\n"
6709
" RangeSelect = RangeInit();\n"
6710
" }\n"
6711
" }\n"
6712
"\n"
6713
" SortColumn = 0;\n"
6714
" SortColumnMouseOver = \"\";\n"
6715
" if(Mode == ModeTimers || Mode == ModeTimers_Threads || Mode == ModeTimers_Groups)\n"
6716
" {\n"
6717
" ToggleFilterInput(1);\n"
6718
" evt.preventDefault();\n"
6719
" }\n"
6720
" if(SubMenuActive != -1)\n"
6721
" {\n"
6722
" if(FilterInputMenu.value.trim() != \"\")\n"
6723
" {\n"
6724
" FilterInputMenu.value = \"\";\n"
6725
" }\n"
6726
" else\n"
6727
" {\n"
6728
" EnableMenu(-1);\n"
6729
" }\n"
6730
" }\n"
6731
"\n"
6732
" if(FilterSearchActive)\n"
6733
" {\n"
6734
" if(FilterInput.value != \'\')\n"
6735
" {\n"
6736
" FilterInput.value = \'\';\n"
6737
" }\n"
6738
" else\n"
6739
" {\n"
6740
" FilterInputHide();\n"
6741
" }\n"
6742
" }\n"
6743
" else\n"
6744
" {\n"
6745
" FilterSearchReset();\n"
6746
" }\n"
6747
" }\n"
6748
"\n"
6749
"\n"
6750
" if(evt.keyCode == 13 && !IgnoreInput)\n"
6751
" {\n"
6752
" if(FilterSearchActive)\n"
6753
" {\n"
6754
" FilterInputCommit();\n"
6755
" }\n"
6756
" else\n"
6757
" {\n"
6758
" FilterInputShow();\n"
6759
" }\n"
6760
" }\n"
6761
" RequestRedraw();\n"
6762
" Invalidate = 0;\n"
6763
"}\n"
6764
"function FilterInputUpdate()\n"
6765
"{\n"
6766
" Invalidate = 0;\n"
6767
" if(FilterSearchActive == 1)\n"
6768
" {\n"
6769
" FilterInputDiv.style[\'display\'] = \'inline\';\n"
6770
" FilterInput.focus();\n"
6771
" }\n"
6772
" else\n"
6773
" {\n"
6774
" FilterSearchSelection = -1;\n"
6775
" FilterInputDiv.style[\'display\'] = \'none\';\n"
6776
" }\n"
6777
"}\n"
6778
"function FilterInputShow()\n"
6779
"{\n"
6780
" // FilterSearchActive = 1;\n"
6781
" // FilterInputUpdate();\n"
6782
" // RequestRedraw();\n"
6783
"}\n"
6784
"function FilterInputHide()\n"
6785
"{\n"
6786
" FilterSearchActive = 0;\n"
6787
" FilterInputUpdate();\n"
6788
"}\n"
6789
"\n"
6790
"function FilterInputCommit()\n"
6791
"{\n"
6792
" if(FilterSearchSelection >= 0)\n"
6793
" {\n"
6794
" FilterSearchReset();\n"
6795
" FilterSearchPassIndex = FilterSearchSelection;\n"
6796
" FilterSearchStartTime = new Date();\n"
6797
" }\n"
6798
" FilterInputHide();\n"
6799
"}\n"
6800
"function FilterSearchReset()\n"
6801
"{\n"
6802
" FilterSearchArray = new Array();\n"
6803
"}\n"
6804
"function CreateFilter(Filter)\n"
6805
"{\n"
6806
" if(!Filter || Filter.length == 0)\n"
6807
" {\n"
6808
" return null;\n"
6809
" }\n"
6810
" Filter = Filter.split(\' \');\n"
6811
"\n"
6812
" var regexp = \"\";\n"
6813
" for(var i = 0; i < Filter.length; ++i)\n"
6814
" {\n"
6815
" regexp = regexp + \".*\" + Filter[i];\n"
6816
" }\n"
6817
" Filter = new Array();\n"
6818
" regexp = regexp + \".*\";\n"
6819
" Filter.push(new RegExp(regexp, \"i\"));\n"
6820
" return Filter;\n"
6821
"}\n"
6822
"function FilterKeyUp()\n"
6823
"{\n"
6824
" FilterInputTimerString = FilterInputTimer.value;\n"
6825
" FilterInputGroupString = FilterInputGroup.value;\n"
6826
" FilterUpdate();\n"
6827
"}\n"
6828
"\n"
6829
"function FilterUpdate()\n"
6830
"{\n"
6831
" FilterTimer = CreateFilter(FilterInputTimerString);\n"
6832
" FilterGroup = CreateFilter(FilterInputGroupString);\n"
6833
"}\n"
6834
"\n"
6835
"function KeyDown(evt)\n"
6836
"{\n"
6837
" //console.log(\"keydown \", evt.keyCode);\n"
6838
" if(evt.keyCode == 18)\n"
6839
" {\n"
6840
" KeyAltDown = 1;\n"
6841
" }\n"
6842
" else if(evt.keyCode == 17)\n"
6843
" {\n"
6844
" KeyCtrlDown = 1;\n"
6845
" }\n"
6846
" else if(evt.keyCode == 16)\n"
6847
" {\n"
6848
" KeyShiftDown = 1;\n"
6849
" }\n"
6850
" else if(evt.keyCode == 9)\n"
6851
" {\n"
6852
" evt.preventDefault();\n"
6853
" }\n"
6854
" else if(evt.keyCode == 13)\n"
6855
" {\n"
6856
" evt.preventDefault();\n"
6857
" }\n"
6858
" else if(evt.keyCode == 91) // z/tab to toggle tooltip\n"
6859
" {\n"
6860
" ToolTipFlip = 1;\n"
6861
" }\n"
6862
" else if(evt.keyCode == 70)\n"
6863
" {\n"
6864
" if(evt.ctrlKey)\n"
6865
" {\n"
6866
" evt.preventDefault();\n"
6867
" if(Mode == ModeDetailed)\n"
6868
" ShowDetailedSearch(true);\n"
6869
" }\n"
6870
" }else if(evt.keyCode == 72)\n"
6871
" {\n"
6872
" KeyHDown = 1;\n"
6873
" RequestRedraw();\n"
6874
" }\n"
6875
"\n"
6876
"\n"
6877
" Invalidate = 0;\n"
6878
"}\n"
6879
"function ParseCookie(str)\n"
6880
"{\n"
6881
" if(!str) return null;\n"
6882
" var result = str.match(/fisk=([^;]+)/);\n"
6883
" // console.log(\"cookie is \" + str);\n"
6884
" if(result && result.length > 0)\n"
6885
" {\n"
6886
" var Obj = JSON.parse(result[1]);\n"
6887
" if(!Obj.offline)\n"
6888
" {\n"
6889
" var C = {};\n"
6890
" C.offline = Obj;\n"
6891
" Obj = C;\n"
6892
" }\n"
6893
" return Obj;\n"
6894
" }\n"
6895
" return null;\n"
6896
"}\n"
6897
"\n"
6898
"function GetCookie()\n"
6899
"{\n"
6900
" var Obj = ParseCookie(localStorage.getItem(\"microprofile_fisk\"));\n"
6901
" if(!Obj)\n"
6902
" {\n"
6903
" Obj = ParseCookie(document.cookie);\n"
6904
" }\n"
6905
" if(!Obj)\n"
6906
" {\n"
6907
" return {offline:{},live:{}};\n"
6908
" }\n"
6909
" return Obj;\n"
6910
"}\n"
6911
"\n"
6912
"function ReadCookie()\n"
6913
"{\n"
6914
" var C = GetCookie();\n"
6915
" var NewMode = ModeDetailed;\n"
6916
" if(C.offline)\n"
6917
" {\n"
6918
" var Obj = C.offline;\n"
6919
" if(Obj.Mode)\n"
6920
" {\n"
6921
" NewMode = Obj.ModeX;\n"
6922
" }\n"
6923
" if(Obj.ReferenceTimeString)\n"
6924
" {\n"
6925
" ReferenceTimeString = Obj.ReferenceTimeString;\n"
6926
" }\n"
6927
" if(Obj.TargetTimeString)\n"
6928
" {\n"
6929
" TargetTimeString = Obj.TargetTimeString;\n"
6930
" }\n"
6931
" if(Obj.ThreadsHidden)\n"
6932
" {\n"
6933
" ThreadsHidden = Obj.ThreadsHidden;\n"
6934
" }\n"
6935
" if(Obj.GroupsAllActive || Obj.GroupsAllActive == 0 || Obj.GroupsAllActive)\n"
6936
" {\n"
6937
" GroupsAllActive = Obj.GroupsAllActive;\n"
6938
" }\n"
6939
" else\n"
6940
" {\n"
6941
" GroupsAllActive = 1;\n"
6942
" }\n"
6943
" if(Obj.GroupsDisabled)\n"
6944
" {\n"
6945
" GroupsDisabled = Obj.GroupsDisabled;\n"
6946
" }\n"
6947
" if(Obj.nContextSwitchEnabled)\n"
6948
" {\n"
6949
" nContextSwitchEnabled = Obj.nContextSwitchEnabled;\n"
6950
" }\n"
6951
" else\n"
6952
" {\n"
6953
" nContextSwitchEnabled = 1;\n"
6954
" }\n"
6955
" if(Obj.GroupColors)\n"
6956
" {\n"
6957
" GroupColors = Obj.GroupColors;\n"
6958
" }\n"
6959
" else\n"
6960
" {\n"
6961
" GroupColors = 0;\n"
6962
" }\n"
6963
" if(Obj.nHideHelp)\n"
6964
" {\n"
6965
" nHideHelp = 1;\n"
6966
" }\n"
6967
" if(Obj.ColumnsEnabled)\n"
6968
" {\n"
6969
" ColumnsEnabled = Obj.ColumnsEnabled;\n"
6970
" }\n"
6971
" if(Obj.ToolTipCorner)\n"
6972
" {\n"
6973
" ToolTipCorner = Obj.ToolTipCorner;\n"
6974
" }\n"
6975
" if(Obj.DrawDetailedFlameMode)\n"
6976
" {\n"
6977
" DrawDetailedFlameMode = Obj.DrawDetailedFlameMode;\n"
6978
" }\n"
6979
" if(Obj.DrawDetailedCompareReverse)\n"
6980
" {\n"
6981
" DrawDetailedCompareReverse = Obj.DrawDetailedCompareReverse;\n"
6982
" }\n"
6983
" if(Obj.ThreadOrderNames)\n"
6984
" {\n"
6985
" ThreadOrderNames = Obj.ThreadOrderNames;\n"
6986
" }\n"
6987
" if(Obj.ThreadLogAutoHide)\n"
6988
" {\n"
6989
" ThreadLogAutoHide = Obj.ThreadLogAutoHide;\n"
6990
" }\n"
6991
" if(Obj.DrawDetailedNewDraw)\n"
6992
" {\n"
6993
" DrawDetailedNewDraw = Obj.DrawDetailedNewDraw;\n"
6994
" }\n"
6995
"\n"
6996
" }\n"
6997
" SetContextSwitch(nContextSwitchEnabled);\n"
6998
" SetMode(NewMode);\n"
6999
" SetReferenceTime(ReferenceTimeString);\n"
7000
" SetTargetTime(TargetTimeString);\n"
7001
" UpdateGroupColors();\n"
7002
" UpdateThreadLogAutoHide();\n"
7003
"}\n"
7004
"function WriteCookie()\n"
7005
"{\n"
7006
" var C = GetCookie();\n"
7007
" var Obj = new Object();\n"
7008
" Obj.ModeX = Mode;\n"
7009
" Obj.ReferenceTimeString = ReferenceTimeString;\n"
7010
" Obj.TargetTimeString = TargetTimeString;\n"
7011
" Obj.ThreadsHidden = ThreadsHidden;\n"
7012
" Obj.GroupsDisabled = GroupsDisabled;\n"
7013
" Obj.GroupsAllActive = GroupsAllActive;\n"
7014
" Obj.nContextSwitchEnabled = nContextSwitchEnabled;\n"
7015
" Obj.GroupColors = GroupColors;\n"
7016
" Obj.ColumnsEnabled = ColumnsEnabled;\n"
7017
" Obj.ToolTipCorner = ToolTipCorner;\n"
7018
" Obj.DrawDetailedFlameMode = DrawDetailedFlameMode;\n"
7019
" Obj.DrawDetailedCompareReverse = DrawDetailedCompareReverse;\n"
7020
" Obj.ThreadOrderNames = ThreadOrderNames;\n"
7021
" Obj.ThreadLogAutoHide = ThreadLogAutoHide;\n"
7022
" Obj.DrawDetailedNewDraw = DrawDetailedNewDraw;\n"
7023
" if(nHideHelp)\n"
7024
" {\n"
7025
" Obj.nHideHelp = 1;\n"
7026
" }\n"
7027
" C.offline = Obj;\n"
7028
" var date = new Date();\n"
7029
" date.setFullYear(2099);\n"
7030
" var cookie = \'fisk=\' + JSON.stringify(C) + \';expires=\' + date;\n"
7031
" document.cookie = cookie;\n"
7032
" localStorage.setItem(\"microprofile_fisk\", cookie);\n"
7033
"}\n"
7034
"\n"
7035
"function WindowRect(x,y,w,h)\n"
7036
"{\n"
7037
" var s = {};\n"
7038
" s.x = x;\n"
7039
" s.y = y;\n"
7040
" s.w = w;\n"
7041
" s.h = h;\n"
7042
" return s;\n"
7043
"}\n"
7044
"\n"
7045
"function MenuSize(w)\n"
7046
"{\n"
7047
" return WindowRect(nWidth / 2 - w / 2, 5, w, nHeight);\n"
7048
"}\n"
7049
"\n"
7050
"function TimerMenuSize()\n"
7051
"{\n"
7052
" return MenuSize(200 + 5 + FontWidth); //fix menu size\n"
7053
"}\n"
7054
"\n"
7055
"function DrawFilterSearch()\n"
7056
"{\n"
7057
" FilterSearchSelection = -1;\n"
7058
" FilterSearchPassIndex = -1;\n"
7059
" FilterSearchSelectionMax = 0;\n"
7060
" if(!FilterSearchActive)\n"
7061
" return;\n"
7062
" nHoverToken = -1;\n"
7063
"\n"
7064
" if(FilterInputSearchLast != FilterInput.value)\n"
7065
" {\n"
7066
" nOffsetFilterSearch = 0;\n"
7067
" }\n"
7068
" FilterInputSearchLast = FilterInput.value;\n"
7069
"\n"
7070
" var FilterArray = CreateFilter(FilterInput.value);\n"
7071
" var context = CanvasDetailedView.getContext(\'2d\');\n"
7072
" var nColorIndex = 0;\n"
7073
" var SizeInfo = TimerMenuSize();\n"
7074
" var Y = SizeInfo.y;\n"
7075
" var Width = S.TimerNameWidth + S.GroupNameWidth;\n"
7076
" SizeInfo.w = Width;\n"
7077
" var X = SizeInfo.x;\n"
7078
"\n"
7079
" MoveFilterInputDiv(SizeInfo.x, SizeInfo.y, SizeInfo.w);\n"
7080
" var YStart = Y;\n"
7081
" Y += 35; //todo: measure somehow?\n"
7082
" var MouseX = DetailedViewMouseX;\n"
7083
" var MouseY = DetailedViewMouseY;\n"
7084
"\n"
7085
" Y -= nOffsetFilterSearch;\n"
7086
" var Count = 0;\n"
7087
" for(var i = 0; i < S.TimerInfo.length; ++i)\n"
7088
" {\n"
7089
" var v = S.TimerInfo[i];\n"
7090
" {\n"
7091
" var Name = v.name;\n"
7092
" var ParentName = S.GroupInfo[v.group].name;\n"
7093
" if(FilterMatch(FilterArray, ParentName + \" \" + Name))\n"
7094
" {\n"
7095
" if(Y >= YStart)\n"
7096
" {\n"
7097
" Count++;\n"
7098
" var ParentName = S.GroupInfo[v.group].name;\n"
7099
" var ParentColor = \'white\';\n"
7100
" var bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight;\n"
7101
" var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
7102
" var TextY = Y+BoxHeight-FontAscent;\n"
7103
" context.fillStyle = bgcolor;\n"
7104
" context.fillRect(X, Y, Width, BoxHeight);\n"
7105
" context.fillStyle = ParentColor;\n"
7106
" context.fillText(ParentName, X + 2, TextY);\n"
7107
" context.fillStyle = g_Colors[v.cid];\n"
7108
" context.textAlign = \'right\';\n"
7109
" context.fillText(Name, X + Width - 2, TextY);\n"
7110
" context.textAlign = \'left\';\n"
7111
" if(bMouseIn)\n"
7112
" {\n"
7113
" FilterSearchSelection = i;\n"
7114
" }\n"
7115
" }\n"
7116
" Y += BoxHeight;\n"
7117
" if(Y > nHeight)\n"
7118
" break;\n"
7119
" nColorIndex = 1-nColorIndex;\n"
7120
" }\n"
7121
" }\n"
7122
" }\n"
7123
" FilterSearchSelectionMax = Count;\n"
7124
" SizeInfo.h = Y-SizeInfo.y;\n"
7125
" RequestRedraw();\n"
7126
" return SizeInfo;\n"
7127
"}\n"
7128
"\n"
7129
"function CalcAverage()\n"
7130
"{\n"
7131
" var Sum = 0;\n"
7132
" var Count = 0;\n"
7133
" for(nLog = 0; nLog < nNumLogs; nLog++)\n"
7134
" {\n"
7135
" StackPos = 0;\n"
7136
" for(var i = 0; i < S.Frames.length; i++)\n"
7137
" {\n"
7138
" var Frame_ = S.Frames[i];\n"
7139
" var tt = Frame_.tt[nLog];\n"
7140
" var ts = Frame_.ts[nLog];\n"
7141
"\n"
7142
" var count = tt.length;\n"
7143
" for(var j = 0; j < count; j++)\n"
7144
" {\n"
7145
" var type ";
7146
7147
const size_t g_MicroProfileHtml_end_4_size = sizeof(g_MicroProfileHtml_end_4);
7148
const char g_MicroProfileHtml_end_5[] =
7149
"= tt[j];\n"
7150
" var time = ts[j];\n"
7151
" if(type == 1)\n"
7152
" {\n"
7153
" Stack[StackPos] = time;//store the frame which it comes from\n"
7154
" StackPos++;\n"
7155
" }\n"
7156
" else if(type == 0)\n"
7157
" {\n"
7158
" if(StackPos>0)\n"
7159
" {\n"
7160
"\n"
7161
" StackPos--;\n"
7162
" var localtime = time - Stack[StackPos];\n"
7163
" Count++;\n"
7164
" Sum += localtime;\n"
7165
" }\n"
7166
" }\n"
7167
" }\n"
7168
" }\n"
7169
" }\n"
7170
" return Sum / Count;\n"
7171
"\n"
7172
"}\n"
7173
"\n"
7174
"function CheckExtType(value, Checked)\n"
7175
"{\n"
7176
" if((value&3) != 3)\n"
7177
" return false;\n"
7178
" return (value >> 2) == Checked;\n"
7179
"\n"
7180
"}\n"
7181
"\n"
7182
"function MakeLod(index, MinDelta, TimeArray, TypeArray, IndexArray, LogStart)\n"
7183
"{\n"
7184
" if(S.LodData[index])\n"
7185
" {\n"
7186
" console.log(\"error!!\");\n"
7187
" }\n"
7188
" var o = new Object();\n"
7189
" o.MinDelta = MinDelta;\n"
7190
" o.TimeArray = TimeArray;\n"
7191
" o.TypeArray = TypeArray;\n"
7192
" o.IndexArray = IndexArray;\n"
7193
" o.LogStart = LogStart;\n"
7194
" S.LodData[index] = o;\n"
7195
"}\n"
7196
"\n"
7197
"function PreprocessBuildSplitArray()\n"
7198
"{\n"
7199
" var nNumLogs = S.Frames[0].ts.length;\n"
7200
"\n"
7201
" ProfileEnter(\"PreprocessBuildSplitArray\");\n"
7202
" var SplitArrays = new Array(nNumLogs);\n"
7203
"\n"
7204
" for(nLog = 0; nLog < nNumLogs; ++nLog)\n"
7205
" {\n"
7206
" console.log(\"source log \" + nLog + \" size \" + S.LodData[0].TypeArray[nLog].length);\n"
7207
" }\n"
7208
"\n"
7209
"\n"
7210
" for(nLog = 0; nLog < nNumLogs; nLog++)\n"
7211
" {\n"
7212
" var MaxDepth = 1;\n"
7213
" var StackPos = 0;\n"
7214
" var Stack = Array(20);\n"
7215
" var TypeArray = S.LodData[0].TypeArray[nLog];\n"
7216
" var TimeArray = S.LodData[0].TimeArray[nLog];\n"
7217
" var DeltaTimes = new Array(TypeArray.length);\n"
7218
"\n"
7219
" for(var j = 0; j < TypeArray.length; ++j)\n"
7220
" {\n"
7221
" var type = TypeArray[j];\n"
7222
" var time = TimeArray[j];\n"
7223
" if(type == 1)\n"
7224
" {\n"
7225
" //push\n"
7226
" Stack[StackPos] = time;\n"
7227
" StackPos++;\n"
7228
" }\n"
7229
" else if(type == 0)\n"
7230
" {\n"
7231
" if(StackPos>0)\n"
7232
" {\n"
7233
" StackPos--;\n"
7234
" DeltaTimes[j] = time - Stack[StackPos];\n"
7235
" }\n"
7236
" else\n"
7237
" {\n"
7238
" DeltaTimes[j] = 0;\n"
7239
" }\n"
7240
" }\n"
7241
" }\n"
7242
" DeltaTimes.sort(function(a,b){return b-a;});\n"
7243
" var SplitArray = Array(NumLodSplits);\n"
7244
" var SplitIndex = DeltaTimes.length;\n"
7245
"\n"
7246
" var j = 0;\n"
7247
" for(j = 0; j < NumLodSplits; ++j)\n"
7248
" {\n"
7249
" SplitIndex = Math.floor(SplitIndex / 2);\n"
7250
" while(SplitIndex > 0 && !DeltaTimes[SplitIndex])\n"
7251
" {\n"
7252
" SplitIndex--;\n"
7253
" }\n"
7254
" if(SplitIndex < SplitMin)\n"
7255
" {\n"
7256
" break;\n"
7257
" }\n"
7258
" //search.. if 0\n"
7259
" var SplitTime = DeltaTimes[SplitIndex];\n"
7260
" if(SplitTime>=0)\n"
7261
" {\n"
7262
" SplitArray[j] = SplitTime;\n"
7263
" }\n"
7264
" else\n"
7265
" {\n"
7266
" SplitArray[j] = SPLIT_LIMIT;\n"
7267
" }\n"
7268
" if(j>0)\n"
7269
" {\n"
7270
" console.assert(SplitArray[j-1] <= SplitArray[j], \"must be less\");\n"
7271
" }\n"
7272
"\n"
7273
" }\n"
7274
" for(; j < NumLodSplits; ++j)\n"
7275
" {\n"
7276
" SplitArray[j] = SPLIT_LIMIT;\n"
7277
" }\n"
7278
"\n"
7279
"\n"
7280
" SplitArrays[nLog] = SplitArray;\n"
7281
" }\n"
7282
" ProfileLeave();\n"
7283
" return SplitArrays;\n"
7284
"}\n"
7285
"\n"
7286
"function PreprocessBuildDurationArray()\n"
7287
"{\n"
7288
" var nNumLogs = S.Frames[0].ts.length;\n"
7289
" ProfileEnter(\"PreprocessBuildDurationArray\");\n"
7290
" var DurationArrays = new Array(nNumLogs);\n"
7291
" for(nLog = 0; nLog < nNumLogs; ++nLog)\n"
7292
" {\n"
7293
" var MaxDepth = 1;\n"
7294
" var StackPos = 0;\n"
7295
" var Stack = Array(20);\n"
7296
" var StackIndex = Array(20);\n"
7297
" var TypeArray = S.LodData[0].TypeArray[nLog];\n"
7298
" var TimeArray = S.LodData[0].TimeArray[nLog];\n"
7299
" var DurationArray = Array(S.LodData[0].TypeArray[nLog].length);\n"
7300
" for(var j = 0; j < TypeArray.length; ++j)\n"
7301
" {\n"
7302
" var type = TypeArray[j];\n"
7303
" var time = TimeArray[j];\n"
7304
" if(type == 1)\n"
7305
" {\n"
7306
" //push\n"
7307
" Stack[StackPos] = time;\n"
7308
" StackIndex[StackPos] = j;\n"
7309
" StackPos++;\n"
7310
" }\n"
7311
" else if(type == 0)\n"
7312
" {\n"
7313
" if(StackPos>0)\n"
7314
" {\n"
7315
" StackPos--;\n"
7316
" var Duration = time - Stack[StackPos];\n"
7317
" DurationArray[StackIndex[StackPos]] = Duration;\n"
7318
" DurationArray[j] = Duration;\n"
7319
" }\n"
7320
" else\n"
7321
" {\n"
7322
" DurationArray[j] = 0;\n"
7323
" }\n"
7324
" }\n"
7325
" }\n"
7326
" for(var j = 0; j < StackPos; ++j)\n"
7327
" {\n"
7328
" DurationArray[j] = 0;\n"
7329
" }\n"
7330
" DurationArrays[nLog] = DurationArray;\n"
7331
" }\n"
7332
" ProfileLeave();\n"
7333
" return DurationArrays;\n"
7334
"\n"
7335
"}\n"
7336
"function PreprocessLods()\n"
7337
"{\n"
7338
" ProfileEnter(\"PreprocessLods\");\n"
7339
" var nNumLogs = S.Frames[0].ts.length;\n"
7340
" var SplitArrays = PreprocessBuildSplitArray();\n"
7341
" var DurationArrays = PreprocessBuildDurationArray();\n"
7342
" var Source = S.LodData[0];\n"
7343
" var SourceLogStart = Source.LogStart;\n"
7344
" var NumFrames = SourceLogStart.length;\n"
7345
"\n"
7346
" for(var i = 0; i < NumLodSplits-1; ++i)\n"
7347
" {\n"
7348
" var DestLogStart = Array(SourceLogStart.length);\n"
7349
" for(var j = 0; j < DestLogStart.length; ++j)\n"
7350
" {\n"
7351
" DestLogStart[j] = Array(nNumLogs);\n"
7352
" }\n"
7353
" var MinDelta = Array(nNumLogs);\n"
7354
" var TimeArray = Array(nNumLogs);\n"
7355
" var IndexArray = Array(nNumLogs);\n"
7356
" var TypeArray = Array(nNumLogs);\n"
7357
"\n"
7358
"\n"
7359
"\n"
7360
" for(nLog = 0; nLog < nNumLogs; ++nLog)\n"
7361
" {\n"
7362
" var SourceTypeArray = Source.TypeArray[nLog];\n"
7363
" var SourceTimeArray = Source.TimeArray[nLog];\n"
7364
" var SourceIndexArray = Source.IndexArray[nLog];\n"
7365
" var Duration = DurationArrays[nLog];\n"
7366
" console.assert(Duration.length == SourceTypeArray.length, \"must be equal!\");\n"
7367
" var SplitTime = SplitArrays[nLog][i];\n"
7368
"\n"
7369
" MinDelta[nLog] = SplitTime;\n"
7370
" if(SplitTime < SPLIT_LIMIT)\n"
7371
" {\n"
7372
" var SourceCount = SourceTypeArray.length;\n"
7373
" var DestTypeArray = Array();\n"
7374
" var DestTimeArray = Array();\n"
7375
" var DestIndexArray = Array();\n"
7376
" var RemapArray = Array(SourceCount);\n"
7377
" var DiscardLast = 0;\n"
7378
"\n"
7379
" for(var j = 0; j < SourceCount; ++j)\n"
7380
" {\n"
7381
" RemapArray[j] = DestTypeArray.length;\n"
7382
" if(Duration[j] >= SplitTime || ((SourceTypeArray[j]&3) == 3 && 0 == DiscardLast))\n"
7383
" {\n"
7384
" DiscardLast = 0;\n"
7385
" DestTypeArray.push(SourceTypeArray[j]);\n"
7386
" DestTimeArray.push(SourceTimeArray[j]);\n"
7387
" DestIndexArray.push(SourceIndexArray[j]);\n"
7388
" }\n"
7389
" else\n"
7390
" {\n"
7391
" DiscardLast = 1;\n"
7392
" }\n"
7393
" }\n"
7394
" TimeArray[nLog] = DestTimeArray;\n"
7395
" IndexArray[nLog] = DestIndexArray;\n"
7396
" TypeArray[nLog] = DestTypeArray;\n"
7397
" for(var j = 0; j < NumFrames; ++j)\n"
7398
" {\n"
7399
" var OldStart = SourceLogStart[j][nLog];\n"
7400
" var NewStart = RemapArray[OldStart];\n"
7401
" var FrameArray = DestLogStart[j];\n"
7402
" FrameArray[nLog] = NewStart;\n"
7403
" }\n"
7404
" }\n"
7405
" else\n"
7406
" {\n"
7407
"\n"
7408
" for(var j = 0; j < NumFrames; ++j)\n"
7409
" {\n"
7410
" var FrameArray = DestLogStart[j];\n"
7411
"\n"
7412
" FrameArray[nLog] = 0;\n"
7413
" }\n"
7414
"\n"
7415
" }\n"
7416
"\n"
7417
" }\n"
7418
" MakeLod(i+1, MinDelta, TimeArray, TypeArray, IndexArray, DestLogStart);\n"
7419
" }\n"
7420
" ProfileLeave();\n"
7421
"}\n"
7422
"\n"
7423
"\n"
7424
"function HistogramCreate(MaxTime)\n"
7425
"{\n"
7426
" let Histogram = new Object();\n"
7427
" Histogram.MaxTime = MaxTime;\n"
7428
" Histogram.MaxOccurence = 0;\n"
7429
" Histogram.Occurences = new Uint32Array(100);\n"
7430
" return Histogram;\n"
7431
"}\n"
7432
"function HistogramAdd(Histogram, Value)\n"
7433
"{\n"
7434
" if(Value > Histogram.MaxTime)\n"
7435
" debugger;\n"
7436
" let Index = Math.floor(Value / Histogram.MaxTime);\n"
7437
" Index = Math.max(0, Math.min(99, Index));\n"
7438
" Occurrences[Index]++;\n"
7439
" Histogram.MaxOccurence = Math.max(Histogram.MaxOccurence, Occurrences[Index]);\n"
7440
"\n"
7441
"}\n"
7442
"\n"
7443
"function PreprocessLogBarArray()\n"
7444
"{\n"
7445
" ProfileEnter(\"PreprocessLogBarArray\");\n"
7446
"\n"
7447
" let NumLogs = S.NumLogs;\n"
7448
" let Stack = Array(20);\n"
7449
"\n"
7450
" let LogRows = new Array(NumLogs);\n"
7451
" S.LogRows = LogRows;\n"
7452
"\n"
7453
" for(let nLog = 0; nLog < NumLogs; nLog++)\n"
7454
" {\n"
7455
" let MaxStack = S.MaxStack[nLog];\n"
7456
" let SectionColorStack = new Array(MaxStack);\n"
7457
" SectionColorStack[0] = CIDFail;\n"
7458
" let StackPos = 0;\n"
7459
" let SectionColorStackPos = 1;\n"
7460
"\n"
7461
" let Rows = new Array(MaxStack);\n"
7462
" LogRows[nLog] = Rows;\n"
7463
" for(let i = 0; i < MaxStack; ++i)\n"
7464
" {\n"
7465
" Row = new Object();\n"
7466
" //Note; This has always got implied begin / end tied together\n"
7467
" Row.Offset = i;\n"
7468
" Row.Tree = new Array()\n"
7469
" Row.Tree[0] = new Object();\n"
7470
" Row.Tree[0].Source = new Array();\n"
7471
" Row.Tree[0].Index_ = new Array();\n"
7472
" Row.Tree[0].ColorIds_ = new Array();\n"
7473
" Row.Tree[0].Begin_ = new Array();\n"
7474
" Row.Tree[0].Duration_ = new Array();\n"
7475
" Row.Tree[0].MaxDuration_ = new Array();\n"
7476
" Row.Tree[0].SumDuration_ = new Array();\n"
7477
" Row.Tree[0].SectionColor_ = new Array();\n"
7478
" Row.Tree[0].Parent_ = -1;\n"
7479
" Row.Tree[0].Tail = 0;\n"
7480
" Row.Tree[0].Length = 0;\n"
7481
"\n"
7482
" Rows[i] = Row;\n"
7483
" }\n"
7484
" let RootSectionColor = CIDFail;\n"
7485
"\n"
7486
" let SrcTypeArray = S.TypeArray[nLog];\n"
7487
" let SrcTimeArray = S.TimeArray[nLog];\n"
7488
" let SrcIndexArray = S.IndexArray[nLog];\n"
7489
" let len = SrcTypeArray.length;\n"
7490
"\n"
7491
" for(let i = 0; i < len; ++i)\n"
7492
" {\n"
7493
" let type = SrcTypeArray[i];\n"
7494
" let time = SrcTimeArray[i];\n"
7495
" let index = SrcIndexArray[i];\n"
7496
" let skipsection = false;\n"
7497
"\n"
7498
" let TimerInfo = type < 2 ? S.TimerInfo[index] : null;\n"
7499
" if(type == 1)\n"
7500
" {\n"
7501
" let IsSection = TimerInfo.flags & FLAGS_SECTION;\n"
7502
" if(IsSection)\n"
7503
" {\n"
7504
" SectionColorStack[SectionColorStackPos] = TimerInfo.cid;\n"
7505
" SectionColorStackPos++;\n"
7506
" }\n"
7507
" if(!IsSection)\n"
7508
" {\n"
7509
" Stack[StackPos] = i;\n"
7510
" StackPos++;\n"
7511
" }\n"
7512
"\n"
7513
" }\n"
7514
" else if(type == 0)\n"
7515
" {\n"
7516
" let IsSection = TimerInfo.flags & FLAGS_SECTION; \n"
7517
" if(IsSection)\n"
7518
" {\n"
7519
" if(SectionColorStackPos > 1)\n"
7520
" {\n"
7521
" SectionColorStackPos--;\n"
7522
" }\n"
7523
" else\n"
7524
" {\n"
7525
" //debugger;\n"
7526
" // Hitting a close, without a start. tag all previously untagged to belong to this section.\n"
7527
" for(let i = 0; i < MaxStack; ++i)\n"
7528
" {\n"
7529
" let sc = Rows[i].Tree[0].SectionColor_;\n"
7530
" for(let j = 0; j < sc.length; ++j)\n"
7531
" {\n"
7532
" if(sc[j] == CIDFail)\n"
7533
" {\n"
7534
" sc[j] = TimerInfo.cid;\n"
7535
" }\n"
7536
" }\n"
7537
" }\n"
7538
"\n"
7539
" }\n"
7540
"\n"
7541
" }\n"
7542
" if(!IsSection && StackPos > 0)\n"
7543
" {\n"
7544
" StackPos--;\n"
7545
" let stackindex = Stack[StackPos];\n"
7546
" let sectioncolor = SectionColorStack[SectionColorStackPos-1];\n"
7547
" let begintype = SrcTypeArray[stackindex];\n"
7548
" let begintime = SrcTimeArray[stackindex];\n"
7549
" let beginindex = SrcIndexArray[stackindex];\n"
7550
"\n"
7551
" if(type != 0)\n"
7552
" debugger;\n"
7553
" if(begintype != 1)\n"
7554
" debugger;\n"
7555
" if(index != beginindex)\n"
7556
" debugger;\n"
7557
" if(StackPos >= MaxStack || StackPos < 0)\n"
7558
" debugger;\n"
7559
" let rt0 = Rows[StackPos].Tree[0];\n"
7560
" rt0.Source.push(i);\n"
7561
" rt0.Index_.push(beginindex);\n"
7562
" rt0.ColorIds_.push(S.TimerInfo[beginindex].cid);\n"
7563
" rt0.Begin_.push(begintime);\n"
7564
" let Duration = time - begintime;\n"
7565
" rt0.Duration_.push(Duration);\n"
7566
" rt0.SumDuration_.push(Duration);\n"
7567
" rt0.MaxDuration_.push(Duration);\n"
7568
" rt0.SectionColor_.push(sectioncolor);\n"
7569
" if(CheckExtType(SrcTypeArray[stackindex+1],ETOKEN_GPU_CPU_TIMESTAMP)) // (SrcTypeArray[stackindex+1]&3) == 3) // this is a gpu log with a cpu marker appended\n"
7570
" {\n"
7571
" //if((SrcTypeArray[stackindex+2]&3) != 3)\n"
7572
" if(!CheckExtType(SrcTypeArray[stackindex+2], ETOKEN_GPU_CPU_SOURCE_THREAD))\n"
7573
" debugger; //should be matching triplets\n"
7574
"\n"
7575
" if(!CheckExtType(SrcTypeArray[i+1], ETOKEN_GPU_CPU_TIMESTAMP))\n"
7576
" debugger; //should be matching pairs\n"
7577
"\n"
7578
" let CustomToken1 = SrcTypeArray[stackindex+1] >> 2;\n"
7579
" let CustomToken2 = SrcTypeArray[stackindex+2] >> 2;\n"
7580
" \n"
7581
" if(CustomToken1 != ETOKEN_GPU_CPU_TIMESTAMP)\n"
7582
" debugger;\n"
7583
" if(CustomToken2 != ETOKEN_GPU_CPU_SOURCE_THREAD)\n"
7584
" debugger;\n"
7585
"\n"
7586
"\n"
7587
" let CpuBegin = SrcTimeArray[stackindex+1];\n"
7588
" let CpuEnd = SrcTimeArray[i+1];\n"
7589
" let Thread = SrcIndexArray[stackindex+2];\n"
7590
" if(!rt0.CpuDuration) //only there for gpu logs, so created on demand\n"
7591
" {\n"
7592
" rt0.CpuBegin = new Array();\n"
7593
" rt0.CpuDuration = new Array();\n"
7594
" rt0.CpuThread = new Array();\n"
7595
" for(let j = 0; j < rt0.Length; ++j)\n"
7596
" {\n"
7597
" rt0.CpuBegin.push(0);\n"
7598
" rt0.CpuDuration.push(0);\n"
7599
" rt0.CpuThread.push(0);\n"
7600
" }\n"
7601
" }\n"
7602
" rt0.CpuBegin.push(CpuBegin);\n"
7603
" rt0.CpuDuration.push(CpuEnd - CpuBegin);\n"
7604
" rt0.CpuThread.push(Thread);\n"
7605
" }\n"
7606
" else if(rt0.CpuDuration)\n"
7607
" {\n"
7608
" rt0.CpuBegin.push(0);\n"
7609
" rt0.CpuDuration.push(0);\n"
7610
" rt0.CpuThread.push(0);\n"
7611
" }\n"
7612
"\n"
7613
" rt0.Length++;\n"
7614
" }\n"
7615
"\n"
7616
" }\n"
7617
" else if(type != 0)\n"
7618
" {\n"
7619
" }\n"
7620
" }\n"
7621
"\n"
7622
" for(let r = 0; r < Rows.length; ++r)\n"
7623
" {\n"
7624
" let Row = Rows[r];\n"
7625
" let RowTreeIndex = 0;\n"
7626
"\n"
7627
" Row.Tree[0].Index = new Int32Array(Row.Tree[0].Index_);\n"
7628
" Row.Tree[0].ColorIds = new Int32Array(Row.Tree[0].ColorIds_);// = new Array();\n"
7629
" Row.Tree[0].Begin = new Float32Array(Row.Tree[0].Begin_);\n"
7630
" Row.Tree[0].Duration = new Float32Array(Row.Tree[0].Duration_);\n"
7631
" Row.Tree[0].MaxDuration = new Float32Array(Row.Tree[0].MaxDuration_);\n"
7632
" Row.Tree[0].SumDuration = new Float32Array(Row.Tree[0].SumDuration_);\n"
7633
" Row.Tree[0].SectionColor = new Int32Array(Row.Tree[0].SectionColor_);\n"
7634
"\n"
7635
" // stop at 100 elements...\n"
7636
" while(Row.Tree[RowTreeIndex].Begin.length > 10)\n"
7637
" {\n"
7638
"\n"
7639
" //Use RowTreeIndex to build RowTreeIndex+1 with half as much data.\n"
7640
" let RowTreeLevelParent = Row.Tree[RowTreeIndex];\n"
7641
" let Size = Math.floor(RowTreeLevelParent.Index.length / 2);\n"
7642
" let Tail = RowTreeLevelParent.Index.length % 2;\n"
7643
" if(Size < 0)\n"
7644
" debugger;\n"
7645
"\n"
7646
" let RowTreeLevel = new Object();\n"
7647
" RowTreeLevel.Index = new Int32Array(Size);\n"
7648
" RowTreeLevel.ColorIds = new Int32Array(Size);\n"
7649
" RowTreeLevel.Begin = new Float32Array(Size);\n"
7650
" RowTreeLevel.Duration = new Float32Array(Size);\n"
7651
" RowTreeLevel.SumDuration = new Float32Array(Size);\n"
7652
" RowTreeLevel.MaxDuration = new Float32Array(Size);\n"
7653
" RowTreeLevel.SectionColor = new Int32Array(Size);\n"
7654
" RowTreeLevel.Parent = RowTreeIndex;\n"
7655
" RowTreeLevel.Tail = Tail;\n"
7656
" RowTreeLevel.Length = 0;\n"
7657
"\n"
7658
" for(let i = 0; i < Size; ++i)\n"
7659
" {\n"
7660
" let i0 = i * 2;\n"
7661
" let i1 = i0 + 1;\n"
7662
" //Should do fancy color merging, but hey just taking the color of the largest seems to work well enough.\n"
7663
" if(RowTreeLevelParent.MaxDuration[i1] > RowTreeLevelParent.MaxDuration[i0])\n"
7664
" {\n"
7665
" RowTreeLevel.Index[i] = i1;\n"
7666
" RowTreeLevel.ColorIds[i] = RowTreeLevelParent.ColorIds[i1];\n"
7667
" RowTreeLevel.MaxDuration[i] = RowTreeLevelParent.MaxDuration[i1];\n"
7668
" RowTreeLevel.SectionColor[i] = RowTreeLevelParent.SectionColor[i1];\n"
7669
" }\n"
7670
" else\n"
7671
" {\n"
7672
" RowTreeLevel.Index[i] = i0;\n"
7673
" RowTreeLevel.ColorIds[i] = RowTreeLevelParent.ColorIds[i0];\n"
7674
" RowTreeLevel.MaxDuration[i] = RowTreeLevelParent.MaxDuration[i0];\n"
7675
" RowTreeLevel.SectionColor[i] = RowTreeLevelParent.SectionColor[i0];\n"
7676
" }\n"
7677
" RowTreeLevel.SumDuration[i] = RowTreeLevelParent.SumDuration[i0] + RowTreeLevelParent.SumDuration[i1];\n"
7678
" RowTreeLevel.Begin[i] = RowTreeLevelParent.Begin[i0];\n"
7679
" RowTreeLevel.Duration[i] = RowTreeLevelParent.Begin[i1] - RowTreeLevelParent.Begin[i0] + RowTreeLevelParent.Duration[i1];\n"
7680
" RowTreeLevel.Length++;\n"
7681
" }\n"
7682
"\n"
7683
"\n"
7684
" if(Row.Tree.length != RowTreeIndex+1)\n"
7685
" debugger;\n"
7686
" Row.Tree.push(RowTreeLevel);\n"
7687
" Row.MaxTree = Row.Tree.length;\n"
7688
" RowTreeIndex++;\n"
7689
" }\n"
7690
" }\n"
7691
" }\n"
7692
" ProfileLeave();\n"
7693
"}\n"
7694
"\n"
7695
"function PreprocessGlobalArray()\n"
7696
"{\n"
7697
" ProfileEnter(\"PreprocessGlobalArray\");\n"
7698
" var nNumLogs = S.Frames[0].ts.length;\n"
7699
" var CaptureStart = S.Frames[0].framestart;\n"
7700
" var CaptureEnd = S.Frames[S.Frames.length-1].frameend;\n"
7701
" S.TypeArray = new Array(nNumLogs);\n"
7702
" S.TimeArray = new Array(nNumLogs);\n"
7703
" S.IndexArray = new Array(nNumLogs);\n"
7704
" S.NumLogs = nNumLogs;\n"
7705
" var LogStartArray = new Array(S.Frames.length);\n"
7706
" for(var i = 0; i < S.Frames.length; i++)\n"
7707
" {\n"
7708
" S.Frames[i].LogStart = new Array(nNumLogs);\n"
7709
" LogStartArray[i] = S.Frames[i].LogStart;\n"
7710
"\n"
7711
" S.Frames[i].LogEnd = new Array(nNumLogs);\n"
7712
" }\n"
7713
" var MinDelta = Array(nNumLogs);\n"
7714
" for(nLog = 0; nLog < nNumLogs; nLog++)\n"
7715
" {\n"
7716
" MinDelta[nLog] = 0;\n"
7717
" var Discard = 0;\n"
7718
" var TypeArray = new Array();\n"
7719
" var TimeArray = new Array();\n"
7720
" var IndexArray = new Array();\n"
7721
" for(var i = 0; i < S.Frames.length; i++)\n"
7722
" {\n"
7723
" var Frame_ = S.Frames[i];\n"
7724
" Frame_.LogStart[nLog] = TimeArray.length;\n"
7725
" var CanDiscard = !S.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"
7726
"\n"
7727
" var FrameDiscard = (S.ISGPU[nLog] ? Frame_.frameendgpu : Frame_.frameend) + 33;//if timestamps are more than 33ms after current frame, we assume buffer has wrapped.\n"
7728
" var tt = Frame_.tt[nLog];\n"
7729
" var ts = Frame_.ts[nLog];\n"
7730
" var ti = Frame_.ti[nLog];\n"
7731
" var len = tt.length;\n"
7732
" var DiscardLast = 0;\n"
7733
" for(var xx = 0; xx < len; ++xx)\n"
7734
" {\n"
7735
" var Skip = (tt[i]&3 == 3) ? DiscardLast : (CanDiscard && ts[xx] > FrameDiscard);\n"
7736
" if(Skip)\n"
7737
" {\n"
7738
" Discard++;\n"
7739
" DiscardLast = 1;\n"
7740
" }\n"
7741
" else\n"
7742
" {\n"
7743
" DiscardLast = 0;\n"
7744
" TypeArray.push(tt[xx]);\n"
7745
" TimeArray.push(ts[xx]);\n"
7746
" IndexArray.push(ti[xx]);\n"
7747
" }\n"
7748
" }\n"
7749
" Frame_.LogEnd[nLog] = TimeArray.length;\n"
7750
" }\n"
7751
" S.TypeArray[nLog] = TypeArray;\n"
7752
" S.TimeArray[nLog] = TimeArray;\n"
7753
" S.IndexArray[nLog] = IndexArray;\n"
7754
" if(Discard)\n"
7755
" {\n"
7756
" console.log(\'discarded \' + Discard + \' markers from \' + S.ThreadNames[nLog]);\n"
7757
" }\n"
7758
" }\n"
7759
" MakeLod(0, MinDelta, S.TimeArray, S.TypeArray, S.IndexArray, LogStartArray);\n"
7760
" ProfileLeave();\n"
7761
"}\n"
7762
"\n"
7763
"function InitThreadLogAutoHidden()\n"
7764
"{\n"
7765
" let nNumLogs = S.Frames[0].ts.length;\n"
7766
" if(!S.ThreadLogAutoHidden)\n"
7767
" {\n"
7768
" S.ThreadLogAutoHidden = Array();\n"
7769
" }\n"
7770
" while(S.ThreadLogAutoHidden.length < nNumLogs)\n"
7771
" {\n"
7772
" S.ThreadLogAutoHidden.push(0);\n"
7773
" }\n"
7774
" if(!S.ThreadLogTypesUsed)\n"
7775
" {\n"
7776
" S.ThreadLogTypesUsed = Array();\n"
7777
" }\n"
7778
" while(S.ThreadLogTypesUsed.length < nNumLogs)\n"
7779
" {\n"
7780
" S.ThreadLogTypesUsed.push([]);\n"
7781
" }\n"
7782
"}\n"
7783
"\n"
7784
"function UpdateThreadLogAutoHide()\n"
7785
"{\n"
7786
" let AutoHide = ThreadLogAutoHide;\n"
7787
" let nNumLogs = S.Frames[0].ts.length;\n"
7788
" InitThreadLogAutoHidden();\n"
7789
" for(let nLog = 0; nLog < nNumLogs; ++nLog)\n"
7790
" {\n"
7791
" if(AutoHide)\n"
7792
" {\n"
7793
" let TypesUsed = S.ThreadLogTypesUsed[nLog];\n"
7794
" S.ThreadLogAutoHidden[nLog] = 1;\n"
7795
" for(let i = 0; i < TypesUsed.length; ++i)\n"
7796
" {\n"
7797
" if(TypesUsed[i])\n"
7798
" {\n"
7799
" S.ThreadLogAutoHidden[nLog] = 0;\n"
7800
" break;\n"
7801
" }\n"
7802
" }\n"
7803
" }\n"
7804
" else\n"
7805
" {\n"
7806
" S.ThreadLogAutoHidden[nLog] = 0;\n"
7807
" }\n"
7808
" console.log(\"AutoHide \", nLog, \" \", S.ThreadLogAutoHidden[nLog]);\n"
7809
" }\n"
7810
"}\n"
7811
"\n"
7812
"function PreprocessGatherLogTypes()\n"
7813
"{\n"
7814
" ProfileEnter(\"PreprocessGatherLogTypes\");\n"
7815
" let TimerCount = S.TimerInfo.length;\n"
7816
" let nNumLogs = S.Frames[0].ts.length;\n"
7817
" InitThreadLogAutoHidden();\n"
7818
" for(let nLog = 0; nLog < nNumLogs; nLog++)\n"
7819
" {\n"
7820
" S.ThreadLogAutoHidden[nLog] = 0;\n"
7821
" let TypesUsed = Array(TimerCount);\n"
7822
" for(let i = 0; i < TypesUsed.length; ++i)\n"
7823
" {\n"
7824
" TypesUsed[i] = 0;\n"
7825
" }\n"
7826
" for(let i = 0; i < S.Frames.length; i++)\n"
7827
" {\n"
7828
" let F = S.Frames[i];\n"
7829
" console.assert(F.tt.length == nNumLogs);\n"
7830
" let Data = F.ti[nLog];\n"
7831
" for(let j in Data)\n"
7832
" {\n"
7833
" let t = Data[j];\n"
7834
" console.assert(t < TimerCount);\n"
7835
" TypesUsed[t] = 1;\n"
7836
" }\n"
7837
" }\n"
7838
" S.ThreadLogTypesUsed[nLog] = TypesUsed;\n"
7839
" }\n"
7840
" ProfileLeave();\n"
7841
"}\n"
7842
"\n"
7843
"function PreprocessFindFirstFrames()\n"
7844
"{\n"
7845
" ProfileEnter(\"PreprocesFindFirstFrames\");\n"
7846
" //create arrays that show how far back we need to start search in order to get all markers.\n"
7847
" let nNumLogs = S.Frames[0].ts.length;\n"
7848
" for(let i = 0; i < S.Frames.length; i++)\n"
7849
" {\n"
7850
" S.Frames[i].FirstFrameIndex = new Array(nNumLogs);\n"
7851
" for(let j = 0; j < S.Frames[i].FirstFrameIndex.length; ++j)\n"
7852
" {\n"
7853
" S.Frames[i].FirstFrameIndex[j] = 0;\n"
7854
" }\n"
7855
" }\n"
7856
"\n"
7857
" let StackPos = 0;\n"
7858
" let Stack = Array(20);\n"
7859
" S.MaxStack = Array(nNumLogs);\n"
7860
"\n"
7861
" for(nLog = 0; nLog < nNumLogs; nLog++)\n"
7862
" {\n"
7863
" let MaxStack = 0;\n"
7864
" StackPos = 0;\n"
7865
" for(let i = 0; i < S.Frames.length; i++)\n"
7866
" {\n"
7867
" let Frame_ = S.Frames[i];\n"
7868
" let tt = Frame_.tt[nLog];\n"
7869
" let count = tt.length;\n"
7870
"\n"
7871
" let FirstFrame = i;\n"
7872
" if(StackPos>0)\n"
7873
" {\n"
7874
" FirstFrame = Stack[0];\n"
7875
" }\n"
7876
" S.Frames[i].FirstFrameIndex[nLog] = FirstFrame;\n"
7877
"\n"
7878
" for(let j = 0; j < count; j++)\n"
7879
" {\n"
7880
" let type = tt[j];\n"
7881
" if(type == 1)\n"
7882
" {\n"
7883
" Stack[StackPos] = i;//store the frame which it comes from\n"
7884
" StackPos++;\n"
7885
" if(StackPos > MaxStack)\n"
7886
" {\n"
7887
" MaxStack = StackPos;\n"
7888
" }\n"
7889
" }\n"
7890
" else if(type == 0)\n"
7891
" {\n"
7892
" if(StackPos>0)\n"
7893
" {\n"
7894
" StackPos--;\n"
7895
" }\n"
7896
" }\n"
7897
" }\n"
7898
" }\n"
7899
" S.MaxStack[nLog] = MaxStack;\n"
7900
" }\n"
7901
" S.MaxStack2 = Array(S.MaxStack.length);\n"
7902
" for(let i = 0; i < S.MaxStack2.length; ++i)\n"
7903
" S.MaxStack2[i] = 0;\n"
7904
" S.SecondActive = 0;\n"
7905
" ProfileLeave();\n"
7906
"}\n"
7907
"function PreprocessMeta()\n"
7908
"{\n"
7909
" return;\n"
7910
" MetaLengths = Array(MetaNames.length);\n"
7911
" MetaLengthsAvg = Array(MetaNames.length);\n"
7912
" MetaLengthsMax = Array(MetaNames.length);\n"
7913
" for(var i = 0; i < MetaNames.length; ++i)\n"
7914
" {\n"
7915
" MetaLengths[i] = MetaNames[i].length+1;\n"
7916
" MetaLengthsAvg[i] = MetaNames[i].length+5;\n"
7917
" MetaLengthsMax[i] = MetaNames[i].length+5;\n"
7918
" if(MetaLengths[i]<12)\n"
7919
" MetaLengths[i] = 12;\n"
7920
" if(MetaLengthsAvg[i]<12)\n"
7921
" MetaLengthsAvg[i] = 12;\n"
7922
" if(MetaLengthsMax[i]<12)\n"
7923
" MetaLengthsMax[i] = 12;\n"
7924
" }\n"
7925
" for(var i = 0; i < S.TimerInfo.length; ++i)\n"
7926
" {\n"
7927
" var Timer = S.TimerInfo[i];\n"
7928
" for(var j = 0; j < MetaNames.length; ++j)\n"
7929
" {\n"
7930
" var Len = FormatMeta(Timer.meta[j],0).length + 2;\n"
7931
" var LenAvg = FormatMeta(Timer.meta[j],2).length + 2;\n"
7932
" var LenMax = FormatMeta(Timer.meta[j],0).length + 2;\n"
7933
" if(Len > MetaLengths[j])\n"
7934
" {\n"
7935
" MetaLengths[j] = Len;\n"
7936
" }\n"
7937
" if(LenAvg > MetaLengthsAvg[j])\n"
7938
" {\n"
7939
" MetaLengthsAvg[j] = LenAvg;\n"
7940
" }\n"
7941
" if(LenMax > MetaLengthsMax[j])\n"
7942
" {\n"
7943
" MetaLengthsMax[j] = LenMax;\n"
7944
" }\n"
7945
" }\n"
7946
" }\n"
7947
"}\n"
7948
"\n"
7949
"function StringHash(s) //note: matching code in microprofile.cpp: uint32_t MicroProfileStringHash(const char* pString)\n"
7950
"{\n"
7951
" let h = 0xfeedba3e;\n"
7952
" for(let i = 0; i < s.length; ++i)\n"
7953
" {\n"
7954
" h = s.charCodeAt(i) + (h << 5) - h;\n"
7955
" h = h & h;\n"
7956
" }\n"
7957
" return Math.abs(h);\n"
7958
"}\n"
7959
"\n"
7960
"function StringColorIndex(Name)\n"
7961
"{\n"
7962
" let h = StringHash(Name);\n"
7963
" let cidx = Math.floor(360*(h / (1<<32-1)) );\n"
7964
" return cidx;\n"
7965
"}\n"
7966
"\n"
7967
"function ColorFromString(Name, S, L)\n"
7968
"{\n"
7969
" let H = StringColorIndex(Name);\n"
7970
" return \"hsl(\" + H + \",\" + S + \"%, \" + L+ \"%)\";\n"
7971
"}\n"
7972
"function LerpColor(v)\n"
7973
"{\n"
7974
" let R_0 = 0;\n"
7975
" let G_0 = 1;\n"
7976
" let B_0 = 0;\n"
7977
"\n"
7978
" let R_1 = 1;\n"
7979
" let G_1 = 0.5;\n"
7980
" let B_1 = 0;\n"
7981
"\n"
7982
" let R_2 = 1;\n"
7983
" let G_2 = 0;\n"
7984
" let B_3 = 0;\n"
7985
" let R;\n"
7986
" let G;\n"
7987
" if(v < 0.5)\n"
7988
" {\n"
7989
" v *= 2;\n"
7990
" let v0 = (1-v);\n"
7991
" R = R_0 * v0 + R_1 * v;\n"
7992
" G = G_0 * v0 + G_1 * v;\n"
7993
"\n"
7994
" }\n"
7995
" else\n"
7996
" {\n"
7997
" v = (v-0.5) * 2;\n"
7998
" let v0 = (1-v);\n"
7999
" R = R_1 * v0 + R_2 * v;\n"
8000
" G = G_1 * v0 + G_2 * v;\n"
8001
" }\n"
8002
" R *= 255;\n"
8003
" G *= 255;\n"
8004
" return \"rgb(\" + R.toFixed(0) + \",\" + G.toFixed(0) + \",0)\";\n"
8005
"\n"
8006
"}\n"
8007
"\n"
8008
"function PreprocessThreadColors(S)\n"
8009
"{\n"
8010
" S.ThreadColors = Array(S.ThreadNames.length);\n"
8011
" for(let i = 0; i < S.ThreadNames.length; ++i)\n"
8012
" {\n"
8013
" var cidx = StringColorIndex(S.ThreadNames[i]);\n"
8014
" var color = \"hsl(\" + cidx + \",50%, 60%)\";\n"
8015
" var coloroff = \"hsl(\" + cidx + \",85%, 50%)\";\n"
8016
" var colordark = \"hsl(\" + cidx + \",80%, 30%)\";\n"
8017
" var colordark_cid = GetColorIndex(colordark);\n"
8018
" var colortrans = \"hsla(\" + cidx + \",55%, 80%, 0.2)\";\n"
8019
" S.ThreadColors[i] = {\"color\":color, \"colordark\":colordark, \"cidx\":cidx, \"gradient\":null,\"gradientoff\":null, \"coloroff\":coloroff, \"colordark_cid\":colordark_cid, \"colortrans\":colortrans};\n"
8020
" }\n"
8021
"}\n"
8022
"\n"
8023
"function PreprocessWidths()\n"
8024
"{\n"
8025
" let context = CanvasHistory.getContext(\'2d\');\n"
8026
" context.font = Font;\n"
8027
" S.TimerNameWidth = 0;\n"
8028
" S.GroupNameWidth = 0;\n"
8029
"\n"
8030
" for(let i in S.TimerInfo)\n"
8031
" {\n"
8032
" let str = S.GroupInfo[S.TimerInfo[i].group].name + \"XXX\" + S.TimerInfo[i].name;\n"
8033
" let width = context.measureText(str).width;\n"
8034
" let widthname = context.measureText(S.TimerInfo[i].name).width;\n"
8035
" S.TimerInfo[i].wtotal = width;\n"
8036
" S.TimerInfo[i].w = widthname;\n"
8037
" S.TimerNameWidth = Math.max(S.TimerNameWidth, widthname);\n"
8038
" }\n"
8039
" for(let i in S.GroupInfo)\n"
8040
" {\n"
8041
" let widthname = context.measureText(S.TimerInfo[i].name).width;\n"
8042
" S.GroupNameWidth = Math.max(S.GroupNameWidth, widthname);\n"
8043
" }\n"
8044
" for(let i in S.ThreadNames)\n"
8045
" {\n"
8046
" let w = context.measureText(S.ThreadNames[i]).width;\n"
8047
" S.ThreadNameWidth = Math.max(S.ThreadNameWidth, w);\n"
8048
" }\n"
8049
" for(let i in S.CategoryInfo)\n"
8050
" {\n"
8051
" let w = context.measureText(S.CategoryInfo[i]).width;\n"
8052
" S.ThreadCategoryWidth = Math.max(S.ThreadCategoryWidth, w);\n"
8053
" }\n"
8054
"}\n"
8055
"\n"
8056
"function PreprocessTimeline()\n"
8057
"{\n"
8058
" Timeline.Times = S.TimelineArray;\n"
8059
" Timeline.Ids = S.TimelineIdArray;\n"
8060
" Timeline.Colors = new Array(S.TimelineArray.length);\n"
8061
" Timeline.Names = S.TimelineNames;\n"
8062
" Timeline.Ends = new Array(S.TimelineArray.length);\n"
8063
" Timeline.Pairs = new Array(S.TimelineArray.length);\n"
8064
" Timeline.SearchMatch = new Array(S.TimelineArray.length);\n"
8065
" Timeline.Tracks = new Array();\n"
8066
" Timeline.Positions = new Array();\n"
8067
" for(var i = 0; i < Timeline.Times.length; ++i)\n"
8068
" {\n"
8069
" Timeline.Positions[i] = -1;\n"
8070
" Timeline.Ends[i] = -1;\n"
8071
" Timeline.Pairs[i] = -1;\n"
8072
" Timeline.SearchMatch[i] = false;\n"
8073
" var Color = S.TimelineColorArray[i]\n"
8074
" if(!Color || Color == \'\' || Color == \"#000000\")\n"
8075
" {\n"
8076
" Color = ColorFromString(Timeline.Names[i], 40, 50);\n"
8077
" }\n"
8078
" Timeline.Colors[i] = GetColorIndex(Color);\n"
8079
" if(null == Timeline.Colors[i])\n"
8080
" debugger;\n"
8081
" Timeline.Colors[i] = GetColorIndex(Color);\n"
8082
" }\n"
8083
"\n"
8084
"\n"
8085
" var LinearizeTrack = function(Track)\n"
8086
" {\n"
8087
" var b = new Array();\n"
8088
" var e = new Array();\n"
8089
" // var n = new Array();\n"
8090
" var k = new Array();\n"
8091
" var h = Track.h;\n"
8092
" while(h != -1)\n"
8093
" {\n"
8094
" b.push(Track.b[h]);\n"
8095
" e.push(Track.e[h]);\n"
8096
" k.push(Track.k[h]);\n"
8097
"\n"
8098
" h = Track.n[h];\n"
8099
" }\n"
8100
" }\n"
8101
"\n"
8102
" var CreateTrack = function()\n"
8103
" {\n"
8104
" var Track = {};\n"
8105
" Track.b = new Array();\n"
8106
" Track.e = new Array();\n"
8107
" Track.n = new Array();\n"
8108
" Track.k = new Array();\n"
8109
" Track.h = -1;\n"
8110
" return Track;\n"
8111
" }\n"
8112
"\n"
8113
"\n"
8114
" var TryAddToTrack = function(Track, b, e, k)\n"
8115
" {\n"
8116
" var Invalid = 0;\n"
8117
" var prev = -1;\n"
8118
" var next = Track.h;\n"
8119
" while(next != -1)\n"
8120
" {\n"
8121
" var B = Track.b[next];\n"
8122
" var E = Track.e[next];\n"
8123
" if(Math.max(B, b) < Math.min(E, e))\n"
8124
" {\n"
8125
" Invalid = 1;\n"
8126
" break;\n"
8127
" }\n"
8128
" if(E < b)\n"
8129
" {\n"
8130
" //should be after next, continue\n"
8131
" }else if(e < B)\n"
8132
" {\n"
8133
" //insert at this spot\n"
8134
" break;\n"
8135
" }\n"
8136
" prev = next;\n"
8137
" next = Track.n[next];\n"
8138
" }\n"
8139
" if(!Invalid)\n"
8140
" {\n"
8141
" var idx = Track.b.length;\n"
8142
" Track.b.push(b);\n"
8143
" Track.e.push(e);\n"
8144
" Track.k.push(k);\n"
8145
" Track.n.push(next);\n"
8146
" if(prev == -1)\n"
8147
" {\n"
8148
" Track.h = idx;\n"
8149
" }\n"
8150
" else\n"
8151
" {\n"
8152
" var h = Track.n[prev];\n"
8153
" if(h != next)\n"
8154
" {\n"
8155
" debugger;\n"
8156
" }\n"
8157
" Track.n[prev] = idx;\n"
8158
" }\n"
8159
" return true;\n"
8160
" }\n"
8161
" else\n"
8162
" {\n"
8163
" return false;\n"
8164
" }\n"
8165
" };\n"
8166
"\n"
8167
"\n"
8168
" var AddToTrack = function(b, e, k)\n"
8169
" {\n"
8170
" var Tracks = Timeline.Tracks;\n"
8171
"\n"
8172
" for(var i = 0; i < Tracks.length; ++i)\n"
8173
" {\n"
8174
" var Track = Tracks[i];\n"
8175
" if(TryAddToTrack(Track, b, e, k))\n"
8176
" {\n"
8177
" return i;\n"
8178
" }\n"
8179
" }\n"
8180
" var NewTrack = CreateTrack();\n"
8181
" var i = Timeline.Tracks.length;\n"
8182
" Timeline.Tracks.push(NewTrack);\n"
8183
" if(!TryAddToTrack(NewTrack, b, e, k))\n"
8184
" {\n"
8185
" debugger;\n"
8186
" }\n"
8187
" return i;\n"
8188
"\n"
8189
" };\n"
8190
"\n"
8191
" let HasMatchingName = function(index)\n"
8192
" {\n"
8193
" let name = Timeline.Names[index];\n"
8194
" return name && name.length > 0;\n"
8195
" };\n"
8196
"\n"
8197
"\n"
8198
"\n"
8199
"\n"
8200
"\n"
8201
" var Matching = {};\n"
8202
" var Pairs = Timeline.Pairs;\n"
8203
" var Ids = Timeline.Ids;\n"
8204
" var Ends = Timeline.Ends;\n"
8205
" var Times = Timeline.Times;\n"
8206
" if(Ids)\n"
8207
" {\n"
8208
" for(var i = 0; i < Ids.length; ++i)\n"
8209
" {\n"
8210
" Pairs[i] = -1;\n"
8211
" var ID = Ids[i];\n"
8212
" var match = Matching[ID];\n"
8213
" if(match >= 0)\n"
8214
" {\n"
8215
" if(match > Ids.length || match < 0)\n"
8216
" debugger;\n"
8217
" Pairs[match] = i;\n"
8218
" Pairs[i] = match;\n"
8219
" if(match > i)\n"
8220
" debugger;\n"
8221
" Ends[match] = Times[i];\n"
8222
" var Track = AddToTrack(Times[match], Ends[match], match);\n"
8223
" Timeline.Positions[match] = Track;\n"
8224
" delete Matching[ID];\n"
8225
" }\n"
8226
" else\n"
8227
" {\n"
8228
" if(HasMatchingName(i))\n"
8229
" {\n"
8230
" Matching[ID] = i;\n"
8231
" }\n"
8232
" }\n"
8233
" }\n"
8234
" }\n"
8235
" // add any unclosed markers\n"
8236
" for(let id in Matching)\n"
8237
" {\n"
8238
" let index = Matching[id];\n"
8239
" let name = Timeline.Names[index];\n"
8240
" if(HasMatchingName(index)) // only close if there is a matching name...\n"
8241
" {\n"
8242
" let StartTime = Times[index];\n"
8243
" let EndTime = S.CaptureEndTime;\n"
8244
" if(StartTime >= EndTime)\n"
8245
" {\n"
8246
" EndTime = EndTime + 42;\n"
8247
" console.log(\"End marker after captureend time. this should not happen. adding 42\");\n"
8248
" debugger;\n"
8249
" }\n"
8250
"\n"
8251
" Ends[index] = S.CaptureEndTime;\n"
8252
" let Track = AddToTrack(Times[index], Ends[index], index);\n"
8253
" Timeline.Positions[index] = Track;\n"
8254
" }\n"
8255
" }\n"
8256
"}\n"
8257
"\n"
8258
"function Preprocess_S()\n"
8259
"{\n"
8260
" console.log(\'preprocessing\\n\');\n"
8261
" S.LodData = new Array();\n"
8262
" S.CSwitchCache = {};\n"
8263
" S.CSwitchOnlyThreads = [];\n"
8264
" S.GroupNameWidth = 200;\n"
8265
" S.TimerNameWidth = 200;\n"
8266
" S.ThreadNameWidth = 150;\n"
8267
" S.ThreadCategoryWidth = 150;\n"
8268
"\n"
8269
" PreprocessCalculateAllTimers();\n"
8270
" PreprocessFindFirstFrames();\n"
8271
" PreprocessGatherLogTypes();\n"
8272
"\n"
8273
" PreprocessGlobalArray();\n"
8274
" PreprocessLogBarArray();\n"
8275
" PreprocessLods();//kill\n"
8276
" PreprocessMeta();//kill\n"
8277
" PreprocessThreadColors(S);\n"
8278
"\n"
8279
" PreprocessContextSwitchCache();\n"
8280
" PreprocessWidths();\n"
8281
"\n"
8282
" UpdateThreadLogAutoHide();\n"
8283
"\n"
8284
" console.log(\'preprocessing done\\n\');\n"
8285
" console.log(\"SS \" + S.LodData.length);\n"
8286
"}\n"
8287
"function Preprocess()\n"
8288
"{\n"
8289
" var ProfileModeOld = ProfileMode;\n"
8290
" ProfileMode = 1;\n"
8291
" ProfileModeClear();\n"
8292
" ProfileEnter(\"Preprocess\");\n"
8293
" Preprocess_S();\n"
8294
" UpdateReferenceTime();\n"
8295
"\n"
8296
" ProfileLeave();\n"
8297
" ProfileModeDump();\n"
8298
" ProfileMode = ProfileModeOld;\n"
8299
" PreprocessTimeline();\n"
8300
" Initialized = 1;\n"
8301
"}\n"
8302
"\n"
8303
"function ToggleColumn(idx, isMeta)\n"
8304
"{\n"
8305
" ColumnsEnabled[idx] = !ColumnsEnabled[idx];\n"
8306
" UpdateColumnsMenu();\n"
8307
" WriteCookie();\n"
8308
" Invalidate = 0;\n"
8309
"}\n"
8310
"function UpdateColumnsMenu()\n"
8311
"{\n"
8312
" var ulColumnMenu = document.getElementById(\'ColumnsSubMenu\');\n"
8313
" var Lis = ulColumnMenu.getElementsByTagName(\'li\');\n"
8314
" for(var i = 0; i < Lis.length; ++i)\n"
8315
" {\n"
8316
" if(ColumnsEnabled[i])\n"
8317
" {\n"
8318
" Lis[i].style[\'text-decoration\'] = \'underline\';\n"
8319
" }\n"
8320
" else\n"
8321
" {\n"
8322
" Lis[i].style[\'text-decoration\'] = \'none\';\n"
8323
" }\n"
8324
" }\n"
8325
"}\n"
8326
"\n"
8327
"function ResetColumnWidth()\n"
8328
"{\n"
8329
" if(ColumnsWidth)\n"
8330
" {\n"
8331
" for(var i = 0; i < ColumnsWidth.length; ++i)\n"
8332
" {\n"
8333
" ColumnsWidth[i] = 0;\n"
8334
" }\n"
8335
" }\n"
8336
"}\n"
8337
"var Comp0 = new Date();\n"
8338
"var Comp1 = new Date();\n"
8339
"var Comp2 = new Date();\n"
8340
"var Comp3 = new Date();\n"
8341
"\n"
8342
"function SetGlobal(Name, Value)\n"
8343
"{\n"
8344
" this[Name] = Value;\n"
8345
"}\n"
8346
"\n"
8347
"\n"
8348
"//compare todo:\n"
8349
"// **Match threads\n"
8350
"// **match tokens.\n"
8351
"// **Calculate shared screen positions.\n"
8352
"// **Invert second pass\n"
8353
"// **fix hovertoken\n"
8354
"// **fix range display\n"
8355
"// todo: isgpu\n"
8356
"// todo: group numtimers.\n"
8357
"// implement timer view\n"
8358
"\n"
8359
"function CompareFixup(S0, S1) // S0 is the reference\n"
8360
"{\n"
8361
" var GroupRemap = Array(S1.GroupInfo.length);\n"
8362
" var ThreadRemap = Array(S1.ThreadNames.length);\n"
8363
" var TimerRemap = Array(S1.TimerInfo.length);\n"
8364
" GroupRemapReverse = Array(S0.GroupInfo.length + S1.GroupInfo.length);\n"
8365
" TimerRemapReverse = Array(S0.TimerInfo.length + S1.TimerInfo.length);\n"
8366
" ThreadRemapReverse = Array(S0.ThreadNames.length + S1.ThreadNames.length);\n"
8367
"\n"
8368
" for(var i = 0; i < GroupRemapReverse.length; ++i)\n"
8369
" GroupRemapReverse[i] = -1;\n"
8370
" for(var i = 0; i < TimerRemapReverse.length; ++i)\n"
8371
" TimerRemapReverse[i] = -1;\n"
8372
" for(var i = 0; i < ThreadRemapReverse.length; ++i)\n"
8373
" ThreadRemapReverse[i] = -1;\n"
8374
"\n"
8375
"\n"
8376
"\n"
8377
" // var dump = function(SS, str)\n"
8378
" // {\n"
8379
" // console.log(str);\n"
8380
" // for(var i = 0; i < SS.GroupInfo.length; ++i)\n"
8381
" // {\n"
8382
" // console.log(\"G\" + i + \":\" + SS.GroupInfo[i].name);\n"
8383
" // }\n"
8384
" // for(var i = 0; i < SS.TimerInfo.length; ++i)\n"
8385
" // {\n"
8386
" // console.log(\"T\" + i + \":\" + SS.TimerInfo[i].name);\n"
8387
" // }\n"
8388
"\n"
8389
" // };\n"
8390
" // dump(S0, \"S0be4\");\n"
8391
" // dump(S1, \"S1be4\");\n"
8392
"\n"
8393
" for(var i = 0; i < S1.GroupInfo.length; ++i)\n"
8394
" {\n"
8395
" var n = S1.GroupInfo[i].name;\n"
8396
" var idx = S0.GroupInfo.findIndex(function(G){ return G.name == n; });\n"
8397
" if(idx != -1)\n"
8398
" {\n"
8399
" GroupRemap[i] = idx;\n"
8400
" }\n"
8401
" else\n"
8402
" {\n"
8403
" GroupRemap[i] = S0.GroupInfo.length;\n"
8404
" S0.GroupInfo.push(S1.GroupInfo[i]);\n"
8405
" }\n"
8406
" GroupRemapReverse[GroupRemap[i]] = i;\n"
8407
" }\n"
8408
" // for(var i = 0; i < S0.TimerInfo.length; ++i)\n"
8409
" // {\n"
8410
" // var n = S0.TimerInfo[i].name;\n"
8411
" // console.log(\'OG \', n, \' idx \', i);\n"
8412
" // }\n"
8413
"\n"
8414
" for(var i = 0; i < S1.TimerInfo.length; ++i)\n"
8415
" {\n"
8416
" var TI = S1.TimerInfo[i];\n"
8417
" var n = TI.name;\n"
8418
" var g = GroupRemap[TI.group];\n"
8419
" var idx = S0.TimerInfo.findIndex(function(T){ return T.name == n && T.group == g; });\n"
8420
" TI.group = GroupRemap[TI.group];\n"
8421
" if(idx != -1)\n"
8422
" {\n"
8423
" TimerRemap[i] = idx;\n"
8424
" }\n"
8425
" else\n"
8426
" {\n"
8427
" console.log(\'added timer \' + TI.name + \' idx \' + S0.TimerInfo.length);\n"
8428
" TimerRemap[i] = S0.TimerInfo.length;\n"
8429
" TI.id = S0.TimerInfo.length;\n"
8430
" S0.TimerInfo.push(TI);\n"
8431
" }\n"
8432
" TimerRemapReverse[TimerRemap[i]] = i;\n"
8433
" }\n"
8434
"\n"
8435
" var NumThreads = S0.ThreadNames.length;\n"
8436
"\n"
8437
"\n"
8438
" for(var i = 0; i < S1.ThreadNames.length; ++i)\n"
8439
" {\n"
8440
" var n = S1.ThreadNames[i];\n"
8441
" var idx = S0.ThreadNames.indexOf(n);\n"
8442
" if(idx != -1)\n"
8443
" {\n"
8444
" ThreadRemap[i] = idx;\n"
8445
" }\n"
8446
" else\n"
8447
" {\n"
8448
" ThreadRemap[i] = S0.ThreadNames.length;\n"
8449
" S0.ThreadNames.push(n);\n"
8450
" NumThreads++;\n"
8451
" }\n"
8452
" ThreadRemapReverse[ThreadRemap[i]] = i;\n"
8453
" }\n"
8454
"\n"
8455
"\n"
8456
" PreprocessThreadColors(S0);\n"
8457
" PreprocessThreadColors(S1);\n"
8458
"\n"
8459
" var Fix = function(a, r)\n"
8460
" {\n"
8461
" for(var i in a)\n"
8462
" {\n"
8463
" a[i] = r[a[i]];\n"
8464
" }\n"
8465
" };\n"
8466
" var FixArray = function(a, s)\n"
8467
" {\n"
8468
" if(!s)\n"
8469
" return;\n"
8470
" for(var i = 0; i < a.length; ++i)\n"
8471
" {\n"
8472
" if(!a[i])\n"
8473
" a[i] = [];\n"
8474
" }\n"
8475
" while(a.length != s)\n"
8476
" a.push([]);\n"
8477
" };\n"
8478
"\n"
8479
" for(var i in S0.Frames)\n"
8480
" {\n"
8481
" var F = S0.Frames[i];\n"
8482
" FixArray(F.ti, NumThreads);\n"
8483
" FixArray(F.ts, NumThreads);\n"
8484
" FixArray(F.tt, NumThreads);\n"
8485
" }\n"
8486
"\n"
8487
" for(var i in S1.Frames)\n"
8488
" {\n"
8489
" var F = S1.Frames[i];\n"
8490
" var ti = F.ti;\n"
8491
" var ts = F.ts;\n"
8492
" var tt = F.tt;\n"
8493
"\n"
8494
" F.ti = new Array(NumThreads);\n"
8495
" F.ts = new Array(NumThreads);\n"
8496
" F.tt = new Array(NumThreads);\n"
8497
"\n"
8498
" for(var j in ti)\n"
8499
" {\n"
8500
"\n"
8501
" Fix(ti[j], TimerRemap);\n"
8502
" F.ti[ThreadRemap[j]] = ti[j];\n"
8503
" }\n"
8504
" FixArray(F.ti, NumThreads);\n"
8505
" for(var i = 0; i < NumThreads; ++i)\n"
8506
" {\n"
8507
" if(!F.ti[i])\n"
8508
" debugger;\n"
8509
" }\n"
8510
" for(var j in ts)\n"
8511
" {\n"
8512
" F.ts[ThreadRemap[j]] = ts[j];\n"
8513
" }\n"
8514
" FixArray(F.ts, NumThreads);\n"
8515
" for(var i = 0; i < NumThreads; ++i)\n"
8516
" {\n"
8517
" if(!F.ts[i])\n"
8518
" debugger;\n"
8519
" }\n"
8520
" for(var j in tt)\n"
8521
" {\n"
8522
" F.tt[ThreadRemap[j]] = tt[j];\n"
8523
" }\n"
8524
" FixArray(F.tt, NumThreads);\n"
8525
"\n"
8526
" for(var i = 0; i < NumThreads; ++i)\n"
8527
" {\n"
8528
" if(!F.tt[i])\n"
8529
" debugger;\n"
8530
" }\n"
8531
" //assert length is the same\n"
8532
" if(F.tt.length != S0.Frames[0].tt.length)\n"
8533
" {\n"
8534
" debugger;\n"
8535
" }\n"
8536
" if(F.ti.length != S0.Frames[0].ti.length)\n"
8537
" {\n"
8538
" debugger;\n"
8539
" }\n"
8540
" if(F.ts.length != S0.Frames[0].ts.length)\n"
8541
" {\n"
8542
" debugger;\n"
8543
" }\n"
8544
" // console.log(\'log \' + i + \':\', F.ts.length, \':\', F.ti.length, \':\', F.tt.length);\n"
8545
" }\n"
8546
"\n"
8547
" var NewTimerInfo = Array(S0.TimerInfo.length);\n"
8548
" for(var i = 0; i < S1.TimerInfo.length; ++i)\n"
8549
" {\n"
8550
" let xx = TimerRemap[i];\n"
8551
" NewTimerInfo[xx] = S1.TimerInfo[i];\n"
8552
" NewTimerInfo[xx].id = xx;\n"
8553
" NewTimerInfo[xx].group = S0.TimerInfo[xx].group;\n"
8554
"\n"
8555
" if(NewTimerInfo[xx].id != S0.TimerInfo[xx].id)\n"
8556
" {\n"
8557
" debugger;\n"
8558
" }\n"
8559
" if(NewTimerInfo[xx].group != S0.TimerInfo[xx].group)\n"
8560
" {\n"
8561
" debugger;\n"
8562
" }\n"
8563
"\n"
8564
" }\n"
8565
" for(var i = 0; i < NewTimerInfo.length; ++i)\n"
8566
" {\n"
8567
" if(!NewTimerInfo[i])\n"
8568
" {\n"
8569
" NewTimerInfo[i] = CloneTimer(S0.TimerInfo[i]);\n"
8570
" NewTimerInfo[i].id = i;\n"
8571
" if(NewTimerInfo[i].id != S0.TimerInfo[i].id)\n"
8572
" {\n"
8573
" debugger;\n"
8574
" }\n"
8575
" if(NewTimerInfo[i].group != S0.TimerInfo[i].group)\n"
8576
" {\n"
8577
" debugger;\n"
8578
" }\n"
8579
"\n"
8580
" }\n"
8581
"";
8582
8583
const size_t g_MicroProfileHtml_end_5_size = sizeof(g_MicroProfileHtml_end_5);
8584
const char g_MicroProfileHtml_end_6[] =
8585
" }\n"
8586
" S1.TimerInfo = NewTimerInfo;\n"
8587
" var NewGroupInfo = Array(S0.GroupInfo.length);\n"
8588
"\n"
8589
" for(let i = 0; i < S1.GroupInfo.length; ++i)\n"
8590
" {\n"
8591
" let xx = GroupRemap[i];\n"
8592
" NewGroupInfo[xx] = S1.GroupInfo[i];\n"
8593
" NewGroupInfo[xx].id = xx;\n"
8594
" }\n"
8595
" for(let i = 0; i < NewGroupInfo.length; ++i)\n"
8596
" {\n"
8597
" if(!NewGroupInfo[i])\n"
8598
" {\n"
8599
" NewGroupInfo[i] = CloneGroup(S0.GroupInfo[i]);\n"
8600
" NewGroupInfo[i].id = i;\n"
8601
" }\n"
8602
" }\n"
8603
" S1.GroupInfo = NewGroupInfo;\n"
8604
" for(let i = 0; i < S1.GroupInfo.length; ++i)\n"
8605
" {\n"
8606
" if(S1.GroupInfo[i].id != i)\n"
8607
" debugger;\n"
8608
" if(S0.GroupInfo[i].id != i)\n"
8609
" debugger;\n"
8610
" }\n"
8611
"\n"
8612
" //debugging:\n"
8613
" if(S0.TimerInfo.length != S1.TimerInfo.length)\n"
8614
" debugger;\n"
8615
" for(let i = 0; i < S0.TimerInfo.length; ++i)\n"
8616
" {\n"
8617
" let t0 = S0.TimerInfo[i];\n"
8618
" let t1 = S1.TimerInfo[i];\n"
8619
" if(t0.id != t1.id)\n"
8620
" debugger;\n"
8621
" if(t0.name != t1.name)\n"
8622
" debugger;\n"
8623
" if(t0.group != t1.group)\n"
8624
" debugger;\n"
8625
" }\n"
8626
"\n"
8627
" if(S0.GroupInfo.length != S1.GroupInfo.length)\n"
8628
" debugger;\n"
8629
" for(let i = 0; i < S0.GroupInfo.length; ++i)\n"
8630
" {\n"
8631
" let t0 = S0.GroupInfo[i];\n"
8632
" let t1 = S1.GroupInfo[i];\n"
8633
" if(t0.id != t1.id)\n"
8634
" debugger;\n"
8635
" if(t0.name != t1.name)\n"
8636
" debugger;\n"
8637
" }\n"
8638
"}\n"
8639
"\n"
8640
"function ReadHtmlFile(File)\n"
8641
"{\n"
8642
" if (!File)\n"
8643
" {\n"
8644
" return;\n"
8645
" }\n"
8646
" var Reader = new FileReader();\n"
8647
" Reader.onload = function(e) {\n"
8648
" if(!ParseCompareData(e.target.result))\n"
8649
" {\n"
8650
" ShowFlashMessage(\"Failed to parse file\", 50);\n"
8651
" }\n"
8652
" };\n"
8653
" Reader.onprogress = function(e)\n"
8654
" {\n"
8655
" var m = e.loaded + \":\" + e.total + \" :: \" + e.lengthComputable;\n"
8656
" console.log(m);\n"
8657
" };\n"
8658
" Reader.readAsText(File);\n"
8659
"}\n"
8660
"\n"
8661
"function ReadHtmlFileHandler(e)\n"
8662
"{\n"
8663
" ReadHtmlFile(e.target.files[0]);\n"
8664
"}\n"
8665
"\n"
8666
"function ParseCompareData(Data)\n"
8667
"{\n"
8668
" S.AA = \"Original\";\n"
8669
" Comp1 = new Date();\n"
8670
"\n"
8671
" var idxbegin = Data.indexOf(\"//EBEGIN\");\n"
8672
" if(idxbegin == -1)\n"
8673
" return false;\n"
8674
" idxbegin += \"//EBEGIN\".length + 1;\n"
8675
" var idxend = Data.indexOf(\"//EEND\", idxbegin);\n"
8676
" if(idxend == -1)\n"
8677
" return false;\n"
8678
"\n"
8679
" Comp2 = new Date();\n"
8680
" var SOriginal = S;\n"
8681
" S = {};\n"
8682
"\n"
8683
" var idx = idxbegin;\n"
8684
" while(idx < idxend)\n"
8685
" {\n"
8686
" var idx0 = Data.indexOf(\'\\n\', idx);\n"
8687
" var s = Data.substring(idx, idx0);\n"
8688
" // console.log(s);\n"
8689
" eval(s);\n"
8690
" idx = idx0+1;\n"
8691
" }\n"
8692
"\n"
8693
" S.AA = \"Parsed\";\n"
8694
" var SParsed = S; //note: the calls to eval, will make a new \"S\" in local scope.\n"
8695
" SetGlobal(\"S\", S); //Set global S to point to new object, while its preprocessed\n"
8696
" Comp3 = new Date();\n"
8697
"\n"
8698
"\n"
8699
" CompareFixup(SOriginal, SParsed);\n"
8700
" Preprocess_S();\n"
8701
"\n"
8702
" var MaxStack2 = SParsed.MaxStack;\n"
8703
"\n"
8704
" var Comp4 = new Date();\n"
8705
" SetGlobal(\"S2\", SParsed);\n"
8706
" SetGlobal(\"S\", SOriginal);\n"
8707
"\n"
8708
" Preprocess_S(); //since indices are rebased, a repreprocessing is needed.\n"
8709
"\n"
8710
" SOriginal.MaxStack2 = SParsed.MaxStack;\n"
8711
" SParsed.MaxStack2 = SOriginal.MaxStack;\n"
8712
" SOriginal.SecondActive = 1;\n"
8713
"\n"
8714
"\n"
8715
" ThreadOrderSort();\n"
8716
"\n"
8717
" console.log(\'file loaded \' + idxbegin + \' \' + idxend );\n"
8718
" console.log(\'time \' + (Comp1 - Comp0));\n"
8719
" console.log(\'time \' + (Comp2 - Comp1));\n"
8720
" console.log(\'time \' + (Comp3 - Comp2).toFixed(2));\n"
8721
" console.log(\'time \' + (Comp4 - Comp3).toFixed(2));\n"
8722
" document.getElementById(\'file-input\').removeEventListener(\'change\', ReadHtmlFileHandler, false);\n"
8723
" let fname = document.getElementById(\'file-input\').value;\n"
8724
" let index = 1+Math.max(fname.lastIndexOf(\'/\'), fname.lastIndexOf(\'\\\\\'));\n"
8725
" if(index < fname.length)\n"
8726
" fname = fname.substring(index);\n"
8727
" let CompStr = \'Compare [\' + fname + \']\';\n"
8728
" RequestRedraw();\n"
8729
" return true;\n"
8730
"}\n"
8731
"\n"
8732
"function ComparePrompt()\n"
8733
"{\n"
8734
" document.getElementById(\'file-input\').addEventListener(\'change\', ReadHtmlFileHandler, false);\n"
8735
" document.getElementById(\'file-input\').click();\n"
8736
"}\n"
8737
"\n"
8738
"\n"
8739
"// magic from stack-overflow somewhere..\n"
8740
"function WindowDragEnter(e)\n"
8741
"{\n"
8742
" LastDropTarget = e.target;\n"
8743
" document.querySelector(\".dropzone\").style.visibility = \"\";\n"
8744
" document.querySelector(\".dropzone\").style.opacity = 1;\n"
8745
"};\n"
8746
"\n"
8747
"function WindowDragLeave(e)\n"
8748
"{\n"
8749
" if(e.target === LastDropTarget || e.target === document)\n"
8750
" {\n"
8751
" document.querySelector(\".dropzone\").style.visibility = \"hidden\";\n"
8752
" document.querySelector(\".dropzone\").style.opacity = 0;\n"
8753
" }\n"
8754
"};\n"
8755
"function DropHandler(ev)\n"
8756
"{\n"
8757
" document.querySelector(\".dropzone\").style.visibility = \"hidden\";\n"
8758
" document.querySelector(\".dropzone\").style.opacity = 0;\n"
8759
" LastDropTarget = null;\n"
8760
"\n"
8761
" if(ev.dataTransfer.files.length > 0)\n"
8762
" {\n"
8763
" let File = ev.dataTransfer.files[0];\n"
8764
" let Name = File.name\n"
8765
" let ExtMatch = Name.match(/\\.[0-9a-zA-Z]+$/);\n"
8766
" let Ext = ExtMatch ? ExtMatch[0] : \"\";\n"
8767
" if(Ext.toLowerCase() == \".html\")\n"
8768
" {\n"
8769
" ReadHtmlFile(File);\n"
8770
" }\n"
8771
" else\n"
8772
" {\n"
8773
" window.alert(\"Not a .html file!\\n\" + Name);\n"
8774
" }\n"
8775
" }\n"
8776
" ev.preventDefault(); \n"
8777
"}\n"
8778
"\n"
8779
"function DragOverHandler(ev)\n"
8780
"{\n"
8781
" ev.preventDefault(); \n"
8782
"}\n"
8783
"\n"
8784
"var mousewheelevt = (/Firefox/i.test(navigator.userAgent)) ? \"DOMMouseScroll\" : \"mousewheel\" //FF doesn\'t recognize mousewheel as of FF3.x\n"
8785
"\n"
8786
"CanvasDetailedView.addEventListener(\'mousemove\', MouseMove, false);\n"
8787
"CanvasDetailedView.addEventListener(\'mousedown\', function(evt) { MouseButton(true, evt); });\n"
8788
"CanvasDetailedView.addEventListener(\'mouseup\', function(evt) { MouseButton(false, evt); } );\n"
8789
"CanvasDetailedView.addEventListener(\'mouseout\', MouseOut);\n"
8790
"CanvasDetailedView.addEventListener(\"contextmenu\", function (e) { e.preventDefault(); }, false);\n"
8791
"CanvasDetailedView.addEventListener(mousewheelevt, MouseWheel, false);\n"
8792
"CanvasHistory.addEventListener(\'mousemove\', MouseMove);\n"
8793
"CanvasHistory.addEventListener(\'mousedown\', function(evt) { MouseButton(true, evt); });\n"
8794
"CanvasHistory.addEventListener(\'mouseup\', function(evt) { MouseButton(false, evt); } );\n"
8795
"CanvasHistory.addEventListener(\'mouseout\', MouseOut);\n"
8796
"CanvasHistory.addEventListener(\"contextmenu\", function (e) { e.preventDefault(); }, false);\n"
8797
"CanvasHistory.addEventListener(mousewheelevt, MouseWheel, false);\n"
8798
"CanvasMenu.addEventListener(\'mousemove\', MouseMove);\n"
8799
"CanvasMenu.addEventListener(\'mousedown\', function(evt) { MouseButton(true, evt); });\n"
8800
"CanvasMenu.addEventListener(\'mouseup\', function(evt) { MouseButton(false, evt); } );\n"
8801
"CanvasMenu.addEventListener(\'mouseout\', MouseOut);\n"
8802
"CanvasMenu.addEventListener(\"contextmenu\", function (e) { e.preventDefault(); }, false);\n"
8803
"CanvasMenu.addEventListener(mousewheelevt, MouseWheel, false);\n"
8804
"FilterInputTimer.addEventListener(\'keyup\', FilterKeyUp);\n"
8805
"FilterInputGroup.addEventListener(\'keyup\', FilterKeyUp);\n"
8806
"\n"
8807
"window.addEventListener(\'keydown\', KeyDown);\n"
8808
"window.addEventListener(\'keyup\', KeyUp);\n"
8809
"window.addEventListener(\'resize\', ResizeCanvas, false);\n"
8810
"window.addEventListener(\"dragenter\", WindowDragEnter);\n"
8811
"window.addEventListener(\"dragleave\", WindowDragLeave);\n"
8812
"document.addEventListener(\'mouseout\', (e) => {\n"
8813
" if (!e.relatedTarget && !e.toElement) {\n"
8814
" MouseOut();\n"
8815
" }\n"
8816
"});\n"
8817
"\n"
8818
"InitGroups();\n"
8819
"ReadCookie();\n"
8820
"MeasureFont();\n"
8821
"ThreadOrderSort();\n"
8822
"InitOrderArrays();\n"
8823
"InitMenu();\n"
8824
"InitFrameInfo();\n"
8825
"ResizeCanvas();\n"
8826
"Preprocess();\n"
8827
"OnPageReady();\n"
8828
"Draw(1);\n"
8829
"\n"
8830
"\n"
8831
"</script>\n"
8832
"</body>\n"
8833
"</html>";
8834
8835
const size_t g_MicroProfileHtml_end_6_size = sizeof(g_MicroProfileHtml_end_6);
8836
const char* g_MicroProfileHtml_end[] = {
8837
&g_MicroProfileHtml_end_0[0],
8838
&g_MicroProfileHtml_end_1[0],
8839
&g_MicroProfileHtml_end_2[0],
8840
&g_MicroProfileHtml_end_3[0],
8841
&g_MicroProfileHtml_end_4[0],
8842
&g_MicroProfileHtml_end_5[0],
8843
&g_MicroProfileHtml_end_6[0],
8844
};
8845
size_t g_MicroProfileHtml_end_sizes[] = {
8846
sizeof(g_MicroProfileHtml_end_0),
8847
sizeof(g_MicroProfileHtml_end_1),
8848
sizeof(g_MicroProfileHtml_end_2),
8849
sizeof(g_MicroProfileHtml_end_3),
8850
sizeof(g_MicroProfileHtml_end_4),
8851
sizeof(g_MicroProfileHtml_end_5),
8852
sizeof(g_MicroProfileHtml_end_6),
8853
};
8854
size_t g_MicroProfileHtml_end_count = 7;
8855
#endif //MICROPROFILE_EMBED_HTML
8856
8857
///end file generated from microprofile.html
8858
///start file generated from microprofilelive.html
8859
#ifdef MICROPROFILE_EMBED_HTML
8860
const char g_MicroProfileHtmlLive_begin_0[] =
8861
"<!DOCTYPE HTML>\n"
8862
"<html>\n"
8863
"<head>\n"
8864
"<title>MicroProfile Live</title>\n"
8865
"<link rel=\"manifest\" href=\'data:application/manifest+json,{\n"
8866
" \"name\":\"MicroProfile\",\n"
8867
" \"short_name\":\"MicroProfile\",\n"
8868
" \"start_url\":\"http://localhost:1338/\",\n"
8869
" \"scope\":\"http://localhost:1338/\",\n"
8870
" \"display\":\"standalone\",\n"
8871
" \"background_color\":\"black\",\n"
8872
" \"theme_color\":\"white\",\n"
8873
" \"icons\":[\n"
8874
" {\n"
8875
" \"src\":\"http://localhost:1338/favicon.png\",\n"
8876
" \"sizes\":\"512x512\",\n"
8877
" \"type\":\"image/png\"\n"
8878
" }\n"
8879
" ]\n"
8880
"}\'>\n"
8881
"\n"
8882
"<style>\n"
8883
"/* about css: http://bit.ly/1eMQ42U */\n"
8884
"body {margin: 0px;padding: 0px; font: 12px Courier New;background-color:#343434; color:white;overflow:hidden;}\n"
8885
"ul {list-style-type: none;margin: 0;padding: 0;}\n"
8886
"li{display: inline; float:left;border:5px; position:relative;text-align:center;}\n"
8887
"a {\n"
8888
" float:left;\n"
8889
" text-decoration:none;\n"
8890
" display: inline;\n"
8891
" text-align: center;\n"
8892
" padding:5px;\n"
8893
" padding-bottom:0px;\n"
8894
" padding-top:0px;\n"
8895
" color: #FFFFFF;\n"
8896
" background-color: #343434;\n"
8897
"}\n"
8898
"a:hover, a:active{\n"
8899
" background-color: #000000;\n"
8900
"}\n"
8901
"\n"
8902
"ul ul {\n"
8903
" position:absolute;\n"
8904
" left:0;\n"
8905
" top:100%;\n"
8906
" margin-left:-999em;\n"
8907
"}\n"
8908
"li:hover ul {\n"
8909
" margin-left:0;\n"
8910
" margin-right:0;\n"
8911
"}\n"
8912
"ul li ul{ display:block;float:none;width:100%;}\n"
8913
"ul li ul li{ display:block;float:none;width:100%;}\n"
8914
"li li a{ display:block;float:none;width:100%;text-align:left;}\n"
8915
"#nav li:hover div {margin-left:0;}\n"
8916
".dropzone {display:flex;justify-content:center;align-items:center;font-size:50px;position: fixed; top: 0; left: 0; z-index: 9999999999; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5);transition: visibility 175ms, opacity 175ms;}\n"
8917
".help {position:absolute;z-index:5;text-align:left;padding:2px;margin-left:-999em;background-color: #313131;width:300px;}\n"
8918
".helpstart {position:absolute;z-index:5;text-align:left;padding:2px;background-color: #313131;width:300px;display:none}\n"
8919
".root {z-index:1;position:absolute;top:0px;left:0px;}\n"
8920
".filterinputsearchdiv{position:fixed; background-color: #313131;display:none;}\n"
8921
".filterinputsearch{width:100px;}\n"
8922
" #popup-overlay {\n"
8923
" display: none;\n"
8924
" position: fixed;\n"
8925
" top: 0; left: 0;\n"
8926
" width: 100vw; height: 100vh;\n"
8927
" background-color: rgba(0, 0, 0, 0.5);\n"
8928
" align-items: center;\n"
8929
" justify-content: center;\n"
8930
" z-index: 10;\n"
8931
" }\n"
8932
"\n"
8933
" #popup-box {\n"
8934
" background: #343434;\n"
8935
" padding: 20px 30px;\n"
8936
" border-radius: 8px;\n"
8937
" box-shadow: 0 0 20px rgba(0,0,0,0.3);\n"
8938
" min-width: 320px;\n"
8939
" text-align: left;\n"
8940
" }\n"
8941
"\n"
8942
" #popup-description {\n"
8943
" margin-bottom: 15px;\n"
8944
" }\n"
8945
"\n"
8946
" .popup-field {\n"
8947
" margin-bottom: 15px;\n"
8948
" }\n"
8949
"\n"
8950
" .popup-field label {\n"
8951
" display: block;\n"
8952
" font-weight: bold;\n"
8953
" margin-bottom: 5px;\n"
8954
" }\n"
8955
"\n"
8956
" .popup-field input {\n"
8957
" width: 100%;\n"
8958
" padding: 8px;\n"
8959
" box-sizing: border-box;\n"
8960
" }\n"
8961
"\n"
8962
" .button-row {\n"
8963
" text-align: right;\n"
8964
" }\n"
8965
"\n"
8966
" #popup-box button {\n"
8967
" padding: 6px 14px;\n"
8968
" margin-top: 10px;\n"
8969
" margin-right: 10px;\n"
8970
" cursor: pointer;\n"
8971
" }\n"
8972
"</style>\n"
8973
"</head>\n"
8974
"<body style=\"\">\n"
8975
"<div style=\"visibility:hidden; opacity:0\" class=\"dropzone\" ondrop=\"DropHandler(event);\" ondragover=\"DragOverHandler(event);\">drop .csv files to view CSV data</div>\n"
8976
"<div class=\"filterinputsearchdiv\" id=\"FilterInputDiv\">Filter<br><input type=\"text\" id=\"FilterInput\" class=\"filterinputsearch\"></div>\n"
8977
"<div class=\"helpstart\" id=\"helpwindow\" style=\"left:20px;top:20px\">\n"
8978
"History View:<br>\n"
8979
"Right Click + Drag : Select Region<br>\n"
8980
"Click + Drag: Move Selection<br>\n"
8981
"Click Frame : Center on frame<br>\n"
8982
"<hr>\n"
8983
"Main View:<br>\n"
8984
"space: Freeze capturing<br>\n"
8985
"x : Toggle View<br>\n"
8986
"/ : Rotate connection port % 3<br>\n"
8987
"Ctrl + Drag: Pan<br>\n"
8988
"Click + Drag: Pan<br>\n"
8989
"Enter: Capture selection/Next N Frames\n"
8990
"<hr>\n"
8991
"<table style=\"width:100%\">\n"
8992
"<tr>\n"
8993
"<td width=\"50%\" align=\"left\"><a href=\'javascript:void(0)\' onclick=\"ShowHelp(0);\">Close</a></td>\n"
8994
"</tr>\n"
8995
"</table>\n"
8996
"</div>\n"
8997
"<div id=\"popup-overlay\">\n"
8998
" <div id=\"popup-box\">\n"
8999
" <div id=\"popup-description\"></div>\n"
9000
" <div id=\"popup-fields\"></div>\n"
9001
" <div class=\"button-row\">\n"
9002
" <button onclick=\"popupOk()\">OK</button>\n"
9003
" <button onclick=\"popupCancel()\">Cancel</button>\n"
9004
" </div>\n"
9005
" </div>\n"
9006
"</div>\n"
9007
"\n"
9008
"<canvas id=\"DetailedView\" height=\"100%\" style=\"background-color:#343434;margin:0px;padding:0px;\"></canvas>\n"
9009
"<script>\n"
9010
"\"use strict\"\n"
9011
"\n"
9012
"\n"
9013
"const popupOverlay = document.getElementById(\'popup-overlay\');\n"
9014
"const popupDescription = document.getElementById(\'popup-description\');\n"
9015
"const popupFields = document.getElementById(\'popup-fields\');\n"
9016
"let popupCallback = null;\n"
9017
"\n"
9018
"function showPopup(description, fields, callback)\n"
9019
"{\n"
9020
" popupCallback = callback;\n"
9021
" popupDescription.textContent = description;\n"
9022
" popupFields.innerHTML = \"\";\n"
9023
" fields.forEach((field, index) => {\n"
9024
" const div = document.createElement(\'div\');\n"
9025
" div.className = \'popup-field\';\n"
9026
"\n"
9027
" const label = document.createElement(\'label\');\n"
9028
" label.textContent = field.label;\n"
9029
" label.htmlFor = `popup-input-${index}`;\n"
9030
"\n"
9031
" const input = document.createElement(\'input\');\n"
9032
" input.id = `popup-input-${index}`;\n"
9033
" input.value = field.value || \'\';\n"
9034
"\n"
9035
" div.appendChild(label);\n"
9036
" div.appendChild(input);\n"
9037
" popupFields.appendChild(div);\n"
9038
" });\n"
9039
" popupOverlay.style.display = \"flex\";\n"
9040
" popupFields.querySelector(\"input\").focus();\n"
9041
"\n"
9042
"}\n"
9043
"function popupOk()\n"
9044
"{\n"
9045
" const inputs = popupFields.querySelectorAll(\"input\");\n"
9046
" const values = [];\n"
9047
" inputs.forEach((input, index) => {\n"
9048
" const label = popupFields.querySelectorAll(\"label\")[index].textContent;\n"
9049
" values[index] = input.value;\n"
9050
" });\n"
9051
" popupCallback(values);\n"
9052
" popupCallback = null;\n"
9053
" popupOverlay.style.display = \"none\";\n"
9054
"}\n"
9055
"function popupCancel() {\n"
9056
" popupCallback = null;\n"
9057
" popupOverlay.style.display = \"none\";\n"
9058
"}\n"
9059
"\n"
9060
"\n"
9061
"var FRAME_HISTORY_COLOR_CPU = \'#ff7f27\';\n"
9062
"var FRAME_HISTORY_COLOR_GPU = \'#ffffff\';\n"
9063
"\n"
9064
"var Settings = {};\n"
9065
"var Cookie = {};\n"
9066
"\n"
9067
"const PERCENTILE_SAMPLES = 1000;\n"
9068
"\n"
9069
"var HistoryHeight = 100;\n"
9070
"var CanvasDetailedView = document.getElementById(\'DetailedView\');\n"
9071
"var CanvasDetailedOffscreen = document.createElement(\'canvas\');\n"
9072
"var FilterInput = document.getElementById(\'FilterInput\');\n"
9073
"var FilterInputDiv = document.getElementById(\'FilterInputDiv\');\n"
9074
"var FilterInputDivPos = {\"x\":-1,\"y\":-1,\"w\":-1,\"h\":-1};\n"
9075
"var FilterInputValueLast = \'\';\n"
9076
"\n"
9077
"var CanvasArray0 = [];\n"
9078
"var CanvasArray1 = [];\n"
9079
"var Views = [];\n"
9080
"\n"
9081
"var ViewIndex = 0;\n"
9082
"\n"
9083
"var nWidth = CanvasDetailedView.width;\n"
9084
"var nHeight = CanvasDetailedView.height;\n"
9085
"var nBackColors = [\'#292929\', \'#343434\' ];\n"
9086
"var nBackColorsDark = [\'#292929\', \'#272727\' ];\n"
9087
"var nBackColorOffset = \'#404040\';\n"
9088
"const FontHeight = 10;\n"
9089
"const FontHeightLarge = 12;\n"
9090
"const FontHeightLarger = 22;\n"
9091
"var FontWidth = 1;\n"
9092
"var FontAscent = 3; //Set manually\n"
9093
"const Font = \'Bold \' + FontHeight + \'px Courier New\';\n"
9094
"const FontLarge = \'Bold \' + FontHeightLarge + \'px Courier New\';\n"
9095
"const FontLarger = \'Bold \' + FontHeightLarger + \'px Courier New\';\n"
9096
"const FontFlash = \'Bold \' + 35 + \'px Courier New\';\n"
9097
"var BoxHeight = FontHeight + 2;\n"
9098
"var MouseX = 0;\n"
9099
"var MouseY = 0;\n"
9100
"var MouseReleased = false;\n"
9101
"var MouseMoveTime = new Date();\n"
9102
"\n"
9103
"var nBarsWidth = 80;\n"
9104
"var nOffsetBarsX = 0;\n"
9105
"var nOffsetBarsY = 0;\n"
9106
"var nOffsetCountersY = 0;\n"
9107
"var nOffsetMenuTimers = 0;\n"
9108
"var nOffsetMenuGroup = 0;\n"
9109
"var nOffsetMenuCounters = 0;\n"
9110
"var nOffsetMenuFunctions = 0;\n"
9111
"var nOffsetMenuModules = 0;\n"
9112
"var nOffsetMenuPatched = 0;\n"
9113
"\n"
9114
"var nHoverCounter = -1;\n"
9115
"\n"
9116
"var MouseDragOff = 0;\n"
9117
"var MouseDragDown = 1;\n"
9118
"var MouseDragUp = 2;\n"
9119
"var MouseDragMove = 3;\n"
9120
"var MouseDragState = MouseDragOff;\n"
9121
"var MouseDragTarget = 0;\n"
9122
"var MouseDragButton = 0;\n"
9123
"var MouseDragKeyShift = 0;\n"
9124
"var MouseDragKeyCtrl = 0;\n"
9125
"var MouseDragX = 0;\n"
9126
"var MouseDragY = 0;\n"
9127
"var MouseDragXLast = 0;\n"
9128
"var MouseDragYLast = 0;\n"
9129
"var MouseDragXStart = 0;\n"
9130
"var MouseDragYStart = 0;\n"
9131
"\n"
9132
"var MouseDragActiveXStart = 0;\n"
9133
"var MouseDragActiveXEnd = -1;\n"
9134
"var MouseInCaptureButton = 0;\n"
9135
"\n"
9136
"var ToolTipCallback = null;\n"
9137
"\n"
9138
"var DPR = 0;\n"
9139
"var C_HUGE = 1e10;\n"
9140
"\n"
9141
"var ActivePreset = \"Default\";\n"
9142
"var ActivePresetRO = 0;\n"
9143
"var PresetPending = 0;\n"
9144
"var Presets = [];\n"
9145
"var PresetsCache = {};\n"
9146
"var ReadOnlyPresets = [];\n"
9147
"var ReadOnlyPresetsCache = {};\n"
9148
"\n"
9149
"Settings.SubGraphSettings = {};\n"
9150
"Settings.SubGraphSettingsPercentile = {};\n"
9151
"Settings.ReferenceTime = 100.0;\n"
9152
"\n"
9153
"const ReferencePresets = [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1.0, 2.0, 5.0, 10.0, 15.0, 20, 30, 33.33, 50, 66.66,100.0,250.0,500,1000.0];\n"
9154
"const PercentilePresets = [0.0, 1.0, 5.0, 10.0, 50.0, 75.0, 99.0];\n"
9155
"let ReferenceTimeTweak = -1;\n"
9156
"const CounterByteNames = [\"bytes\", \"kilobytes\", \"megabytes\", \"gigabytes\"];\n"
9157
"let PercentileTweak = -1;\n"
9158
"\n"
9159
"Settings.TargetTime = 15;\n"
9160
"var TargetTimeTweak = -1;\n"
9161
"\n"
9162
"Settings.GraphSoftFrames = 5;\n"
9163
"Settings.GraphSoftMode = 0;\n"
9164
"const GraphSoftFramePresets = [2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30];\n"
9165
"const GraphSoftFrameModeNames = [\"off\", \"avg\", \"min\", \"max\"];\n"
9166
"\n"
9167
"\n"
9168
"var AggregateFrames = 60;\n"
9169
"Settings.AggregateFrames = 60;\n"
9170
"var AggregatePresets = [0, 10,20,30,60,90,120,500];\n"
9171
"var AggregateHistorySize = 5;\n"
9172
"var AggregateTweak = -1;\n"
9173
"var AggregateCurrent = 0;\n"
9174
"\n"
9175
"var AutoCaptureCooldown = -1;\n"
9176
"var AutoCaptureEnabled = 0;\n"
9177
"var AutoCaptureDefaultThreshold = 66;\n"
9178
"Settings.AutoCaptureTheshold = AutoCaptureDefaultThreshold;\n"
9179
"Settings.AutoCaptureRepeat = 1;\n"
9180
"var AutoCaptureThesholdPresets = [1,3,5,10,15,30,50,66,90,100,250,500,1000];\n"
9181
"var AutoCaptureRepeatPresets = [1,2,3,4,5,6,7,8,9,10, 25, 50, 100];\n"
9182
"var AutoCaptureTweak = -1;\n"
9183
"var AutoCaptureRepeatTweak = -1;\n"
9184
"var AutoCaptureSourceTweak = -1;\n"
9185
"var AutoCaptureSourceIndex = -1;\n"
9186
"\n"
9187
"var CaptureFramesDefault = 30;\n"
9188
"Settings.CaptureFrames = CaptureFramesDefault;\n"
9189
"Settings.CaptureDelay = 0;\n"
9190
"var CaptureFramesPresets = [5,10,15,30,50,66,90,100];\n"
9191
"var CaptureDelayPresets = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n"
9192
"var CaptureTweak = -1;\n"
9193
"var CaptureDelayTweak = -1;\n"
9194
"\n"
9195
"var CaptureTriggerTime = null;\n"
9196
"var CaptureTriggerTimeType = 0;\n"
9197
"var CaptureTriggerDelta = 0;\n"
9198
"\n"
9199
"let LastDropTarget = null;\n"
9200
"\n"
9201
"\n"
9202
"\n"
9203
"var ProfileData = {};\n"
9204
"var ProfileStackTime = [];\n"
9205
"var ProfileStackName = [];\n"
9206
"var ProfileMode = 0;\n"
9207
"var ProfileRedraw0 = 0;\n"
9208
"var ProfileRedraw1 = 0;\n"
9209
"var ProfileRedraw2 = 0;\n"
9210
"var ProfileFps = 0;\n"
9211
"var ProfileMs = 0;\n"
9212
"var ProfileFpsAggr = 0;\n"
9213
"var ProfileFpsCount = 0;\n"
9214
"var ProfileLastTimeStamp = new Date();\n"
9215
"var PlotfArray = new Array();\n"
9216
"\n"
9217
"var ConnectionStr = [\"\\\\\", \"|\", \"/\", \"-\" ];\n"
9218
"var ConnectionIdx = 0;\n"
9219
"var EnabledArray = [];\n"
9220
"\n"
9221
"\n"
9222
"var FrameData = {};\n"
9223
"var FRAME_COUNT = 1000;\n"
9224
"var FramePending = 0;\n"
9225
"\n"
9226
"var WSConnected = 0;\n"
9227
"var WSIsOpen = 0;\n"
9228
"var WSSeconds = 0;\n"
9229
"var WSFail = 0;\n"
9230
"var WS;\n"
9231
"var WSHost = location.hostname ? location.hostname : \"localhost\";\n"
9232
"var WSPort = location.port ? location.port : 1338;\n"
9233
"var WSPath;\n"
9234
"\n"
9235
"var CaptureButtonX = 0;\n"
9236
"var CaptureButtonY = 0;\n"
9237
"var GroupsEnabled = 0;\n"
9238
"var TimersEnabled = 0;\n"
9239
"let CountersEnabled = 0;\n"
9240
"\n"
9241
"var TimersActiveOnly = 0;\n"
9242
"\n"
9243
"\n"
9244
"const MSG_TIMER_TREE = 1;\n"
9245
"const MSG_ENABLED = 2;\n"
9246
"const MSG_FRAME = 3;\n"
9247
"const MSG_LOADSETTINGS = 4;\n"
9248
"const MSG_PRESETS = 5;\n"
9249
"const MSG_CURRENTSETTINGS = 6;\n"
9250
"const MSG_COUNTERS = 7;\n"
9251
"const MSG_FUNCTION_RESULTS = 8;\n"
9252
"const MSG_INACTIVE_FRAME = 9;\n"
9253
"const MSG_FUNCTION_NAMES = 10;\n"
9254
"const MSG_INSTRUMENT_ERROR = 11;\n"
9255
"const MSG_QUERY_INDEX = 12;\n"
9256
"\n"
9257
"\n"
9258
"const TYPE_NONE = 0;\n"
9259
"const TYPE_TIMER = 1;\n"
9260
"const TYPE_GROUP = 2;\n"
9261
"const TYPE_CATEGORY = 3;\n"
9262
"const TYPE_SETTING = 4;\n"
9263
"const TYPE_COUNTER = 5;\n"
9264
"\n"
9265
"const MicroProfileTokenTypeCpu=0;\n"
9266
"const MicroProfileTokenTypeGpu=1;\n"
9267
"\n"
9268
"\n"
9269
"let WSSend = 0;\n"
9270
"let WSReceive = 0;\n"
9271
"let WSSendBytes = 0;\n"
9272
"let WSReceiveBytes = 0;\n"
9273
"let WSOpenTime = 0;\n"
9274
"let WSReadyState = 9999;\n"
9275
"\n"
9276
"\n"
9277
"var TimerArray = [];\n"
9278
"var CounterArray = [];\n"
9279
"var Empty = {\"id\":0, \"w\":0, \"depth\":0, \"sibling\":-1,\"parent\":-1,\"firstchild\":-1};\n"
9280
"var WidthArray = [];\n"
9281
"var FunctionQueryArray = [];\n"
9282
"var FunctionQueryPending = null;\n"
9283
"var FunctionQueryLastRequest = 0;\n"
9284
"var FunctionQueryReceived = 0;\n"
9285
"var WidthTree = 0;\n"
9286
"Settings.ViewActive = 0;\n"
9287
"Settings.ViewCompressed = 0;\n"
9288
"Settings.AllowHighDPI = 1;\n"
9289
"let ViewCompressedTimeout = -1;\n"
9290
"const ViewNames = [\"Graph\", \"Graph\", \"Graph\", \"Bars\", \"Bars\", \"Bars\", \"Counters\"];\n"
9291
"const ViewNames2 = [\"[split]\", \"[percentile]\",\"[group/thread]\",\"[table]\", \"[all]\", \"[single]\", \"\"];\n"
9292
"\n"
9293
"const VIEW_GRAPH_SPLIT = 0;\n"
9294
"// var VIEW_GRAPH = 1;\n"
9295
"const VIEW_GRAPH_PERCENTILE = 1;\n"
9296
"const VIEW_GRAPH_THREAD_GROUP = 2;\n"
9297
"const VIEW_BAR = 3;\n"
9298
"const VIEW_BAR_ALL = 4;\n"
9299
"const VIEW_BAR_SINGLE = 5;\n"
9300
"const VIEW_COUNTERS = 6;\n"
9301
"const VIEW_SIZE = 7;\n"
9302
"const GRAPH_ALPHA = 0.5;\n"
9303
"\n"
9304
"\n"
9305
"Settings.AutomaticReference = 0;\n"
9306
"Cookie.CodeReportMode = 0; // 0: prompt, 1:always send, 2: never send, never prompt\n"
9307
"\n"
9308
"\n"
9309
"let ReferenceHistory = 0;\n"
9310
"let ReferenceGraph = 0;\n"
9311
"let ReferenceBar = 0;\n"
9312
"let ReferenceHistoryAutomatic = 0;\n"
9313
"let ReferenceGraphAutomatic = 0;\n"
9314
"let ReferenceGraphAutomaticGroup = 0;\n"
9315
"let ReferenceBarAutomatic = 0;\n"
9316
"\n"
9317
"let SingleTimerBars = 0;\n"
9318
"let History;\n"
9319
"let MainView;\n"
9320
"let X7Views;\n"
9321
"let X7LegendView;\n"
9322
"let X7BarColumnRemap = [0,1,2,3,4,5,6];\n"
9323
"let X7BarColumnMask = -1;\n"
9324
"let X7LegendOffset = 25;\n"
9325
"let X7BarLastView = -1;\n"
9326
"let X7BarFirstView = -1;\n"
9327
"\n"
9328
"\n"
9329
"let ViewBarMaxMsTextLength = 0;\n"
9330
"\n"
9331
"Settings.SortColumnOrderFlip = 0;\n"
9332
"Settings.SortColumnName = \"\";\n"
9333
"var SortColumnMouseOverNext = \"\";\n"
9334
"\n"
9335
"\n"
9336
"let KeyShiftDown = 0;\n"
9337
"let KeyCtrlDown = 0;\n"
9338
"let PromptActive = 0;\n"
9339
"let PromptExitTime = new Date();\n"
9340
"\n"
9341
"let IsFrozen = 0;\n"
9342
"\n"
9343
"let PresetToLoad;\n"
9344
"let PresetToLoadRO = 0;\n"
9345
"let HelpFade;\n"
9346
"\n"
9347
"\n"
9348
"TimerArray.push(Empty); // 0 is root of tree\n"
9349
"\n"
9350
"const StrTime = \"Time\";\n"
9351
"const StrExclusive = \"Excl Time\";\n"
9352
"const StrGroup = \"Group\";\n"
9353
"const StrThread = \"Thread\";\n"
9354
"const StrTimer = \"Timer\";\n"
9355
"const StrAverage = \"Average\";\n"
9356
"const StrMax = \"Max\";\n"
9357
"const StrTotal = \"Total\";\n"
9358
"const StrExclTotal = \"Excl Total\";\n"
9359
"const StrMin = \"Min\";\n"
9360
"const StrSpike = \"Spike%\";\n"
9361
"const StrCallAverage = \"Call Average\";\n"
9362
"const StrCount = \"Count\";\n"
9363
"const StrExclAverage = \"Excl Average\";\n"
9364
"const StrExclMax = \"Excl Max\";\n"
9365
"const StrExclMin = \"Excl Max\";\n"
9366
"const StrCallExclAverage = \"Call Excl Avg\";\n"
9367
"\n"
9368
"\n"
9369
"let CounterNameWidth = 100;\n"
9370
"let CounterNameMenuWidth = 100;\n"
9371
"let CounterFullNameWidth = 100;\n"
9372
"let CounterValueWidth = 100;\n"
9373
"let CounterLimitWidth = 100;\n"
9374
"\n"
9375
"const FormatCounterDefault = 0;\n"
9376
"const FormatCounterBytes = 1;\n"
9377
"const FormatCounterBytesExt = [\"b\",\"kb\",\"mb\",\"gb\",\"tb\",\"pb\",\"eb\",\"zb\",\"yb\"];\n"
9378
"\n"
9379
"const BarColumnNamesTable = [StrTime, StrExclusive, StrAverage, StrMax, StrMin, StrTotal, StrExclAverage, StrExclMax, StrExclTotal, StrSpike, StrCallAverage, StrCallExclAverage, StrCount];\n"
9380
"const BarColumnNamesMulti = [StrTime, StrAverage, StrMax, StrMin, StrExclAverage, StrExclMax, StrExclMin];\n"
9381
"const BarColumnNamesSingle = [StrAverage, StrMax, StrMin, StrExclAverage, StrExclMax, StrExclMin, StrCallAverage];\n"
9382
"\n"
9383
"// var SYMBOLSTATE_DEFAULT = 0;\n"
9384
"// var SYMBOLSTATE_LOADING = 1;\n"
9385
"// var SYMBOLSTATE_DONE = 2;\n"
9386
"\n"
9387
"\n"
9388
"var SymbolState;\n"
9389
"var ModuleState = [];\n"
9390
"\n"
9391
"var FunctionsInstrumented = [];\n"
9392
"var FunctionsInstrumentedUnmangled = [];\n"
9393
"var FunctionsInstrumentedModule = [];\n"
9394
"var PopupsAllowed = 0;\n"
9395
"var PopupsFailed = 0;\n"
9396
"var PopupTestPending = 0;\n"
9397
"\n"
9398
"var ThreadInfo = {};\n"
9399
"\n"
9400
"function ConvertHslToRGB(h, s, l) //from https://gist.github.com/mjackson/5311256\n"
9401
"{\n"
9402
" var r, g, b;\n"
9403
" if (s == 0)\n"
9404
" {\n"
9405
" r = g = b = l; // achromatic\n"
9406
" }\n"
9407
" else\n"
9408
" {\n"
9409
" function hue2rgb(p, q, t)\n"
9410
" {\n"
9411
" if (t < 0) t += 1;\n"
9412
" if (t > 1) t -= 1;\n"
9413
" if (t < 1/6) return p + (q - p) * 6 * t;\n"
9414
" if (t < 1/2) return q;\n"
9415
" if (t < 2/3) return p + (q - p) * (2/3 - t) * 6;\n"
9416
" return p;\n"
9417
" }\n"
9418
" var q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n"
9419
" var p = 2 * l - q;\n"
9420
" r = hue2rgb(p, q, h + 1/3);\n"
9421
" g = hue2rgb(p, q, h);\n"
9422
" b = hue2rgb(p, q, h - 1/3);\n"
9423
" }\n"
9424
" var color = ((r*255)<<16) | ((g*255)<<8) | (b*255);\n"
9425
" return (\"000000\" + color.toString(16)).slice(-6);\n"
9426
"}\n"
9427
"\n"
9428
"\n"
9429
"function GetBarColumnNames()\n"
9430
"{\n"
9431
" if(Settings.ViewActive == VIEW_BAR_ALL)\n"
9432
" {\n"
9433
" return BarColumnNamesMulti;\n"
9434
" }\n"
9435
" else if(Settings.ViewActive == VIEW_BAR_SINGLE)\n"
9436
" {\n"
9437
" return BarColumnNamesSingle;\n"
9438
" }\n"
9439
" else\n"
9440
" {\n"
9441
" return BarColumnNamesTable;\n"
9442
" }\n"
9443
"}\n"
9444
"function GetBarColumnEnabled()\n"
9445
"{\n"
9446
" if(Settings.ViewActive == VIEW_BAR_ALL)\n"
9447
" {\n"
9448
" return Settings.BarColumnEnabledMulti;\n"
9449
" }\n"
9450
" else if(Settings.ViewActive == VIEW_BAR_SINGLE)\n"
9451
" {\n"
9452
" return Settings.BarColumnEnabledSingle;\n"
9453
" }\n"
9454
" else\n"
9455
" {\n"
9456
" return Settings.BarColumnEnabledTable;\n"
9457
" }\n"
9458
"}\n"
9459
"\n"
9460
"Settings.BarColumnEnabledTable = new Array(BarColumnNamesTable.length);\n"
9461
"Settings.BarColumnEnabledSingle = new Array(BarColumnNamesSingle.length);\n"
9462
"Settings.BarColumnEnabledMulti = new Array(BarColumnNamesMulti.length);\n"
9463
"var ColumnsWidth = new Array(BarColumnNamesTable.length);\n"
9464
"function ClearEnabled(E)\n"
9465
"{\n"
9466
" for(var i = 0; i < E.length; ++i)\n"
9467
" {\n"
9468
" E[i] = 1;\n"
9469
" ColumnsWidth[i] = 10;\n"
9470
" }\n"
9471
"}\n"
9472
"ClearEnabled(Settings.BarColumnEnabledTable);\n"
9473
"ClearEnabled(Settings.BarColumnEnabledSingle);\n"
9474
"ClearEnabled(Settings.BarColumnEnabledMulti);\n"
9475
"\n"
9476
"function Plotf(str)\n"
9477
"{\n"
9478
" PlotfArray.push(str);\n"
9479
"}\n"
9480
"function PlotfClear()\n"
9481
"{\n"
9482
" PlotfArray = new Array();\n"
9483
"}\n"
9484
"\n"
9485
"function ProfileModeClear()\n"
9486
"{\n"
9487
" if(ProfileMode)\n"
9488
" {\n"
9489
" for(var idx in ProfileData)\n"
9490
" {\n"
9491
" if(idx == \"Plot\")\n"
9492
" continue;\n"
9493
" var Timer = ProfileData[idx];\n"
9494
" Timer.Count = 0;\n"
9495
" Timer.Time = 0;\n"
9496
" }\n"
9497
"\n"
9498
" // ProfileData = new Object();\n"
9499
" ProfileStackTime = new Array();\n"
9500
" ProfileStackName = new Array();\n"
9501
" }\n"
9502
"}\n"
9503
"function ProfileEnter(Name)\n"
9504
"{\n"
9505
" if(ProfileMode)\n"
9506
" {\n"
9507
" ProfileStackTime.push(performance.now());\n"
9508
" ProfileStackName.push(Name);\n"
9509
" }\n"
9510
"}\n"
9511
"function ProfileLeave()\n"
9512
"{\n"
9513
" if(ProfileMode)\n"
9514
" {\n"
9515
" var Time = performance.now();\n"
9516
" var Delta = Time - ProfileStackTime.pop();\n"
9517
" var Name = ProfileStackName.pop();\n"
9518
" var Obj = ProfileData[Name];\n"
9519
" if(!Obj)\n"
9520
" {\n"
9521
" Obj = new Object();\n"
9522
" Obj.Count = 0;\n"
9523
" Obj.Name = Name;\n"
9524
" Obj.Time = 0;\n"
9525
" Obj.AggrCount = 0;\n"
9526
" Obj.AggrTime = 0;\n"
9527
" Obj.AggrMax = 0;\n"
9528
" Obj.AvgTime = 0;\n"
9529
" Obj.MaxTime = 0;\n"
9530
" Obj.TotalTime = 0;\n"
9531
" ProfileData[Name] = Obj;\n"
9532
" }\n"
9533
" Obj.Time += Delta;\n"
9534
" Obj.Count += 1;\n"
9535
" }\n"
9536
"}\n"
9537
"\n"
9538
"function ProfilePlot(s)\n"
9539
"{\n"
9540
" if(ProfileMode)\n"
9541
" {\n"
9542
" var A = ProfileData.Plot;\n"
9543
" if(!A)\n"
9544
" {\n"
9545
" ProfileData.Plot = Array();\n"
9546
" A = ProfileData.Plot;\n"
9547
" }\n"
9548
" if(A.length<10)\n"
9549
" {\n"
9550
" A.push(s);\n"
9551
" }\n"
9552
" }\n"
9553
"}\n"
9554
"function ProfileModeDump()\n"
9555
"{\n"
9556
" for(var idx in ProfileData)\n"
9557
" {\n"
9558
" var Timer = ProfileData[idx];\n"
9559
" console.log(Timer.Name + \" \" + Timer.Time + \"ms \" + Timer.Count);\n"
9560
" }\n"
9561
"\n"
9562
"}\n"
9563
"function ProfileModeDraw(Canvas)\n"
9564
"{\n"
9565
" if(ProfileMode)\n"
9566
" {\n"
9567
" ProfileFpsCount ++ ;\n"
9568
" var AggrFrames = 60;\n"
9569
" var StringArray = [];\n"
9570
" function FormatTime(f)\n"
9571
" {\n"
9572
" return (\" \" + f.toFixed(2)).slice(-12);\n"
9573
" }\n"
9574
" function FormatStr(t, count, avg, max, total)\n"
9575
" {\n"
9576
" var str = FormatTime(t) + \"ms \" + (\" #\" + count).slice(-8) +\n"
9577
" \"\" + FormatTime(avg) + \"ms \" + FormatTime(max) + \"ms \" + FormatTime(total) + \"ms\";\n"
9578
" return str;\n"
9579
" }\n"
9580
" StringArray.push(\"\");\n"
9581
" StringArray.push(\"time count avg max total/\" + AggrFrames + \" \");\n"
9582
"\n"
9583
" for(var idx in ProfileData)\n"
9584
" {\n"
9585
" if(idx == \"Plot\")\n"
9586
" continue;\n"
9587
" var Timer = ProfileData[idx];\n"
9588
" Timer.AggrCount += Timer.Count;\n"
9589
" Timer.AggrTime += Timer.Time;\n"
9590
" Timer.AggrMax = Math.max(Timer.AggrMax, Timer.Time);\n"
9591
" if(ProfileFpsCount == AggrFrames)\n"
9592
" {\n"
9593
" Timer.AvgTime = Timer.AggrTime / AggrFrames;\n"
9594
" Timer.MaxTime = Timer.AggrMax;\n"
9595
" Timer.TotalTime = Timer.AggrTime;\n"
9596
" Timer.AggrCount = 0;\n"
9597
" Timer.AggrTime = 0;\n"
9598
" Timer.AggrMax = 0;\n"
9599
" }\n"
9600
" StringArray.push(Timer.Name);\n"
9601
" StringArray.push(FormatStr(Timer.Time, Timer.Count, Timer.AvgTime, Timer.MaxTime, Timer.TotalTime));\n"
9602
" }\n"
9603
" var Time = new Date();\n"
9604
" var Delta = Time - ProfileLastTimeStamp;\n"
9605
" ProfileLastTimeStamp = Time;\n"
9606
" StringArray.push(\"Frame Delta\");\n"
9607
" StringArray.push(Delta + \"ms\");\n"
9608
" {\n"
9609
" ProfileFpsAggr += Delta;\n"
9610
"\n"
9611
" if(ProfileFpsCount == AggrFrames)\n"
9612
" {\n"
9613
" ProfileMs = ProfileFpsAggr / AggrFrames;\n"
9614
" ProfileFps = 1000 / (ProfileFpsAggr / AggrFrames);\n"
9615
" ProfileFpsAggr = 0;\n"
9616
" ProfileFpsCount = 0;\n"
9617
" }\n"
9618
" StringArray.push(\"Avg FPS\");\n"
9619
" StringArray.push(\"\" + ProfileFps.toFixed(2));\n"
9620
" StringArray.push(\"Avg MS\");\n"
9621
" StringArray.push(\"\" + ProfileMs.toFixed(2));\n"
9622
" }\n"
9623
" for(var i = 0; i < ProfileData.Plot; ++i)\n"
9624
" {\n"
9625
" StringArray.push(\"\");\n"
9626
" StringArray.push(ProfileData.Plot[i]);\n"
9627
" }\n"
9628
" ProfileData.Plot = Array();\n"
9629
" DrawToolTip(StringArray, Canvas, 0, 200);\n"
9630
" }\n"
9631
"}\n"
9632
"\n"
9633
"\n"
9634
"\n"
9635
"function MeasureFont()\n"
9636
"{\n"
9637
" var context = CanvasDetailedView.getContext(\'2d\');\n"
9638
" context.font = Font;\n"
9639
" FontWidth = context.measureText(\'W\').width;\n"
9640
"\n"
9641
"}\n"
9642
"function ResizeCanvasDPR(w, h, c)\n"
9643
"{\n"
9644
" DPR = Settings.AllowHighDPI ? window.devicePixelRatio : 0;\n"
9645
" if(DPR)\n"
9646
" {\n"
9647
" c.style.width = w + \'px\';\n"
9648
" c.style.height = h + \'px\';\n"
9649
" c.width = w * DPR;\n"
9650
" c.height = h * DPR;\n"
9651
" c.getContext(\'2d\').scale(DPR,DPR);\n"
9652
" }\n"
9653
" else\n"
9654
" {\n"
9655
" DPR = 1;\n"
9656
" c.width = w;\n"
9657
" c.height = h;\n"
9658
" }\n"
9659
"\n"
9660
"}\n"
9661
"\n"
9662
"function ResizeCanvasDPR2(w, h, c)\n"
9663
"{\n"
9664
" DPR = window.devicePixelRatio;\n"
9665
" if(DPR)\n"
9666
" {\n"
9667
" c.style.width = w + \'px\';\n"
9668
" c.style.height = h + \'px\';\n"
9669
" c.width = w * DPR;\n"
9670
" c.height = h * DPR;\n"
9671
" c.getContext(\'2d\').scale(DPR,DPR);\n"
9672
" }\n"
9673
" else\n"
9674
" {\n"
9675
" c.width = w;\n"
9676
" c.height = h;\n"
9677
" }\n"
9678
"\n"
9679
"}\n"
9680
"function ResizeView(View, x, y, w, h)\n"
9681
"{\n"
9682
" View.x = x;\n"
9683
" View.y = y;\n"
9684
" View.w = w;\n"
9685
" View.h = h;\n"
9686
" var c0 = View.Canvas[0];\n"
9687
" var c1 = View.Canvas[1];\n"
9688
" ResizeCanvasDPR(w, h, c0);\n"
9689
" ResizeCanvasDPR(w, h, c1);\n"
9690
" c0.getContext(\'2d\').clearRect(0, 0, w, h);\n"
9691
" c1.getContext(\'2d\').clearRect(0, 0, w, h);\n"
9692
" View.OffscreenData[0] = c0.getContext(\'2d\').getImageData(0, 0, c0.width, c0.height);\n"
9693
" View.OffscreenData[1] = c1.getContext(\'2d\').getImageData(0, 0, c1.width, c1.height);\n"
9694
"\n"
9695
"}\n"
9696
"function CreateView(x, y, w, h, name, DisplayFunc, visible, index)\n"
9697
"{\n"
9698
" var idx = Views.length;\n"
9699
" var c0 = CanvasArray0[idx];\n"
9700
" var c1 = CanvasArray1[idx];\n"
9701
" if(!c0)\n"
9702
" {\n"
9703
" c0 = document.createElement(\'canvas\');\n"
9704
" CanvasArray0[idx] = c0;\n"
9705
" }\n"
9706
" if(!c1)\n"
9707
" {\n"
9708
" c1 = document.createElement(\'canvas\');\n"
9709
" CanvasArray1[idx] = c1;\n"
9710
" }\n"
9711
" var View = {};\n"
9712
" View.x = x;\n"
9713
" View.y = y;\n"
9714
" View.w = w;\n"
9715
" View.h = h;\n"
9716
" View.Canvas = [c0, c1];\n"
9717
" View.OffscreenData = [null, null];\n"
9718
" View.visible = visible;\n"
9719
" View.index = index;\n"
9720
" ResizeCanvasDPR(w, h, c0);\n"
9721
" ResizeCanvasDPR(w, h, c1);\n"
9722
"\n"
9723
" c0.getContext(\'2d\').clearRect(0, 0, w, h);\n"
9724
" c1.getContext(\'2d\').clearRect(0, 0, w, h);\n"
9725
" View.OffscreenData[0] = c0.getContext(\'2d\').getImageData(0, 0, c0.width, c0.height);\n"
9726
" View.OffscreenData[1] = c1.getContext(\'2d\').getImageData(0, 0, c1.width, c1.height);\n"
9727
" View.BackBuffer = 0;\n"
9728
" View.DisplayFunc = DisplayFunc;\n"
9729
" Views.push(View);\n"
9730
" return View;\n"
9731
"}\n"
9732
"\n"
9733
"function CreateViews(Width, Height, ViewCompressed)\n"
9734
"{\n"
9735
" Views = [];\n"
9736
" var HistoryH = ViewCompressed ? 0 : HistoryHeight;\n"
9737
" History = CreateView(0, 0, Width, HistoryHeight, \"History\", DrawHistory, true, 0);\n"
9738
" History.visible = !ViewCompressed;\n"
9739
" MainView = CreateView(0, HistoryH, Width, Height-HistoryH, \"Main\", DrawGraphSplit, true);\n"
9740
" X7Views = [];\n"
9741
" var w = Width / 7;\n"
9742
" var x = 0;\n"
9743
" X7Views.push(CreateView(w*0, HistoryH, w, Height - HistoryH, \"x5_0\", DrawBars, false, 0) );\n"
9744
" X7Views.push(CreateView(w*1, HistoryH, w, Height - HistoryH, \"x5_1\", DrawBars, false, 1) );\n"
9745
" X7Views.push(CreateView(w*2, HistoryH, w, Height - HistoryH, \"x5_2\", DrawBars, false, 2) );\n"
9746
" X7Views.push(CreateView(w*3, HistoryH, w, Height - HistoryH, \"x5_3\", DrawBars, false, 3) );\n"
9747
" X7Views.push(CreateView(w*4, HistoryH, w, Height - HistoryH, \"x5_4\", DrawBars, false, 4) );\n"
9748
" X7Views.push(CreateView(w*5, HistoryH, w, Height - HistoryH, \"x5_3\", DrawBars, false, 5) );\n"
9749
" X7Views.push(CreateView(w*6, HistoryH, w, Height - HistoryH, \"x5_3\", DrawBars, false, 6) );\n"
9750
" X7LegendView = CreateView(0, Height-X7LegendOffset, Width, X7LegendOffset, \"x7_legend\", DrawBarsLegend, false, 0);\n"
9751
"\n"
9752
"}\n"
9753
"\n"
9754
"function ResizeCanvas()\n"
9755
"{\n"
9756
" nWidth = window.innerWidth;\n"
9757
" nHeight = window.innerHeight;\n"
9758
" DPR = Settings.AllowHighDPI ? window.devicePixelRatio : 0;\n"
9759
" ResizeCanvasDPR(nWidth, nHeight, CanvasDetailedView);\n"
9760
" ResizeCanvasDPR(nWidth, nHeight, CanvasDetailedOffscreen);\n"
9761
"\n"
9762
" if(DPR)\n"
9763
" {\n"
9764
" CanvasDetailedView.style.width = nWidth + \'px\';\n"
9765
" CanvasDetailedView.style.height = nHeight + \'px\';\n"
9766
" CanvasDetailedView.width = nWidth * DPR;\n"
9767
" CanvasDetailedView.height = nHeight * DPR;\n"
9768
" CanvasDetailedView.getContext(\'2d\').scale(DPR,DPR);\n"
9769
"\n"
9770
" CanvasDetailedOffscreen.style.width = nWidth + \'px\';\n"
9771
" CanvasDetailedOffscreen.style.height = nHeight + \'px\';\n"
9772
" CanvasDetailedOffscreen.width = nWidth * DPR;\n"
9773
" CanvasDetailedOffscreen.height = nHeight * DPR;\n"
9774
" CanvasDetailedOffscreen.getContext(\'2d\').scale(DPR,DPR);\n"
9775
"\n"
9776
" }\n"
9777
" else\n"
9778
" {\n"
9779
" DPR = 1;\n"
9780
" CanvasDetailedView.width = nWidth;\n"
9781
" CanvasDetailedView.height = nHeight;\n"
9782
" CanvasDetailedOffscreen.width = nWidth;\n"
9783
" CanvasDetailedOffscreen.height = nHeight;\n"
9784
" }\n"
9785
" MeasureFont();\n"
9786
" CreateViews(nWidth, nHeight, Settings.ViewCompressed);\n"
9787
" ActivateView(Settings.ViewActive);\n"
9788
"}\n"
9789
"\n"
9790
"function FormatTime(Time, Ref)\n"
9791
"{\n"
9792
" if(!Ref)\n"
9793
" {\n"
9794
" return Time.toFixed(3);\n"
9795
" }\n"
9796
" else\n"
9797
" {\n"
9798
" let r = 3;\n"
9799
" if(Ref < 1.0)\n"
9800
" {\n"
9801
" r = Math.floor(r + -Math.log(Ref)/ Math.log(10))\n"
9802
" }\n"
9803
" return Time.toFixed(r);\n"
9804
" }\n"
9805
"}\n"
9806
"function FormatName(T)\n"
9807
"{\n"
9808
" if(T.idtype == TYPE_COUNTER)\n"
9809
" {\n"
9810
" return T.countername;\n"
9811
" }\n"
9812
" else\n"
9813
" {\n"
9814
" return T.name;\n"
9815
" }\n"
9816
"}\n"
9817
"\n"
9818
"function FormatTimeText(V, T, Ref)\n"
9819
"{\n"
9820
" if(T.idtype == TYPE_COUNTER)\n"
9821
" {\n"
9822
" return FormatCounter(T.format, V);\n"
9823
" }\n"
9824
" else\n"
9825
" {\n"
9826
" if(!Ref)\n"
9827
" {\n"
9828
" if(T && T.id)\n"
9829
" {\n"
9830
" let TimerState = FrameData.TimerMap[T.id];\n"
9831
" if(TimerState)\n"
9832
" {\n"
9833
" let SubGraphSettings = GetSubGraphSettings(GetFullName(T));\n"
9834
" Ref = GetSubGraphReferenceTime(T, SubGraphSettings, TimerState);\n"
9835
" }\n"
9836
" }\n"
9837
" }\n"
9838
" return FormatTime(V, Ref) + \"ms\";\n"
9839
" }\n"
9840
"}\n"
9841
"\n"
9842
"function DrawBarsLegend(View, LocalMouseX, LocalMouseY, SubIndex)\n"
9843
"{\n"
9844
" ProfileEnter(\"DrawBar\");\n"
9845
" var TimerMap = FrameData.TimerMap;\n"
9846
" if(!TimerMap)\n"
9847
" return;\n"
9848
" if(Settings.ViewCompressed)\n"
9849
" return;\n"
9850
" var Canvas = View.Canvas[View.BackBuffer];\n"
9851
" var context = Canvas.getContext(\'2d\');\n"
9852
" context.clearRect(0, 0, View.w, View.h);\n"
9853
" var X = 0;\n"
9854
" var Y = View.h/2;\n"
9855
" var XSpace = 5;\n"
9856
" var XSpace2 = XSpace * 2;\n"
9857
" function DrawEntry(T)\n"
9858
" {\n"
9859
" X += XSpace2*2;\n"
9860
" context.fillStyle = T.color;\n"
9861
" context.fillRect(X-XSpace,Y-XSpace,XSpace2,XSpace2);\n"
9862
" X += XSpace + 2;\n"
9863
" context.fillStyle = \'white\';\n"
9864
" var w = context.measureText(T.name).width;\n"
9865
" context.fillText(T.name, X, Y + FontHeight/2);\n"
9866
" X += w;\n"
9867
" }\n"
9868
"\n"
9869
" if(SingleTimerBars == 0)\n"
9870
" {\n"
9871
" for(var key in TimerMap)\n"
9872
" {\n"
9873
" var idx = GetTimer(key);\n"
9874
" var T = TimerArray[idx];\n"
9875
" if(T.e)\n"
9876
" {\n"
9877
" DrawEntry(T);\n"
9878
" }\n"
9879
" }\n"
9880
" }\n"
9881
" else if(EnabledArray.length > 0)\n"
9882
" {\n"
9883
" var idx = EnabledArray[0];\n"
9884
" var T = TimerArray[idx];\n"
9885
" DrawEntry(T);\n"
9886
" }\n"
9887
"}\n"
9888
"\n"
9889
"function DrawBars(View, LocalMouseX, LocalMouseY, SubIndex)\n"
9890
"{\n"
9891
" var TimerMap = FrameData.TimerMap;\n"
9892
" if(!TimerMap)\n"
9893
" return;\n"
9894
" if(!SubIndex)\n"
9895
" SubIndex = 0;\n"
9896
"\n"
9897
" ProfileEnter(\"DrawBar\");\n"
9898
" var Canvas = View.Canvas[View.BackBuffer];\n"
9899
" var context = Canvas.getContext(\'2d\');\n"
9900
"\n"
9901
" context.clearRect(0, 0, View.w, View.h);\n"
9902
" var bgcolor = nBackColors[ViewIndex%2];\n"
9903
" context.fillStyle = bgcolor;\n"
9904
" context.fillRect(0, 0, View.w, View.h);\n"
9905
" var Title = \"?\";\n"
9906
" var TitleName = null;\n"
9907
" var nNumBars = 0;\n"
9908
" var BarNames = [];\n"
9909
" var BarTimes = [];\n"
9910
" var BarColors = [];\n"
9911
" var AggregateIndex = Settings.AggregateFrames <= 0 ? AggregateHistorySize-1 : AggregateHistorySize-2; //fix med\n"
9912
" var GetTime = null;\n"
9913
" var SubIndex = X7BarColumnRemap[SubIndex];\n"
9914
"\n"
9915
" if(SingleTimerBars == 0)\n"
9916
" {\n"
9917
" if(SubIndex == 0)\n"
9918
" {\n"
9919
" Title = \"Time\";\n"
9920
" GetTime = function(FD){ return FD.FrameTime; };\n"
9921
" }\n"
9922
" else if(SubIndex == 1)\n"
9923
" {\n"
9924
" Title = \"Average\";\n"
9925
" GetTime = function(FD){ return FD.TimeAvg[AggregateIndex]; };\n"
9926
" }\n"
9927
" else if(SubIndex == 2)\n"
9928
" {\n"
9929
" Title = \"Max\";\n"
9930
" GetTime = function(FD){ return FD.TimeMax[AggregateIndex]; };\n"
9931
" }\n"
9932
" else if(SubIndex == 3)\n"
9933
" {\n"
9934
" Title = \"Min\";\n"
9935
" GetTime = function(FD){ return FD.TimeMin[AggregateIndex]; };\n"
9936
" }\n"
9937
" else if(SubIndex == 4)\n"
9938
" {\n"
9939
" Title = \"Exclusive Avg\";\n"
9940
" GetTime = function(FD){ return FD.TimeExclAvg[AggregateIndex]; };\n"
9941
" }\n"
9942
" else if(SubIndex == 5)\n"
9943
" {\n"
9944
" Title = \"Exclusive Max\";\n"
9945
" GetTime = function(FD){ return FD.TimeExclMax[AggregateIndex]; };\n"
9946
" }\n"
9947
" else if(SubIndex == 6)\n"
9948
" {\n"
9949
" Title = \"Exclusive Min\";\n"
9950
" GetTime = function(FD){ return FD.TimeExclMin[AggregateIndex]; };\n"
9951
" }\n"
9952
" for(var key in TimerMap)\n"
9953
" {\n"
9954
" var idx = GetTimer(key);\n"
9955
" var T = TimerArray[idx];\n"
9956
" if(T.e)\n"
9957
" {\n"
9958
" nNumBars++;\n"
9959
" var FD = TimerMap[key];\n"
9960
" var Time = GetTime(FD);\n"
9961
" BarNames.push(T.name);\n"
9962
" BarTimes.push(Time);\n"
9963
" BarColors.push(T.color);\n"
9964
" }\n"
9965
" }\n"
9966
"\n"
9967
" }\n"
9968
" else if(EnabledArray.length > 0)\n"
9969
" {\n"
9970
" var idx = EnabledArray[0];\n"
9971
" var T = TimerArray[idx];\n"
9972
" var FD = GetFrameData(T.id);\n"
9973
" var Property = null;\n"
9974
" if(SubIndex == 0)\n"
9975
" {\n"
9976
" Title = \"Average\";\n"
9977
" Property = \"TimeAvg\";\n"
9978
" }\n"
9979
" else if(SubIndex == 1)\n"
9980
" {\n"
9981
" Title = \"Max\";\n"
9982
" Property = \"TimeMax\";\n"
9983
" }\n"
9984
" else if(SubIndex == 2)\n"
9985
" {\n"
9986
" Title = \"Min\";\n"
9987
" Property = \"TimeMin\";\n"
9988
" }\n"
9989
" else if(SubIndex == 3)\n"
9990
" {\n"
9991
" Title = \"Exclusive Average\";\n"
9992
" Property = \"TimeExclAvg\";\n"
9993
" }\n"
9994
" else if(SubIndex == 4)\n"
9995
" {\n"
9996
" Title = \"Exclusive Max\";\n"
9997
" Property = \"TimeExclMax\";\n"
9998
" }\n"
9999
" else if(SubIndex == 5)\n"
10000
" {\n"
10001
" Title = \"Exclusive Min\";\n"
10002
" Property = \"TimeExclMin\";\n"
10003
" }\n"
10004
" else if(SubIndex == 6)\n"
10005
" {\n"
10006
" Title = \"Call Average\";\n"
10007
" Property = \"TimeCallAvg\";\n"
10008
" }\n"
10009
" else if(SubIndex == 7)\n"
10010
" {\n"
10011
" Title = \"Call Excl Average\";\n"
10012
" Property = \"TimeCallExclAvg\";\n"
10013
" }\n"
10014
" TitleName = T.name;\n"
10015
" for(var i = 0; i < AggregateHistorySize; ++i)\n"
10016
" {\n"
10017
" nNumBars++;\n"
10018
" var A = FD[Property];\n"
10019
" var Time = A[i];\n"
10020
" BarTimes.push(Time);\n"
10021
" BarColors.push(T.color);\n"
10022
" }\n"
10023
" }\n"
10024
"\n"
10025
"\n"
10026
" if(!nNumBars)\n"
10027
" {\n"
10028
" ProfileLeave();\n"
10029
" return;\n"
10030
" }\n"
10031
"\n"
10032
" var h = View.h;\n"
10033
" var w = View.w;\n"
10034
" var MsTextExtraSpace = Math.cos(3.14/4.0) * (ViewBarMaxMsTextLength);\n"
10035
" var DrawXLeft = Settings.ViewCompressed ? 3 : 15;\n"
10036
" DrawXLeft = Math.max(DrawXLeft, MsTextExtraSpace);\n"
10037
" var DrawXRight = Settings.ViewCompressed ? 3: 10;\n"
10038
" var DrawY = 35 * 2;\n"
10039
" if(Settings.ViewCompressed)\n"
10040
" {\n"
10041
" DrawY = (MsTextExtraSpace) + 35;\n"
10042
" }\n"
10043
" var DrawWidth = w - DrawXLeft - DrawXRight;\n"
10044
" var DrawHeight = h - DrawY;\n"
10045
" var SpaceWidth = 5;\n"
10046
" var BarWidth = (DrawWidth-SpaceWidth*(nNumBars-1))/ nNumBars;\n"
10047
" for(var x = 0; x < 2; ++x)\n"
10048
" {\n"
10049
" if(BarWidth < 14)\n"
10050
" {\n"
10051
" SpaceWidth -= 1;\n"
10052
" BarWidth = (DrawWidth-SpaceWidth*(nNumBars-1))/ nNumBars;\n"
10053
" }\n"
10054
" }\n"
10055
" if(BarWidth > 50)\n"
10056
" BarWidth = 50;\n"
10057
" var BarHeight = DrawHeight - 5;\n"
10058
"\n"
10059
" var ReferenceTime = ReferenceBar;\n"
10060
"\n"
10061
" var fHeightScale = h / ReferenceTime;\n"
10062
" var MouseDragging = 0;\n"
10063
" var fWidth = w / FRAME_COUNT;\n"
10064
" var Keys = [];\n"
10065
" var X = DrawXLeft;\n"
10066
" var offset = 0;\n"
10067
" context.textAlign = \'center\';\n"
10068
" context.fillStyle = \'#ffffff\';\n"
10069
" context.fillText(Title, w / 2.0, FontHeight);\n"
10070
" context.textAlign = \'left\';\n"
10071
" context.fillStyle = \'wheat\';\n"
10072
" var BaseY = 20;\n"
10073
" if(SubIndex == X7BarFirstView)\n"
10074
" {\n"
10075
" context.fillText(ReferenceTime.toFixed(2) + \'ms\', 0, BaseY - 5 + DrawHeight - BarHeight);\n"
10076
" }\n"
10077
" else if(SubIndex == X7BarLastView)\n"
10078
" {\n"
10079
" context.textAlign = \'right\';\n"
10080
" context.fillText(ReferenceTime.toFixed(2) + \'ms\', w, BaseY - 5 + DrawHeight - BarHeight);\n"
10081
" }\n"
10082
" context.textAlign = \'right\';\n"
10083
" var BarFont = FontLarge;\n"
10084
" var DrawNames = true;\n"
10085
" if(BarWidth < 14)\n"
10086
" {\n"
10087
" DrawNames = BarWidth > 4;\n"
10088
" var FontXX = \'Bold \' + Math.floor(BarWidth) + \'px Courier New\';\n"
10089
" BarFont = FontXX;\n"
10090
"\n"
10091
" }\n"
10092
" context.font = BarFont;\n"
10093
" for(var i = 0; i < BarTimes.length; ++i)\n"
10094
" {\n"
10095
" var TimeText = FormatTime(Time);\n"
10096
" var w = context.measureText(TimeText).width;\n"
10097
" ViewBarMaxMsTextLength = Math.max(w, ViewBarMaxMsTextLength);\n"
10098
"\n"
10099
"\n"
10100
" }\n"
10101
" for(var i = 0; i < BarTimes.length; ++i)\n"
10102
" {\n"
10103
" var Time = BarTimes[i];\n"
10104
" var TimeText = FormatTime(Time);\n"
10105
" ReferenceBarAutomatic = Math.max(Time, ReferenceBarAutomatic);\n"
10106
" var Color = BarColors[i];\n"
10107
" var fPrc = Time / ReferenceTime;\n"
10108
" if(fPrc > 1.0)\n"
10109
" fPrc = 1.0;\n"
10110
" var BarH = fPrc * BarHeight;\n"
10111
"\n"
10112
" var X0 = X;\n"
10113
" var Y0 = BaseY + DrawHeight - BarH;\n"
10114
" context.fillStyle = Color;\n"
10115
" context.fillRect(X0, Y0, BarWidth, BarH);\n"
10116
" context.fillStyle = \'#ffffff\';\n"
10117
" var MouseOver = LocalMouseX > X0 && LocalMouseX < X0 + BarWidth;\n"
10118
" if(MouseOver || (Settings.ViewCompressed&&DrawNames))\n"
10119
" {\n"
10120
" context.save();\n"
10121
" context.translate(X0 + BarWidth * 0.5, BaseY + DrawHeight - 2);\n"
10122
" context.rotate(-3.14/2.0);\n"
10123
" context.font = BarFont;\n"
10124
" context.textAlign = \'left\';\n"
10125
" context.textBaseline = \'middle\';\n"
10126
" var m = context.measureText(BarNames[i]);\n"
10127
" context.fillStyle = \'black\';\n"
10128
" context.fillText(BarNames[i], -1, -1);\n"
10129
" context.fillStyle = \'white\';\n"
10130
" context.fillText(BarNames[i], 0, 0);\n"
10131
" context.textAlign = \'right\';\n"
10132
" context.restore();\n"
10133
" }\n"
10134
" context.save();\n"
10135
" var XText = X+BarWidth;\n"
10136
" var YText = BaseY + DrawHeight + FontHeight;\n"
10137
" context.translate(XText, YText);\n"
10138
" context.rotate(-3.14/4.0);\n"
10139
" context.font = BarFont;\n"
10140
" context.fillText(TimeText, 0, 0);\n"
10141
" context.restore();\n"
10142
"\n"
10143
" X += BarWidth + SpaceWidth;\n"
10144
" }\n"
10145
" context.font = Font;\n"
10146
" ProfileLeave();\n"
10147
"}\n"
10148
"\n"
10149
"function SortColumnFromName(Name)\n"
10150
"{\n"
10151
" //should match switch in drawtableview\n"
10152
" if(Name == StrAverage)\n"
10153
" {\n"
10154
" return 1;\n"
10155
" }\n"
10156
" else if(Name == StrMax)\n"
10157
" {\n"
10158
" return 2;\n"
10159
" }\n"
10160
" else if(Name == StrTotal)\n"
10161
" {\n"
10162
" return 3;\n"
10163
" }\n"
10164
" else if(Name == StrMin)\n"
10165
" {\n"
10166
" return 4;\n"
10167
" }\n"
10168
" else if(Name == StrSpike)\n"
10169
" {\n"
10170
" return 5;\n"
10171
" }\n"
10172
" else if(Name == StrCallAverage)\n"
10173
" {\n"
10174
" return 6;\n"
10175
" }\n"
10176
" else if(Name == StrCount)\n"
10177
" {\n"
10178
" return 7;\n"
10179
" }\n"
10180
" else if(Name == StrExclAverage)\n"
10181
" {\n"
10182
" return 8;\n"
10183
" }\n"
10184
" else if(Name == StrExclMax)\n"
10185
" {\n"
10186
" return 9;\n"
10187
" }\n"
10188
" else if(Name == StrGroup)\n"
10189
" {\n"
10190
" return -1;\n"
10191
" }\n"
10192
" else if(Name == StrTimer)\n"
10193
" {\n"
10194
" return -2;\n"
10195
" }\n"
10196
" return 0;\n"
10197
"}\n"
10198
"\n"
10199
"\n"
10200
"function DrawTableView(View, LocalMouseX, LocalMouseY, SubIndex)\n"
10201
"{\n"
10202
" ProfileEnter(\"DrawTableView\");\n"
10203
" let Canvas = View.Canvas[View.BackBuffer];\n"
10204
" let context = Canvas.getContext(\'2d\');\n"
10205
" let Height = BoxHeight;\n"
10206
" let Width = nWidth;\n"
10207
" let Y = Height;\n"
10208
" let XBase = 0;\n"
10209
" let nColorIndex = 0;\n"
10210
" let bMouseIn = 0;\n"
10211
" let RcpReferenceTime = 1.0 / Settings.ReferenceTime;\n"
10212
" let CountWidth = 12 * FontWidth;\n"
10213
" let InnerBoxHeight = BoxHeight-2;\n"
10214
" let TimerLen = 8;\n"
10215
" let TimerWidth = TimerLen * FontWidth;\n"
10216
" let nWidthBars = nBarsWidth+2;\n"
10217
" let nWidthMs = TimerWidth+2+10;\n"
10218
" let NameWidth = 200;\n"
10219
" let R = 0;\n"
10220
" let X = 0;\n"
10221
"\n"
10222
" let OffsetY = BoxHeight;\n"
10223
"\n"
10224
"\n"
10225
" context.clearRect(0, 0, View.w, View.h);\n"
10226
" context.fillStyle = \'white\';\n"
10227
" context";
10228
10229
const size_t g_MicroProfileHtmlLive_begin_0_size = sizeof(g_MicroProfileHtmlLive_begin_0);
10230
const char g_MicroProfileHtmlLive_begin_1[] =
10231
".font = Font;\n"
10232
"\n"
10233
"\n"
10234
" function HeaderMouseHandle(XBegin, X, Y, Header)\n"
10235
" {\n"
10236
" if(Header == null)\n"
10237
" debugger;\n"
10238
" let bMouseIn = LocalMouseY >= Y && LocalMouseY < BoxHeight+Y && LocalMouseX < X && LocalMouseX > XBegin;\n"
10239
" if(bMouseIn)\n"
10240
" {\n"
10241
" SortColumnMouseOverNext = Header;\n"
10242
" }\n"
10243
" }\n"
10244
" function HeaderString(Header)\n"
10245
" {\n"
10246
" if(Header == Settings.SortColumnName)\n"
10247
" {\n"
10248
" return Header + (Settings.SortColumnOrderFlip ? \'<\' : \'>\');\n"
10249
" }\n"
10250
" else\n"
10251
" {\n"
10252
" return Header;\n"
10253
" }\n"
10254
"\n"
10255
" }\n"
10256
" function DrawHeaderSplit(Header, Y)\n"
10257
" {\n"
10258
" if(Settings.BarColumnEnabledTable[R])\n"
10259
" {\n"
10260
" context.fillStyle = \'white\';\n"
10261
" context.fillText(HeaderString(Header), X, Y + Height-FontAscent);\n"
10262
" var XBegin = X;\n"
10263
" X += nWidthBars;\n"
10264
" context.fillStyle = nBackColorOffset;\n"
10265
" X += ColumnsWidth[R];\n"
10266
"\n"
10267
" if(X >= NameWidth)\n"
10268
" {\n"
10269
" context.fillRect(X-3, Y, 1, nHeight);\n"
10270
" }\n"
10271
" HeaderMouseHandle(XBegin, X, Y, Header);\n"
10272
" }\n"
10273
" R++;\n"
10274
" }\n"
10275
" function DrawHeaderSplitSingle(Header, Y)\n"
10276
" {\n"
10277
" if(Settings.BarColumnEnabledTable[R])\n"
10278
" {\n"
10279
" context.fillStyle = \'white\';\n"
10280
" context.fillText(HeaderString(Header), X, Y + Height-FontAscent);\n"
10281
" let XBegin = X;\n"
10282
" X += ColumnsWidth[R];\n"
10283
" context.fillStyle = nBackColorOffset;\n"
10284
" if(X >= NameWidth)\n"
10285
" {\n"
10286
" context.fillRect(X-3, Y, 1, nHeight);\n"
10287
" }\n"
10288
" HeaderMouseHandle(XBegin, X, Y, Header);\n"
10289
" }\n"
10290
" R++;\n"
10291
" }\n"
10292
" function DrawHeaderSplitLeftRight(HeaderLeft, HeaderRight, Y, Width)\n"
10293
" {\n"
10294
" let HeaderLeftS = HeaderString(HeaderLeft);\n"
10295
" let HeaderRightS = HeaderString(HeaderRight);\n"
10296
" context.textAlign = \'left\';\n"
10297
" context.fillStyle = \'white\';\n"
10298
" context.fillText(HeaderLeftS, X, Y + Height-FontAscent);\n"
10299
" let wLeft = context.measureText(HeaderLeftS).width;\n"
10300
" let XBegin = X;\n"
10301
" X += Width;\n"
10302
" context.textAlign = \'right\';\n"
10303
" context.fillText(HeaderRightS, X-5, Y + Height-FontAscent);\n"
10304
" context.textAlign = \'left\';\n"
10305
" context.fillStyle = nBackColorOffset;\n"
10306
" if(X >= NameWidth)\n"
10307
" {\n"
10308
" context.fillRect(X-3, 0, 1, nHeight);\n"
10309
" }\n"
10310
" HeaderMouseHandle(XBegin, XBegin + wLeft, Y, HeaderLeft);\n"
10311
" HeaderMouseHandle(XBegin + wLeft, X, Y, HeaderRight);\n"
10312
"\n"
10313
" }\n"
10314
" function DrawTimer(Value, Color, Skip)\n"
10315
" {\n"
10316
" if(Settings.BarColumnEnabledTable[R])\n"
10317
" {\n"
10318
" if(Skip)\n"
10319
" {\n"
10320
" X += nWidthBars;\n"
10321
" X += ColumnsWidth[R];\n"
10322
" }\n"
10323
" else\n"
10324
" {\n"
10325
" if(null == Value)\n"
10326
" {\n"
10327
" X += nWidthBars + ColumnsWidth[R];\n"
10328
" console.log(\"Should not happen2\\n\");\n"
10329
" debugger;\n"
10330
" return;\n"
10331
" }\n"
10332
" let Prc = Math.max(0, Value) * RcpReferenceTime;\n"
10333
" let YText = Y+Height-FontAscent;\n"
10334
" if(Prc > 1)\n"
10335
" {\n"
10336
" Prc = 1;\n"
10337
" }\n"
10338
" context.textAlign = \'left\';\n"
10339
" context.fillStyle = Color;\n"
10340
" context.fillRect(X+1, Y+1, Prc * nBarsWidth, InnerBoxHeight);\n"
10341
" X += nWidthBars;\n"
10342
" context.fillStyle = \'white\';\n"
10343
" let TimerText = FormatTime(Value);\n"
10344
" let W = context.measureText(TimerText).width + FontWidth;\n"
10345
" ColumnsWidth[R] = Math.max(W, ColumnsWidth[R]);\n"
10346
" X += ColumnsWidth[R];\n"
10347
" context.textAlign = \'right\';\n"
10348
" context.fillText(TimerText, X - FontWidth, YText);\n"
10349
" context.textAlign = \'left\';\n"
10350
" }\n"
10351
" }\n"
10352
" R++;\n"
10353
" }\n"
10354
" function DrawCount(Str, Skip)\n"
10355
" {\n"
10356
" if(Settings.BarColumnEnabledTable[R])\n"
10357
" {\n"
10358
" X += ColumnsWidth[R];\n"
10359
" let W = Math.max(80, context.measureText(Str).width + FontWidth * 2);\n"
10360
" ColumnsWidth[R] = Math.max(W, ColumnsWidth[R]);\n"
10361
" if(!Skip)\n"
10362
" {\n"
10363
" context.fillStyle = \'white\';\n"
10364
" context.textAlign = \'right\';\n"
10365
" let YText = Y+Height-FontAscent;\n"
10366
" context.fillText(Str, X-6, YText);\n"
10367
" }\n"
10368
" }\n"
10369
" R++;\n"
10370
"\n"
10371
" }\n"
10372
" function DrawMeta(Value, Width, Dec, YText)\n"
10373
" {\n"
10374
" Value = FormatMeta(Value, Dec);\n"
10375
" X += (FontWidth*Width);\n"
10376
" context.textAlign = \'right\';\n"
10377
" context.fillText(Value, X-FontWidth, YText);\n"
10378
" context.textAlign = \'left\';\n"
10379
" }\n"
10380
"\n"
10381
" function DrawTimerRow(idx, showgroup)\n"
10382
" {\n"
10383
" R = 0;\n"
10384
" let T = TimerArray[idx];\n"
10385
" let IsCounter = T.idtype == TYPE_COUNTER;\n"
10386
" let key = T.id;\n"
10387
" let FD = TimerMap[key];\n"
10388
" let AggregateIndex = Settings.AggregateFrames <= 0 ? AggregateHistorySize-1 : AggregateHistorySize-2;\n"
10389
"\n"
10390
" let YText = Y+Height-FontAscent;\n"
10391
" X = NameWidth + XBase;\n"
10392
"\n"
10393
" nColorIndex = 1-nColorIndex;\n"
10394
" bMouseIn = LocalMouseY >= Y && LocalMouseY < Y + BoxHeight;\n"
10395
" context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
10396
" context.fillRect(0, Y, Width, FontHeight+2);\n"
10397
"\n"
10398
" DrawTimer(T.time, T.color);\n"
10399
" DrawTimer(T.excl, T.color, IsCounter);\n"
10400
"\n"
10401
" DrawTimer(T.average, T.color);\n"
10402
" DrawTimer(T.max, T.color);\n"
10403
" DrawTimer(T.min, T.color);\n"
10404
" DrawTimer(T.total, T.color);\n"
10405
"\n"
10406
" DrawTimer(T.exclaverage, T.color, IsCounter);\n"
10407
" DrawTimer(T.exclmax, T.color, IsCounter);\n"
10408
" DrawTimer(T.excltotal, T.color, IsCounter);\n"
10409
"\n"
10410
" DrawCount((T.spike?T.spike.toFixed(2):\"0\") + \'%\', IsCounter);\n"
10411
" DrawTimer(T.callaverage, T.color, IsCounter);\n"
10412
" DrawTimer(T.callexclaverage, T.color, IsCounter);\n"
10413
" DrawCount(\'\' + T.callcount, IsCounter);\n"
10414
"\n"
10415
" context.fillStyle = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
10416
" context.fillRect(0, Y, NameWidth, Height);\n"
10417
" if(T.idtype == TYPE_GROUP)\n"
10418
" {\n"
10419
" context.textAlign = \'left\';\n"
10420
" context.fillStyle = T.color;\n"
10421
" context.fillText(T.name, 1, YText);\n"
10422
" }\n"
10423
" else if(T.idtype == TYPE_COUNTER)\n"
10424
" {\n"
10425
" context.textAlign = \'left\';\n"
10426
" context.fillStyle = T.color;\n"
10427
" context.fillText(T.countername, 1, YText);\n"
10428
" }\n"
10429
" else\n"
10430
" {\n"
10431
" context.textAlign = \'right\';\n"
10432
" context.fillStyle = T.color;\n"
10433
" context.fillText(T.name, NameWidth - 5, YText);\n"
10434
" context.textAlign = \'left\';\n"
10435
" let P = TimerArray[T.parent];\n"
10436
" context.fillStyle = P.color;\n"
10437
" let ParentName = P.name;\n"
10438
" context.fillText(ParentName, 1, YText);\n"
10439
" }\n"
10440
" }\n"
10441
" function FilterMatch(FilterArray, value)\n"
10442
" {\n"
10443
" if(!FilterArray)\n"
10444
" return true;\n"
10445
" for(let i = 0; i < FilterArray.length; ++i)\n"
10446
" {\n"
10447
" let res = value.search(FilterArray[i]);\n"
10448
" if(res<0)\n"
10449
" return false;\n"
10450
" }\n"
10451
" return true;\n"
10452
" }\n"
10453
" let TimerMap = FrameData.TimerMap;\n"
10454
" if(!TimerMap)\n"
10455
" {\n"
10456
" return;\n"
10457
" }\n"
10458
"\n"
10459
" let wfirst = 100;\n"
10460
" let OrderArray = new Array();\n"
10461
" let nTotalRows = 0;\n"
10462
" for(let key in TimerMap)\n"
10463
" {\n"
10464
" let idx = GetTimer(key);\n"
10465
" let T = TimerArray[idx];\n"
10466
" if(T.e)\n"
10467
" {\n"
10468
" OrderArray.push(idx);\n"
10469
" wfirst = wfirst < T.wtotal ? T.wtotal : wfirst;\n"
10470
" nTotalRows++;\n"
10471
" }\n"
10472
" }\n"
10473
" NameWidth = wfirst + 20;\n"
10474
"\n"
10475
"\n"
10476
" let nTotalRowPixels = (3+nTotalRows) * Height;\n"
10477
" let nFrameRows = nHeight - HistoryHeight - BoxHeight;\n"
10478
" if(nTotalRowPixels > nFrameRows)\n"
10479
" {\n"
10480
" if(nOffsetBarsY + nFrameRows > nTotalRowPixels)\n"
10481
" {\n"
10482
" nOffsetBarsY = nTotalRowPixels - nFrameRows;\n"
10483
" }\n"
10484
" }\n"
10485
" else\n"
10486
" {\n"
10487
" nOffsetBarsY = 0;\n"
10488
" }\n"
10489
" Y = Y - nOffsetBarsY;\n"
10490
" Y += OffsetY;\n"
10491
" XBase = XBase - nOffsetBarsX;\n"
10492
"\n"
10493
" if(1)\n"
10494
" {\n"
10495
" let Flip = Settings.SortColumnOrderFlip == 1 ? -1 : 1;\n"
10496
" let StringCompare = function(Key)\n"
10497
" {\n"
10498
" let F = function(A, B)\n"
10499
" {\n"
10500
" let s1 = Key(A);\n"
10501
" let s2 = Key(B);\n"
10502
" return Flip * s2.localeCompare(s1);\n"
10503
" };\n"
10504
" return F;\n"
10505
" };\n"
10506
" let NumberCompare = function(Key)\n"
10507
" {\n"
10508
" let F = function(A, B)\n"
10509
" {\n"
10510
" let v0 = Key(B);\n"
10511
" let v1 = Key(A);\n"
10512
" return Flip * (v0 - v1);\n"
10513
" };\n"
10514
" return F;\n"
10515
" };\n"
10516
" let N = Settings.SortColumnName;\n"
10517
" if(N == StrTime)\n"
10518
" {\n"
10519
" let Do = function()\n"
10520
" {\n"
10521
" for(var i = 0; i < OrderArray.length; ++i)\n"
10522
" {\n"
10523
" let t = TimerArray[OrderArray[i]];\n"
10524
" console.log(\"\", i, OrderArray[i], t.name, t.id, t.time);\n"
10525
" };\n"
10526
"\n"
10527
" };\n"
10528
" OrderArray.sort( NumberCompare( function (a) {\n"
10529
" return TimerArray[a].time;\n"
10530
" } ) );\n"
10531
" }\n"
10532
" else if(N == StrExclusive)\n"
10533
" {\n"
10534
" OrderArray.sort( NumberCompare( function (a) { return TimerArray[a].excl; } ) );\n"
10535
" }\n"
10536
" else if(N == StrAverage)\n"
10537
" {\n"
10538
" OrderArray.sort( NumberCompare( function (a) { return TimerArray[a].average; } ) );\n"
10539
" }\n"
10540
" else if(N == StrMax)\n"
10541
" {\n"
10542
" OrderArray.sort( NumberCompare( function (a) { return TimerArray[a].max; } ) );\n"
10543
" }\n"
10544
" else if(N == StrTotal)\n"
10545
" {\n"
10546
" OrderArray.sort( NumberCompare( function (a) { return TimerArray[a].total; } ) );\n"
10547
" }\n"
10548
" else if(N == StrMin)\n"
10549
" {\n"
10550
" OrderArray.sort( NumberCompare( function (a) { return TimerArray[a].min; } ) );\n"
10551
" }\n"
10552
" else if(N == StrSpike)\n"
10553
" {\n"
10554
" OrderArray.sort( NumberCompare( function (a) { return TimerArray[a].spike; } ) );\n"
10555
" }\n"
10556
" else if(N == StrCallAverage)\n"
10557
" {\n"
10558
" OrderArray.sort( NumberCompare( function (a) { return TimerArray[a].callaverage; } ) );\n"
10559
" }\n"
10560
" else if(N == StrCount)\n"
10561
" {\n"
10562
" OrderArray.sort( NumberCompare( function (a) { return TimerArray[a].count; } ) );\n"
10563
" }\n"
10564
" else if(N == StrExclAverage)\n"
10565
" {\n"
10566
" OrderArray.sort( NumberCompare( function (a) { return TimerArray[a].exclaverage; } ) );\n"
10567
" }\n"
10568
" else if(N == StrExclMax)\n"
10569
" {\n"
10570
" OrderArray.sort( NumberCompare( function (a) { return TimerArray[a].exclmax; } ) );\n"
10571
" }\n"
10572
" else if(N == StrExclTotal)\n"
10573
" {\n"
10574
" OrderArray.sort( NumberCompare( function (a) { return TimerArray[a].excltotal; } ) );\n"
10575
" }\n"
10576
" else if(N == StrGroup)\n"
10577
" {\n"
10578
" OrderArray.sort( StringCompare( function (a) { return TimerArray[TimerArray[a].parent].name; } ) );\n"
10579
" }\n"
10580
" else if(N == StrTimer)\n"
10581
" {\n"
10582
" OrderArray.sort( StringCompare( function (a) { return TimerArray[a].name; } ) );\n"
10583
" }\n"
10584
" else\n"
10585
" {\n"
10586
" if(N != \"\")\n"
10587
" {\n"
10588
" console.log(\"unhandle sortkey\", N);\n"
10589
" debugger;\n"
10590
" }\n"
10591
"\n"
10592
" OrderArray.sort( StringCompare( function (a) { return TimerArray[a].sortkey; } ) );\n"
10593
" }\n"
10594
" }\n"
10595
"\n"
10596
" let ColorHigh = \'#85929e\';\n"
10597
"\n"
10598
"\n"
10599
" for(let i = 0; i < OrderArray.length; ++i)\n"
10600
" {\n"
10601
" let idx = OrderArray[i];\n"
10602
" let T = TimerArray[idx];\n"
10603
" if(T.idtype == TYPE_GROUP)\n"
10604
" {\n"
10605
" DrawTimerRow(idx, 1);\n"
10606
" Y += Height;\n"
10607
" }\n"
10608
" }\n"
10609
" let SplitY0 = Y;\n"
10610
"\n"
10611
" for(let i = 0; i < OrderArray.length; ++i)\n"
10612
" {\n"
10613
" let idx = OrderArray[i];\n"
10614
" let T = TimerArray[idx];\n"
10615
" if(T.idtype == TYPE_TIMER)\n"
10616
" {\n"
10617
" DrawTimerRow(idx, 1);\n"
10618
" Y += Height;\n"
10619
" }\n"
10620
" }\n"
10621
" let SplitY1 = Y;\n"
10622
"\n"
10623
" for(let i = 0; i < OrderArray.length; ++i)\n"
10624
" {\n"
10625
" let idx = OrderArray[i];\n"
10626
" let T = TimerArray[idx];\n"
10627
" if(T.idtype == TYPE_COUNTER)\n"
10628
" {\n"
10629
" DrawTimerRow(idx, 1);\n"
10630
" Y += Height;\n"
10631
" }\n"
10632
" }\n"
10633
"\n"
10634
" \n"
10635
" context.fillStyle = nBackColorOffset;\n"
10636
" context.fillRect(0, 0, Width, 2*Height);\n"
10637
" context.fillStyle = \'white\';\n"
10638
" SortColumnMouseOverNext = null;\n"
10639
" X = NameWidth + XBase;\n"
10640
" R = 0;\n"
10641
"\n"
10642
" let Aggr = Settings.AggregateFrames <= 0 ? AggregateCurrent : Settings.AggregateFrames;\n"
10643
" let Headers = [\"Per Frame\", \"Aggregate/\" + Aggr + \" Frames\", \"Call/\" + Aggr + \" Frames\"];\n"
10644
" let SplitX = [0,0,0];\n"
10645
"\n"
10646
" DrawHeaderSplit(StrTime,OffsetY);\n"
10647
" DrawHeaderSplit(StrExclusive, OffsetY);\n"
10648
" SplitX[0] = X;\n"
10649
"\n"
10650
" DrawHeaderSplit(StrAverage, OffsetY);\n"
10651
" DrawHeaderSplit(StrMax, OffsetY);\n"
10652
" DrawHeaderSplit(StrMin, OffsetY);\n"
10653
" DrawHeaderSplit(StrTotal, OffsetY);\n"
10654
"\n"
10655
" DrawHeaderSplit(StrExclAverage, OffsetY);\n"
10656
" DrawHeaderSplit(StrExclMax, OffsetY);\n"
10657
" DrawHeaderSplit(StrExclTotal, OffsetY);\n"
10658
"\n"
10659
" DrawHeaderSplitSingle(StrSpike, OffsetY);\n"
10660
" SplitX[1] = X;\n"
10661
"\n"
10662
" DrawHeaderSplit(StrCallAverage, OffsetY);\n"
10663
" DrawHeaderSplit(StrCallExclAverage, OffsetY);\n"
10664
" DrawHeaderSplitSingle(StrCount, OffsetY);\n"
10665
" SplitX[2] = X;\n"
10666
"\n"
10667
" context.fillStyle = \'white\';\n"
10668
" for(let i = 0; i < SplitX.length; ++i)\n"
10669
" {\n"
10670
" let X0 = i == 0 ? (NameWidth + XBase) : SplitX[i-1];\n"
10671
" let X1 = SplitX[i];\n"
10672
" if(X0 != X1)\n"
10673
" {\n"
10674
" context.fillText(Headers[i], X0 + 1, Height-FontAscent);\n"
10675
" }\n"
10676
" }\n"
10677
" X = 0;\n"
10678
" context.fillStyle = nBackColorOffset;\n"
10679
" context.fillRect(0, 0, NameWidth, Height * 2);\n"
10680
" context.fillStyle = \'white\';\n"
10681
" DrawHeaderSplitLeftRight(StrGroup, StrTimer, 0, NameWidth);\n"
10682
"\n"
10683
"\n"
10684
" for(let i = 0; i < SplitX.length; ++i)\n"
10685
" {\n"
10686
" let X0 = i == 0 ? (NameWidth + XBase) : SplitX[i-1];\n"
10687
" let X1 = SplitX[i];\n"
10688
" if(X0 != X1)\n"
10689
" {\n"
10690
" context.fillStyle = ColorHigh;\n"
10691
" if(X1 >= NameWidth)\n"
10692
" context.fillRect(X1-2.5, 0, 2, nHeight);\n"
10693
" if(X0 >= NameWidth)\n"
10694
" context.fillRect(X0-2.5, 0, 2, nHeight);\n"
10695
" }\n"
10696
" }\n"
10697
" context.fillStyle = ColorHigh;\n"
10698
" context.fillRect(0, 2*Height-1, nWidth, 2);\n"
10699
"\n"
10700
" context.fillStyle = ColorHigh;\n"
10701
" context.fillRect(0, SplitY0-1, nWidth, 2);\n"
10702
" context.fillRect(0, SplitY1-1, nWidth, 2);\n"
10703
"\n"
10704
"\n"
10705
" ProfileLeave();\n"
10706
"}\n"
10707
"function DrawGraphThreadGroup(View, LocalMouseX, LocalMouseY, SubIndex)\n"
10708
"{\n"
10709
" DrawGraphThreadExclusive(View, LocalMouseX, LocalMouseY, SubIndex);\n"
10710
"}\n"
10711
"function DrawGraphSplit(View, LocalMouseX, LocalMouseY, SubIndex)\n"
10712
"{\n"
10713
" DrawGraph(View, LocalMouseX, LocalMouseY, SubIndex, 1);\n"
10714
"}\n"
10715
"\n"
10716
"function DrawGraphThreadExclusive(View, LocalMouseX, LocalMouseY, SubIndex, Split)\n"
10717
"{\n"
10718
" var TimerMap = FrameData.TimerMap;\n"
10719
" if(!TimerMap)\n"
10720
" return;\n"
10721
"\n"
10722
" ProfileEnter(\"DrawGraphThreadExclusive\");\n"
10723
" var Canvas = View.Canvas[View.BackBuffer];\n"
10724
" var context = Canvas.getContext(\'2d\');\n"
10725
" context.clearRect(0, 0, View.w, View.h);\n"
10726
"\n"
10727
" var h = View.h;\n"
10728
" var w = View.w;\n"
10729
" var fHeightScale = h / ReferenceGraph;\n"
10730
" var MouseDragging = 0;\n"
10731
" var fWidth = w / FRAME_COUNT;\n"
10732
" var MouseTime = ReferenceGraph * (1-(LocalMouseY / h));\n"
10733
" var HighlightKey = 0;\n"
10734
" var HighlightFrame = -1;\n"
10735
"\n"
10736
"\n"
10737
" var NumGraphs = 0;\n"
10738
" for(let k in ThreadInfo)\n"
10739
" {\n"
10740
" NumGraphs++;\n"
10741
" }\n"
10742
" if(NumGraphs)\n"
10743
" {\n"
10744
" let hstart = 0;\n"
10745
" let gh = h / NumGraphs;\n"
10746
" let cidx = 1;\n"
10747
" let Count = FRAME_COUNT;\n"
10748
" let Last = AllocClearedArray(Count);\n"
10749
" let FT = FrameData.Time;\n"
10750
" let RcpFT = AllocClearedArray(Count);\n"
10751
" if(FT.length != RcpFT.length)\n"
10752
" debugger;\n"
10753
" for(let k = 0; k < RcpFT.length; ++k)\n"
10754
" {\n"
10755
" if(FT[k] != 0)\n"
10756
" {\n"
10757
" RcpFT[k] = 1.0 / FT[k];\n"
10758
" }\n"
10759
" else\n"
10760
" {\n"
10761
" RcpFT[k] = 0;\n"
10762
" }\n"
10763
" }\n"
10764
"\n"
10765
" for(let k in ThreadInfo)\n"
10766
" {\n"
10767
" for(let j = 0; j < Last.length; ++j)\n"
10768
" Last[j] = 0.0;\n"
10769
" let TI = ThreadInfo[k];\n"
10770
" let X = 0;\n"
10771
" let Y = hstart + gh;\n"
10772
" var YStart = Y;\n"
10773
" if(LocalMouseX >= 0 && LocalMouseY >= hstart && LocalMouseX < w && LocalMouseY <= Y)\n"
10774
" {\n"
10775
" HighlightKey = k;\n"
10776
" HighlightFrame = Math.floor(FRAME_COUNT * LocalMouseX / w);\n"
10777
" }\n"
10778
"\n"
10779
"\n"
10780
" context.globalAlpha = 1;\n"
10781
" context.fillStyle = nBackColorsDark[cidx];\n"
10782
" cidx = 1-cidx;\n"
10783
" context.fillRect(0, hstart, w, gh);\n"
10784
" context.strokeStyle = \'white\';\n"
10785
" context.fillStyle = \'white\';\n"
10786
" for(let l = 0; l < TI.a.length; ++l)\n"
10787
" {\n"
10788
" X = 0;\n"
10789
" let a = TI.a[l];\n"
10790
" if(a.length != Count)\n"
10791
" {\n"
10792
" console.log(\"should not happen!\\n\");\n"
10793
" debugger;\n"
10794
" }\n"
10795
" let idx = GetTimer(TI.ids[l]);\n"
10796
" let c = TimerArray[idx].color;\n"
10797
" context.strokeStyle = c;\n"
10798
" context.fillStyle = c;\n"
10799
" context.beginPath();\n"
10800
"\n"
10801
" for(let m = Last.length-1;m >= 0; m--)\n"
10802
" {\n"
10803
" let XX = X + fWidth * m;\n"
10804
" Y = Math.max(YStart - Last[m] * gh, hstart);\n"
10805
" if(m == Last.length-1)\n"
10806
" {\n"
10807
" context.moveTo(XX, Y);\n"
10808
" }\n"
10809
" else\n"
10810
" {\n"
10811
" context.lineTo(XX, Y);\n"
10812
" }\n"
10813
" }\n"
10814
"\n"
10815
" for(let m = 0; m < a.length; ++m)\n"
10816
" {\n"
10817
"\n"
10818
" let h = a[m] * RcpFT[m];\n"
10819
" if(h > 1.1)\n"
10820
" {\n"
10821
" console.log(\"should not happen \", a[m], RcpFT[m], h);\n"
10822
" debugger;\n"
10823
" h = 1;\n"
10824
" //todo...\n"
10825
" }\n"
10826
" let hm = h + Last[m];\n"
10827
" if(hm > 1.1)\n"
10828
" {\n"
10829
" console.log(\"should not happen \", hm, h, Last[m]);\n"
10830
" debugger;\n"
10831
" hm = 1;\n"
10832
" //todo...\n"
10833
" }\n"
10834
" Y = Math.max(YStart - hm * gh, hstart);\n"
10835
" context.lineTo(X, Y);\n"
10836
" X += fWidth;\n"
10837
" Last[m] = hm;\n"
10838
" }\n"
10839
" context.fill();\n"
10840
"\n"
10841
" }\n"
10842
" context.fillStyle = \'wheat\';\n"
10843
" context.textAlign=\'right\';\n"
10844
" context.fillText(\'100%\', nWidth, hstart + FontHeight);\n"
10845
" context.textAlign=\'left\';\n"
10846
" context.fillText(TI.n, 0, hstart + FontHeight);\n"
10847
" hstart += gh;\n"
10848
" }\n"
10849
" }\n"
10850
"\n"
10851
" if(HighlightKey != 0 && SubMenuActive == -1)\n"
10852
" {\n"
10853
" ToolTipCallback = function(canvas, x, y)\n"
10854
" {\n"
10855
" let TI = ThreadInfo[HighlightKey];\n"
10856
" let ret = [];\n"
10857
" let colors = [];\n"
10858
" for(let l = 0; l < TI.a.length; ++l)\n"
10859
" {\n"
10860
" let a = TI.a[l];\n"
10861
" let idx = GetTimer(TI.ids[l]);\n"
10862
" let c = TimerArray[idx].color;\n"
10863
" colors.push(c);\n"
10864
" ret.push(TimerArray[idx].name);\n"
10865
" let t = FormatTime(a[HighlightFrame]) + \'ms\';\n"
10866
" colors.push(\'white\');\n"
10867
" ret.push(t);\n"
10868
" }\n"
10869
" return {c:colors, a:ret};\n"
10870
" }\n"
10871
" }\n"
10872
"\n"
10873
" ProfileLeave();\n"
10874
"}\n"
10875
"\n"
10876
"function DrawGraphPercentile(View, LocalMouseX, LocalMouseY, SubIndex)\n"
10877
"{\n"
10878
" let TimerMap = FrameData.TimerMap;\n"
10879
" if(!TimerMap)\n"
10880
" return;\n"
10881
"\n"
10882
" ProfileEnter(\"DrawGraphPercentile\");\n"
10883
" let Canvas = View.Canvas[View.BackBuffer];\n"
10884
" let context = Canvas.getContext(\'2d\');\n"
10885
" context.clearRect(0, 0, View.w, View.h);\n"
10886
"\n"
10887
" let h = View.h;\n"
10888
" let w = View.w;\n"
10889
" let Keys = SortGraphs();\n"
10890
" let NumGraphs = Keys.length;\n"
10891
" let ToolTips = Array();\n"
10892
" if(NumGraphs)\n"
10893
" {\n"
10894
" let hstart = 0;\n"
10895
" let gh = h / NumGraphs;\n"
10896
" let cidx = 1;\n"
10897
"\n"
10898
" if(LocalMouseX >= 0 && LocalMouseY >= 0 && LocalMouseX < w && LocalMouseY < h && SubMenuActive == -1)\n"
10899
" {\n"
10900
" ToolTipCallback = function(canvas, x, y)\n"
10901
" {\n"
10902
" let TimerMap = FrameData.TimerMap;\n"
10903
" let context = canvas.getContext(\'2d\');\n"
10904
" context.font = Font;\n"
10905
" let XPos = x - 20;\n"
10906
" for(let key in TimerMap)\n"
10907
" {\n"
10908
" let idx = GetTimer(key);\n"
10909
" let TimerState = TimerMap[key];\n"
10910
" let T = TimerArray[idx];\n"
10911
" if(!IsGroup(key) && T.e && TimerState.PercentileMax > TimerState.PercentileMin)\n"
10912
" {\n"
10913
" let HighlightIndex = -1;\n"
10914
" let Max = TimerState.PercentileMax;\n"
10915
" let Min = TimerState.PercentileMin;\n"
10916
" let h = View.h;\n"
10917
" let w = View.w;\n"
10918
" let tooltipstring = TimerState.tooltipstring;\n"
10919
"\n"
10920
" if(LocalMouseX >= 0 && LocalMouseY >= 0 && LocalMouseX < w && LocalMouseY < h && SubMenuActive == -1 && tooltipstring)\n"
10921
" {\n"
10922
" if(TimerState.tooltipysoft)\n"
10923
" {\n"
10924
" let RATE = 0.05;\n"
10925
" if(Math.abs(TimerState.tooltipysoft - TimerState.tooltipy) > 6)\n"
10926
" {\n"
10927
" TimerState.tooltipysoft = TimerState.tooltipy * RATE + TimerState.tooltipysoft * (1-RATE);\n"
10928
" }\n"
10929
" }\n"
10930
" else\n"
10931
" {\n"
10932
" TimerState.tooltipysoft = TimerState.tooltipy;\n"
10933
" }\n"
10934
" let Y = TimerState.tooltipysoft;\n"
10935
" let wtext = context.measureText(tooltipstring, XPos, Y).width;\n"
10936
" let X = Math.max(0, XPos - wtext);\n"
10937
" context.fillStyle = \'black\';\n"
10938
" context.fillRect(X - 1, Y-1 , wtext+2, BoxHeight+2);\n"
10939
" context.fillStyle = \'white\';\n"
10940
" context.textAlign = \'right\';\n"
10941
" context.fillText(tooltipstring, X + wtext, Y+BoxHeight-2);\n"
10942
"\n"
10943
" }\n"
10944
" }\n"
10945
" context.textAlign = \'left\';\n"
10946
" }\n"
10947
" }\n"
10948
" }\n"
10949
"\n"
10950
" for(let index in Keys)\n"
10951
" {\n"
10952
" let key = Keys[index];\n"
10953
" let idx = GetTimer(key);\n"
10954
" let T = TimerArray[idx];\n"
10955
" let TimerState = TimerMap[key];\n"
10956
" TimerState.tooltipstring = null;\n"
10957
" let Valid = TimerState.PercentileMax > TimerState.PercentileMin;\n"
10958
" if(!IsGroup(key) && T.e)\n"
10959
" {\n"
10960
" let Max = Valid ? TimerState.PercentileMax : 1;\n"
10961
" let Min = Valid ? TimerState.PercentileMin : 0;\n"
10962
" let SubGraphSettings = GetSubGraphSettings(GetFullName(T));\n"
10963
" let Percentile = 0.0;\n"
10964
" if(Percentile == null)\n"
10965
" Percentile = 0.0;\n"
10966
" Percentile = Math.max(0.0, Math.min(99.0, Percentile));\n"
10967
" if(!SubGraphSettings.AutomaticReference)\n"
10968
" {\n"
10969
" Max = SubGraphSettings.ReferenceTime;\n"
10970
" }\n"
10971
" let Reference = Max;\n"
10972
" let PercentileData = TimerState.Percentile;\n"
10973
" let PercentileCount = TimerState.PercentileCount;\n"
10974
" let BasePrc = 0;\n"
10975
" if(PercentileCount > PERCENTILE_SAMPLES)\n"
10976
" {\n"
10977
" BasePrc = 100 * (1- PERCENTILE_SAMPLES / PercentileCount);\n"
10978
" }\n"
10979
" let Total = PercentileData.length-1;\n"
10980
" let NumElementsOnScreen = Total * (100 - Percentile) / (100);\n"
10981
" let WidthPerElement = w / NumElementsOnScreen;\n"
10982
" let TotalWidth = Total * WidthPerElement;\n"
10983
" let PercentilePrc = Percentile / 100;\n"
10984
" let PercentileOffset = PercentilePrc * TotalWidth;\n"
10985
" let fHeightScale2 = gh / Max;\n"
10986
" let color = T.color;\n"
10987
" let X = 0;\n"
10988
" let Y = hstart + gh;\n"
10989
" let YStart = Y;\n"
10990
" let MouseInside = LocalMouseX >= 0 && LocalMouseY >= 0 && LocalMouseX < w && LocalMouseY < h && SubMenuActive == -1;\n"
10991
"\n"
10992
" context.globalAlpha = 1;\n"
10993
" context.fillStyle = nBackColorsDark[cidx];\n"
10994
" cidx = 1-cidx;\n"
10995
" context.fillRect(0, hstart, w, gh);\n"
10996
" context.strokeStyle = color;\n"
10997
" context.fillStyle = color;\n"
10998
" let PercentileStart = Math.max(0, Math.floor(0.01*Percentile / PercentileData.length));\n"
10999
" {\n"
11000
" context.beginPath();\n"
11001
" context.moveTo(X,Y);\n"
11002
" for(let i = PercentileStart; i < PercentileData.length; ++i)\n"
11003
" {\n"
11004
" X = i * WidthPerElement - PercentileOffset;\n"
11005
" Y = Math.max(YStart - PercentileData[i] * fHeightScale2, hstart);\n"
11006
" context.lineTo(X, Y);\n"
11007
" }\n"
11008
" context.stroke();\n"
11009
" context.lineTo(X, YStart);\n"
11010
" context.globalAlpha = GRAPH_ALPHA;\n"
11011
" context.fill();\n"
11012
" }\n"
11013
" context.globalAlpha = 1;\n"
11014
" context.fillStyle = \'wheat\';\n"
11015
" context.textAlign=\'right\';\n"
11016
" context.fillText(FormatTimeText(Reference, T), nWidth, hstart + FontHeight);\n"
11017
" context.fillText(\'100%\', nWidth, hstart + gh-2);\n"
11018
" context.textAlign=\'centered\';\n"
11019
" Percentile = BasePrc;\n"
11020
" context.fillText( ((Percentile + 100)/2).toFixed(2) + \'%\', nWidth/2, hstart + gh-2);\n"
11021
" context.textAlign=\'left\';\n"
11022
" context.fillText(Percentile.toFixed(2) + \"% [Samples:\" + PercentileCount + \"]\", 0, hstart + gh-2);\n"
11023
" context.fillText(FormatName(T), 15, hstart + FontHeight);\n"
11024
" context.fillText(Percentile + \'%\', nWidth, hstart + FontHeight);\n"
11025
"\n"
11026
" if(MouseInside)\n"
11027
" {\n"
11028
" let Element = (PercentileOffset + LocalMouseX) / WidthPerElement;\n"
11029
" let Rounded = Math.round(Element);\n"
11030
" let HighlightIndex = Math.max(0, Math.min(Rounded, PercentileData.length-1));\n"
11031
" X = HighlightIndex * WidthPerElement - PercentileOffset;\n"
11032
" let Y = YStart - Math.min(PercentileData[HighlightIndex], Reference) * fHeightScale2;\n"
11033
" context.strokeStyle = color;\n"
11034
" context.beginPath();\n"
11035
" let CrossX = X;\n"
11036
" let CrossY = Y;\n"
11037
" context.moveTo(CrossX-2, CrossY-2);\n"
11038
" context.lineTo(CrossX+2, CrossY+2);\n"
11039
" context.moveTo(CrossX+2, CrossY-2);\n"
11040
" context.lineTo(CrossX-2, CrossY+2);\n"
11041
" context.moveTo(CrossX, hstart);\n"
11042
" context.lineTo(CrossX, hstart + gh);\n"
11043
" context.stroke();\n"
11044
" TimerState.tooltipy = Math.min(YStart - BoxHeight, Y) + View.y;\n"
11045
" let Perc = 0;\n"
11046
" if(PERCENTILE_SAMPLES < PercentileCount)\n"
11047
" {\n"
11048
" let Idx = PercentileCount - PERCENTILE_SAMPLES + HighlightIndex;\n"
11049
" Perc = 100 * Idx / (PercentileCount-1);\n"
11050
" }\n"
11051
" else\n"
11052
" {\n"
11053
" let Idx = HighlightIndex - (PERCENTILE_SAMPLES - PercentileCount);\n"
11054
" Idx = Math.max(Idx, 0);\n"
11055
" Perc = 100 * (Idx / (PercentileCount-1))\n"
11056
" }\n"
11057
" TimerState.tooltipstring = FormatTime(Perc) + \'% \' + FormatTimeText(PercentileData[HighlightIndex], T);\n"
11058
" }\n"
11059
" hstart += gh;\n"
11060
" }\n"
11061
" }\n"
11062
" }\n"
11063
" ProfileLeave();\n"
11064
"}\n"
11065
"\n"
11066
"function DrawGraphViewLargeHeader(context, Text, Y, TextOffset)\n"
11067
"{\n"
11068
" context.textAlign = \"left\";\n"
11069
" context.fillStyle = \"grey\";\n"
11070
" context.strokeStyle = \"grey\";\n"
11071
" context.textBaseline = \"top\";\n"
11072
" context.font = FontLarger;\n"
11073
" context.beginPath();\n"
11074
" context.moveTo(0, Y);\n"
11075
" context.lineTo(nWidth, Y);\n"
11076
" context.stroke();\n"
11077
" context.fillText(Text, 0, Y + 2 + TextOffset);\n"
11078
" context.font = Font;\n"
11079
" context.textBaseline = \"alphabetic\";\n"
11080
" return Y + 2 + FontHeightLarger;\n"
11081
"}\n"
11082
"\n"
11083
"\n"
11084
"function CounterType(k)\n"
11085
"{\n"
11086
" let T = TimerArray[GetTimer(k)];\n"
11087
" let t0 = T.idtype;\n"
11088
" if(t0 == TYPE_TIMER)\n"
11089
" {\n"
11090
" if(T.timertype == MicroProfileTokenTypeGpu)\n"
11091
" {\n"
11092
" return 0;\n"
11093
" }\n"
11094
" else\n"
11095
" {\n"
11096
" return 1;\n"
11097
" }\n"
11098
" }\n"
11099
" else\n"
11100
" {\n"
11101
" if(T.format == FormatCounterBytes)\n"
11102
" {\n"
11103
" return 3;\n"
11104
" }\n"
11105
" else\n"
11106
" {\n"
11107
" return 2;\n"
11108
" }\n"
11109
" }\n"
11110
"}\n"
11111
"\n"
11112
"function CounterTypeName(n)\n"
11113
"{\n"
11114
" if(n == 0)\n"
11115
" return \"GPU\";\n"
11116
" if(n == 3)\n"
11117
" return \"Byte Counter\";\n"
11118
" if(n == 2)\n"
11119
" return \"Counter\";\n"
11120
"\n"
11121
" return \"CPU\";\n"
11122
"}\n"
11123
"\n"
11124
"function SortGraphs()\n"
11125
"{\n"
11126
" let TimerMap = FrameData.TimerMap;\n"
11127
" let Keys = [];\n"
11128
" for(let key in TimerMap)\n"
11129
" {\n"
11130
" let idx = GetTimer(key);\n"
11131
" let T = TimerArray[idx];\n"
11132
" if(!IsGroup(key) && T.e)\n"
11133
" {\n"
11134
" Keys.push(key);\n"
11135
" }\n"
11136
" }\n"
11137
" // sort based on idtype\n"
11138
" Keys.sort(function(l, r) {\n"
11139
" return CounterType(l)-CounterType(r);\n"
11140
" });\n"
11141
"\n"
11142
" return Keys;\n"
11143
"}\n"
11144
"\n"
11145
"function GetGraphTimeSource(TimerState)\n"
11146
"{\n"
11147
" if(Settings.GraphSoftMode)\n"
11148
" return TimerState.TimeSoft;\n"
11149
" else\n"
11150
" return TimerState.Time;\n"
11151
"}\n"
11152
"\n"
11153
"\n"
11154
"function DrawGraph(View, LocalMouseX, LocalMouseY, SubIndex, Split)\n"
11155
"{\n"
11156
" let TimerMap = FrameData.TimerMap;\n"
11157
" if(!TimerMap)\n"
11158
" return;\n"
11159
"\n"
11160
" ProfileEnter(\"DrawGraph\");\n"
11161
"\n"
11162
" let Canvas = View.Canvas[View.BackBuffer];\n"
11163
" let context = Canvas.getContext(\'2d\');\n"
11164
" context.clearRect(0, 0, View.w, View.h);\n"
11165
"\n"
11166
" let h = View.h;\n"
11167
" let w = View.w;\n"
11168
" let fHeightScale = h / ReferenceGraph;\n"
11169
" let MouseDragging = 0;\n"
11170
" let fWidth = w / (FRAME_COUNT-1);\n"
11171
" let HighlightFrame = -1;\n"
11172
" let GraphKey = null;\n"
11173
" let GraphBest = 0;\n"
11174
" let MouseTime = ReferenceGraph * (1-(LocalMouseY / h));\n"
11175
"\n"
11176
" \n"
11177
" let Keys = SortGraphs();\n"
11178
" let NumGraphs = Keys.length;\n"
11179
"\n"
11180
" if(LocalMouseX >= 0 && LocalMouseY >= 0 && LocalMouseX < w && LocalMouseY < h && SubMenuActive == -1)\n"
11181
" {\n"
11182
" var index = Math.floor(FRAME_COUNT * LocalMouseX / w);\n"
11183
" HighlightFrame = index;\n"
11184
" for(var key in TimerMap)\n"
11185
" {\n"
11186
" var idx = GetTimer(key);\n"
11187
" var T = TimerArray[idx];\n"
11188
" var TimerState = TimerMap[key];\n"
11189
" var Time = GetGraphTimeSource(TimerState);\n"
11190
" if(Time[index] >= MouseTime && (GraphBest == 0 || Time[index] <= GraphBest))\n"
11191
" {\n"
11192
" GraphKey = key;\n"
11193
" GraphBest = Time[index];\n"
11194
" }\n"
11195
" }\n"
11196
" ToolTipCallback = function(canvas, x, y)\n"
11197
" {\n"
11198
" if(Split)\n"
11199
" {\n"
11200
" let TimerMap = FrameData.TimerMap;\n"
11201
" let context = canvas.getContext(\'2d\');\n"
11202
" context.font = Font;\n"
11203
" let XPos = x - 20;\n"
11204
" for(let key in TimerMap)\n"
11205
" {\n"
11206
" let idx = GetTimer(key);\n"
11207
" let T = TimerArray[idx];\n"
11208
" if(T.e)\n"
11209
" {\n"
11210
" let TimerState = TimerMap[key];\n"
11211
" let Time = GetGraphTimeSource(TimerState);\n"
11212
" if(TimerState.tooltipysoft)\n"
11213
" {\n"
11214
" let RATE = 0.05;\n"
11215
" if(Math.abs(TimerState.tooltipysoft - TimerState.tooltipy) > 6)\n"
11216
" {\n"
11217
" TimerState.tooltipysoft = TimerState.tooltipy * RATE + TimerState.tooltipysoft * (1-RATE);\n"
11218
" }\n"
11219
" }\n"
11220
" else\n"
11221
" {\n"
11222
" TimerState.tooltipysoft = TimerState.tooltipy;\n"
11223
" }\n"
11224
" let Y = TimerState.tooltipysoft;\n"
11225
" let str = \'\' + FormatTimeText(Time[index], T);\n"
11226
" let w = context.measureText(str, XPos, Y).width;\n"
11227
" let X = Math.max(0, XPos - w);\n"
11228
" context.fillStyle = \'black\';\n"
11229
" context.fillRect(X - 1, Y-1 , w+2, BoxHeight+2);\n"
11230
" context.fillStyle = \'white\';\n"
11231
" context.textAlign = \'right\';\n"
11232
" context.fillText(str, X + w, Y+BoxHeight-2);\n"
11233
" }\n"
11234
"\n"
11235
" }\n"
11236
" context.textAlign = \'left\';\n"
11237
" }\n"
11238
" else\n"
11239
" {\n"
11240
" var StringArray = [];\n"
11241
" var ColorArray = [];\n"
11242
" var TimerMap = FrameData.TimerMap;\n"
11243
" for(var key in TimerMap)\n"
11244
" {\n"
11245
" if(!IsGroup(key))\n"
11246
" {\n"
11247
" var idx = GetTimer(key);\n"
11248
" var T = TimerArray[idx];\n"
11249
" var TimerState = TimerMap[key];\n"
11250
" var Time = GetGraphTimeSource(TimerState);\n"
11251
" ColorArray.push(TimerArray[idx].color);\n"
11252
" StringArray.push(\'\' + T.name);\n"
11253
" ColorArray.push(\'white\');\n"
11254
" StringArray.push(\'\' + FormatTime(Time[index]) + \'ms\') ;\n"
11255
" }\n"
11256
" }\n"
11257
" return {c:ColorArray,a:StringArray};\n"
11258
" }\n"
11259
" }\n"
11260
"\n"
11261
" }\n"
11262
"\n"
11263
" if(Split)\n"
11264
" {\n"
11265
" if(NumGraphs)\n"
11266
" {\n"
11267
"\n"
11268
" var hstart = 0;\n"
11269
" let gh = h / NumGraphs;\n"
11270
" let CurrentType = -1;\n"
11271
" let cidx = 1;\n"
11272
" for(let index in Keys)\n"
11273
" {\n"
11274
" let key = Keys[index];\n"
11275
" let idx = GetTimer(key);\n"
11276
" let T = TimerArray[idx];\n"
11277
" let TimerState = TimerMap[key];\n"
11278
" if(!IsGroup(key) && T.e)\n"
11279
" {\n"
11280
"\n"
11281
" let SubGraphSettings = GetSubGraphSettings(GetFullName(T));\n"
11282
" let Reference = GetSubGraphReferenceTime(T, SubGraphSettings, TimerState);\n"
11283
" let fHeightScale2 = gh / Reference;\n"
11284
"\n"
11285
" let Time = GetGraphTimeSource(TimerState);\n"
11286
" let color = TimerArray[idx].color;\n"
11287
" let X = w - Time.length*fWidth;\n"
11288
" let Y = hstart + gh;\n"
11289
" let YHeader = hstart;\n"
11290
" let YStart = Y;\n"
11291
" context.globalAlpha = 1;\n"
11292
" context.fillStyle = nBackColorsDark[cidx];\n"
11293
" cidx = 1-cidx;\n"
11294
" context.fillRect(0, hstart, w, gh);\n"
11295
"\n"
11296
" context.strokeStyle = color;\n"
11297
" context.fillStyle = color;\n"
11298
" context.beginPath();\n"
11299
" context.moveTo(X,Y);\n"
11300
" for(let i = 0; i < Time.length; ++i)\n"
11301
" {\n"
11302
" Y = Math.max(YStart - Time[i] * fHeightScale2, hstart);\n"
11303
" context.lineTo(X, Y);\n"
11304
" X += fWidth;\n"
11305
"\n"
11306
" }\n"
11307
" context.stroke();\n"
11308
" context.lineTo(X, YStart);\n"
11309
" context.globalAlpha = GRAPH_ALPHA;\n"
11310
" context.fill();\n"
11311
"\n"
11312
"\n"
11313
" context.globalAlpha = 1;\n"
11314
" context.fillStyle = \'wheat\';\n"
11315
" context.textAlign=\'right\';\n"
11316
" context.fillText(FormatTimeText(Reference, T), nWidth, hstart + FontHeight);\n"
11317
" {\n"
11318
" let Value = Time[Time.length-1];\n"
11319
" let YPos = Value * fHeightScale2 + Math.floor(0.5*FontHeight);\n"
11320
" const sp = FontHeight+2;\n"
11321
" YPos = Math.min(Math.max(sp, YPos), gh-2*sp);\n"
11322
" let Y = YStart - YPos;\n"
11323
" TimerState.finaly = Y;\n"
11324
" if(TimerState.finalysoft)\n"
11325
" {\n"
11326
" let RATE = 0.025;\n"
11327
" if(Math.abs(TimerState.finalysoft - TimerState.finaly) > 6)\n"
11328
" {\n"
11329
" TimerState.finalysoft = TimerState.finaly * RATE + TimerState.finalysoft * (1-RATE);\n"
11330
" }\n"
11331
" }\n"
11332
" else\n"
11333
" {\n"
11334
" TimerState.finalysoft = TimerState.finaly;\n"
11335
" }\n"
11336
" Y = TimerState.finalysoft;\n"
11337
" let str = \'\' + FormatTimeText(Value, T);\n"
11338
" let X = nWidth;\n"
11339
" let w = context.measureText(str, X, Y).width;\n"
11340
" context.fillStyle = \'black\';\n"
11341
" let a = context.globalAlpha;\n"
11342
" context.globalAlpha = 0.3;\n"
11343
" context.fillRect(X-w, Y-1-FontHeight , w+2, BoxHeight+2);\n"
11344
" context.globalAlpha = a;\n"
11345
" context.fillStyle = \'white\';\n"
11346
" context.fillText(FormatTimeText(Value, T), nWidth, TimerState.finalysoft);\n"
11347
" \n"
11348
"\n"
11349
" }\n"
11350
" context.textAlign=\'left\';\n"
11351
" context.fillText(FormatName(T), 15, hstart + FontHeight);\n"
11352
"\n"
11353
"\n"
11354
" let Type = CounterType(key);\n"
11355
" if(Type != CurrentType)\n"
11356
" { \n"
11357
" CurrentType = Type;\n"
11358
" DrawGraphViewLargeHeader(context, CounterTypeName(CurrentType), YHeader, FontHeight + 3);\n"
11359
" }\n"
11360
"\n"
11361
" if(HighlightFrame >= 0)\n"
11362
" {\n"
11363
" let X = w - Time.length * fWidth + fWidth * HighlightFrame;\n"
11364
" let Y = YStart - Math.min(Time[HighlightFrame], Reference) * fHeightScale2;\n"
11365
" context.strokeStyle = color;\n"
11366
" context.beginPath();\n"
11367
" let CrossX = X;\n"
11368
" let CrossY = Y;\n"
11369
" context.moveTo(CrossX-2, CrossY-2);\n"
11370
" context.lineTo(CrossX+2, CrossY+2);\n"
11371
" context.moveTo(CrossX+2, CrossY-2);\n"
11372
" context.lineTo(CrossX-2, CrossY+2);\n"
11373
" context.moveTo(CrossX, hstart);\n"
11374
" context.lineTo(CrossX, hstart + gh);\n"
11375
" context.stroke();\n"
11376
" TimerState.tooltipy = Math.min(YStart - BoxHeight, Y) + View.y;\n"
11377
" }\n"
11378
" hstart += gh;\n"
11379
" }\n"
11380
" }\n"
11381
" }\n"
11382
" }\n"
11383
" else\n"
11384
" {\n"
11385
" }\n"
11386
"\n"
11387
" ProfileLeave();\n"
11388
"}\n"
11389
"\n"
11390
"function StringHash(s) //note: matching code in microprofile.cpp: uint32_t MicroProfileStringHash(const char* pString)\n"
11391
"{\n"
11392
" var h = 0xfeedba3e;\n"
11393
" for(var i = 0; i < s.length; ++i)\n"
11394
" {\n"
11395
" h = s.charCodeAt(i) + ((h << 5) - h);\n"
11396
" h = h & h;\n"
11397
" }\n"
11398
" return Math.abs(h);\n"
11399
"}\n"
11400
"\n"
11401
"function StringColorIndex(Name)\n"
11402
"{\n"
11403
" var h = StringHash(Name);\n"
11404
" var cidx = Math.floor(360*(h / (1<<32-1)) );\n"
11405
" return cidx;\n"
11406
"}\n"
11407
"\n"
11408
"function ColorFromString(Name, S, L)\n"
11409
"{\n"
11410
" var H = StringColorIndex(Name);\n"
11411
" return \"hsl(\" + H + \",\" + S + \"%, \" + L+ \"%)\";\n"
11412
"}\n"
11413
"\n"
11414
"function LerpColor(v)\n"
11415
"{\n"
11416
" var R_0 = 0;\n"
11417
" var G_0 = 1;\n"
11418
" var B_0 = 0;\n"
11419
"\n"
11420
" var R_1 = 1;\n"
11421
" var G_1 = 0.5;\n"
11422
" var B_1 = 0;\n"
11423
"\n"
11424
" var R_2 = 1;\n"
11425
" var G_2 = 0;\n"
11426
" var B_3 = 0;\n"
11427
" var R;\n"
11428
" var G;\n"
11429
" if(v < 0.5)\n"
11430
" {\n"
11431
" v *= 2;\n"
11432
" var v0 = (1-v);\n"
11433
" R = R_0 * v0 + R_1 * v;\n"
11434
" G = G_0 * v0 + G_1 * v;\n"
11435
"\n"
11436
" }\n"
11437
" else\n"
11438
" {\n"
11439
" v = (v-0.5) * 2;\n"
11440
" var v0 = (1-v);\n"
11441
" R = R_1 * v0 + R_2 * v;\n"
11442
" G = G_1 * v0 + G_2 * v;\n"
11443
" }\n"
11444
" R *= 255;\n"
11445
" G *= 255;\n"
11446
" return \"rgb(\" + R.toFixed(0) + \",\" + G.toFixed(0) + \",0)\";\n"
11447
"\n"
11448
"}\n"
11449
"\n"
11450
"function DrawRange(context, X, XEnd, Y, YEnd, ColorBack, ColorFront)\n"
11451
"{\n"
11452
" if(X < XEnd)\n"
11453
" {\n"
11454
" var W = XEnd - X;\n"
11455
" var H = YEnd - Y;\n"
11456
" context.globalAlpha = 0.1;\n"
11457
" context.fillStyle = ColorBack;\n"
11458
" context.fillRect(X, Y, W, H);\n"
11459
" context.globalAlpha = 1;\n"
11460
" context.strokeStyle = ColorFront;\n"
11461
" context.beginPath();\n"
11462
" context.moveTo(X, 0);\n"
11463
" context.lineTo(X, H);\n"
11464
" context.moveTo(X+W, 0);\n"
11465
" context.lineTo(X+W, H);\n"
11466
" // context.closePath();\n"
11467
" context.stroke();\n"
11468
" }\n"
11469
"}\n"
11470
"\n"
11471
"\n"
11472
"function DrawHistory(View, LocalMouseX, LocalMouseY)\n"
11473
"{\n"
11474
" ProfileEnter(\"DrawHistory\");\n"
11475
" var Canvas = View.Canvas[View.BackBuffer];\n"
11476
" var context = Canvas.getContext(\'2d\');\n"
11477
" context.clearRect(0, 0, View.w, View.h);\n"
11478
" if(!FrameData.Time)\n"
11479
" return;\n"
11480
" var fHeight = View.h;\n"
11481
" var fWidth = nWidth / FRAME_COUNT;\n"
11482
" var fHeightScale = fHeight / ReferenceHistory;\n"
11483
" var fX = 0;\n"
11484
" var FrameIndex = -1;\n"
11485
" var MouseDragging = 0;\n"
11486
" var GreenTime = (Settings.TargetTime * 0.9);\n"
11487
" var RedBegin = (Settings.TargetTime * 1.1);\n"
11488
" var LerpDist = 1.0 / (RedBegin - GreenTime);\n"
11489
" var id0 = -1;\n"
11490
" var id1 = -1;\n"
11491
"\n"
11492
" if(MouseDragActiveXEnd > MouseDragActiveXStart)\n"
11493
" {\n"
11494
" var idx0 = Math.ceil(FRAME_COUNT * MouseDragActiveXStart / nWidth);\n"
11495
" var idx1 = Math.floor(FRAME_COUNT * MouseDragActiveXEnd / nWidth);\n"
11496
" idx0 = Clamp(idx0, 0, FRAME_COUNT-1);\n"
11497
" idx1 = Clamp(idx1, 0, FRAME_COUNT-1);\n"
11498
" id0 = FrameData.Ids[idx0];\n"
11499
" id1 = FrameData.Ids[idx1];\n"
11500
" }\n"
11501
"\n"
11502
"\n"
11503
" var ToolTipFrame = -1;\n"
11504
" for(var i = 0; i < FRAME_COUNT; i++)\n"
11505
" {\n"
11506
" var fMs = FrameData.Time[i];\n"
11507
" var fPrc = (fMs - GreenTime) * LerpDist;\n"
11508
" fPrc = Clamp(fPrc, 0, 1);\n"
11509
" var color = LerpColor(fPrc);\n"
11510
" var fid = FrameData.Ids[i];\n"
11511
" if(fid >= id0 && fid <= id1)\n"
11512
" {\n"
11513
" color = \'cyan\';\n"
11514
" }else if(FrameData.Frozen[i])\n"
11515
" {\n"
11516
" color = \'purple\';\n"
11517
" }\n"
11518
"\n"
11519
"\n"
11520
" var fH = fHeightScale * fMs;\n"
11521
" var bMouse = LocalMouseX > fX && LocalMouseX < fX + fWidth+1 && MouseY <= HistoryHeight;\n"
11522
" if(bMouse && !MouseDragging)\n"
11523
" {\n"
11524
" context.fillStyle = FRAME_HISTORY_COLOR_GPU;\n"
11525
" ToolTipFrame = i;\n"
11526
" }\n"
11527
" else\n"
11528
" {\n"
11529
" context.fillStyle = color;\n"
11530
" }\n"
11531
" context.fillRect(fX, fHeight - fH, fWidth-1, fH);\n"
11532
" fX += fWidth;\n"
11533
" }\n"
11534
"\n"
11535
"\n"
11536
" DrawRange(context, MouseDragActiveXStart, MouseDragActiveXEnd, 0, HistoryHeight, \'#59d0ff\', \'#00ddff\');\n"
11537
"\n"
11538
"\n"
11539
" var fH = fHeight - ";
11540
11541
const size_t g_MicroProfileHtmlLive_begin_1_size = sizeof(g_MicroProfileHtmlLive_begin_1);
11542
const char g_MicroProfileHtmlLive_begin_2[] =
11543
"fHeightScale * Settings.TargetTime;\n"
11544
" context.fillStyle = \'wheat\';\n"
11545
" context.strokeStyle = \'wheat\';\n"
11546
" context.beginPath();\n"
11547
" context.moveTo(0, fH);\n"
11548
" context.lineTo(nWidth, fH);\n"
11549
" // context.closePath();\n"
11550
" context.stroke();\n"
11551
" var YText;\n"
11552
" if(fH > HistoryHeight * 0.25)\n"
11553
" {\n"
11554
" YText = fH - FontAscent;\n"
11555
" }\n"
11556
" else\n"
11557
" {\n"
11558
" YText = fH + FontHeight;\n"
11559
" }\n"
11560
"\n"
11561
" context.fillText(Settings.TargetTime + \'ms\', 3, YText);\n"
11562
" context.textAlign=\'right\';\n"
11563
" context.fillText(FormatTime(ReferenceHistory) + \'ms\', nWidth, FontHeight);\n"
11564
" context.textAlign=\'left\';\n"
11565
"\n"
11566
"\n"
11567
"\n"
11568
" if(ToolTipFrame >= 0)\n"
11569
" {\n"
11570
" var fMs = FrameData.Time[ToolTipFrame];\n"
11571
" var Frozen = FrameData.Frozen[ToolTipFrame];\n"
11572
" ToolTipCallback = function()\n"
11573
" {\n"
11574
" var StringArray = [];\n"
11575
" StringArray.push(\"Frame\");\n"
11576
" StringArray.push(\"\" + ToolTipFrame);\n"
11577
" StringArray.push(\"Time\");\n"
11578
" StringArray.push(\"\" + fMs.toFixed(3));\n"
11579
" if(Frozen)\n"
11580
" {\n"
11581
" StringArray.push(\"Frozen & Unreliable\");\n"
11582
" StringArray.push(\"\");\n"
11583
" }\n"
11584
" return StringArray;\n"
11585
" }\n"
11586
" }\n"
11587
"\n"
11588
"\n"
11589
" ProfileLeave();\n"
11590
"\n"
11591
"}\n"
11592
"function MouseInRect(Rect)\n"
11593
"{\n"
11594
" return MouseInside(Rect.x, Rect.y, Rect.w, Rect.h);\n"
11595
"}\n"
11596
"function MouseInside(X, Y, W, H)\n"
11597
"{\n"
11598
" return MouseX >= X && MouseX <= X + W && MouseY >= Y && MouseY <= Y + H;\n"
11599
"}\n"
11600
"\n"
11601
"var MessageText = \"\";\n"
11602
"var MessageTimeout = -1;\n"
11603
"var MessageTimeoutLast = new Date();\n"
11604
"var MessageShowSpinner = 0;\n"
11605
"function SetMessage(text, TimeOut, ShowSpinner)\n"
11606
"{\n"
11607
" if(TimeOut)\n"
11608
" {\n"
11609
" MessageTimeout = TimeOut;\n"
11610
" }\n"
11611
" else\n"
11612
" {\n"
11613
" MessageTimeout = -1;\n"
11614
" }\n"
11615
" MessageText = text;\n"
11616
" MessageShowSpinner = ShowSpinner;\n"
11617
"}\n"
11618
"function ClearMessage(Message)\n"
11619
"{\n"
11620
" if(Message == MessageText)\n"
11621
" {\n"
11622
" MessageText = \"\";\n"
11623
" MessageTimeout = -1;\n"
11624
" }\n"
11625
"}\n"
11626
"\n"
11627
"function DrawMessage()\n"
11628
"{\n"
11629
" var context = CanvasDetailedView.getContext(\'2d\');\n"
11630
" var Now = new Date();\n"
11631
" var Delta = Now - MessageTimeoutLast;\n"
11632
" if(MessageTimeout>0)\n"
11633
" {\n"
11634
" MessageTimeout -= Delta;\n"
11635
" if(MessageTimeout<= 0)\n"
11636
" {\n"
11637
" MessageText = \"\";\n"
11638
" MessageTimeout = -1;\n"
11639
" }\n"
11640
"\n"
11641
" }\n"
11642
" MessageTimeoutLast = Now;\n"
11643
"\n"
11644
" var Text = MessageText;\n"
11645
" var X = nWidth / 2;\n"
11646
"\n"
11647
" var Y = nHeight / 2;\n"
11648
" context.font = FontFlash;\n"
11649
" context.textAlign = \'center\';\n"
11650
" context.fillStyle = \'red\';\n"
11651
"\n"
11652
" function MSG(a, Spinner)\n"
11653
" {\n"
11654
" context.fillText(a, X, Y);\n"
11655
" if(Spinner)\n"
11656
" {\n"
11657
" var w = context.measureText(a).width;\n"
11658
" SpinnerDraw(1, context, SpinnerText0, X + 3 + w*0.5, Y - 25, 30, 30);\n"
11659
" SpinnerDraw(1, context, SpinnerText1, X - 3 - w*0.5 - 30, Y - 25, 30, 30);\n"
11660
" }\n"
11661
" Y -= 60;\n"
11662
" }\n"
11663
" if(!HelpFade)\n"
11664
" HelpFade = new Date();\n"
11665
" var HelpFadeTime = new Date() - HelpFade;\n"
11666
" if(HelpFadeTime < 2000)\n"
11667
" {\n"
11668
" var Alpha = 1 - (HelpFadeTime/2000);\n"
11669
" context.globalAlpha = Alpha;\n"
11670
" context.fillText(\"Press \'h\' for help\", X, 200);\n"
11671
" context.globalAlpha = 1;\n"
11672
" }\n"
11673
"\n"
11674
" if(Text != \"\")\n"
11675
" {\n"
11676
" MSG(Text);\n"
11677
" }\n"
11678
" if(IsFrozen)\n"
11679
" {\n"
11680
" MSG(\"FROZEN[space]\");\n"
11681
" }\n"
11682
" if(Settings.ViewCompressed && ViewCompressedTimeout > 0)\n"
11683
" {\n"
11684
" ViewCompressedTimeout -= Delta;\n"
11685
" MSG(\"Compressed: [CTRL-SPACE] To Exit\");\n"
11686
" }\n"
11687
"\n"
11688
" PresetPending++; //hack: wait 20 frames before showing enable messages to prevent it from showing when loading settings. [[[test]]]\n"
11689
" if(WSIsOpen && PresetPending > 20)\n"
11690
" {\n"
11691
" if(Settings.ViewActive != VIEW_COUNTERS)\n"
11692
" {\n"
11693
" if(GroupsEnabled == 0)\n"
11694
" {\n"
11695
" MSG(\"Paused: Enable groups in \'Control\' menu to unpause\");\n"
11696
" }\n"
11697
" if((CountersEnabled == 0 && TimersEnabled == 0) && Settings.ViewActive != VIEW_GRAPH_THREAD_GROUP)\n"
11698
" {\n"
11699
" MSG(\"Enable Timers or Counters\");\n"
11700
" }\n"
11701
" }\n"
11702
" }\n"
11703
" context.textAlign = \'left\';\n"
11704
" context.font = Font;\n"
11705
"}\n"
11706
"\n"
11707
"function DrawGraphSettingsMenu(context, XBase, Y, width, height)\n"
11708
"{\n"
11709
" if(SubMenuActive != SubMenuGraphSettings)\n"
11710
" {\n"
11711
" SubMenuGraphSettingsIndex = -1;\n"
11712
" SubMenuGraphSettingsKey = \"\";\n"
11713
" }\n"
11714
" if(!ShowMenu())\n"
11715
" {\n"
11716
" return;\n"
11717
" }\n"
11718
" if(!(Settings.ViewActive == VIEW_GRAPH_SPLIT || Settings.ViewActive == VIEW_GRAPH_PERCENTILE))\n"
11719
" {\n"
11720
" return;\n"
11721
" }\n"
11722
" \n"
11723
" let TimerMap = FrameData.TimerMap;\n"
11724
" let Keys = SortGraphs();\n"
11725
" let NumGraphs = Keys.length;\n"
11726
"\n"
11727
" let h = height;\n"
11728
" let w = width;\n"
11729
" let hstart = Y;\n"
11730
" let gh = h / NumGraphs;\n"
11731
" NumGraphs = 0;\n"
11732
" for(let index in Keys)\n"
11733
" {\n"
11734
" let key = Keys[index];\n"
11735
" {\n"
11736
" let idx = GetTimer(key);\n"
11737
" let T = TimerArray[idx];\n"
11738
" if(T.e)\n"
11739
" {\n"
11740
" let X = XBase+1;\n"
11741
" let Y = hstart+1;\n"
11742
" let MenuText = \">\";\n"
11743
" let w2 = 2 + context.measureText(MenuText).width;\n"
11744
" let bMouseInside = MouseInside(X, Y, w2, 4 + FontHeight);\n"
11745
" context.fillStyle = bMouseInside || (SubMenuGraphSettings == SubMenuActive && SubMenuGraphSettingsIndex == NumGraphs) ? nBackColors[1] : \'black\';\n"
11746
" context.fillRect(X, Y, w2, 4 + FontHeight);\n"
11747
" context.fillStyle = \'#ffffff\';\n"
11748
" context.fillText(MenuText, X, Y + FontHeight);\n"
11749
" context.textAlign = \'left\';\n"
11750
" if(bMouseInside)\n"
11751
" {\n"
11752
" SubMenuGraphSettingsIndex = NumGraphs;\n"
11753
" SubMenuGraphSettingsKey = GetFullName(T);\n"
11754
" CaptureButtonX = X + w2 + 2;\n"
11755
" CaptureButtonY = Y;\n"
11756
" EnableMenu(SubMenuGraphSettings);\n"
11757
" }\n"
11758
" NumGraphs++;\n"
11759
" hstart += gh;\n"
11760
"\n"
11761
"\n"
11762
" }\n"
11763
" }\n"
11764
" }\n"
11765
"}\n"
11766
"\n"
11767
"function DrawCaptureMenu(context)\n"
11768
"{\n"
11769
" MouseInCaptureButton = 0;\n"
11770
" if(!ShowMenu())\n"
11771
" {\n"
11772
" return;\n"
11773
" }\n"
11774
"\n"
11775
" var CaptureRange = MouseDragActiveXStart < MouseDragActiveXEnd ? \"Selection\" : (\"\"+Settings.CaptureFrames);\n"
11776
" var CaptureText = \"Capture[\" + CaptureRange + \"]\";\n"
11777
" var w = 10 + context.measureText(CaptureText).width;\n"
11778
" var X = nWidth / 2 - w / 2;\n"
11779
" var XCenter = nWidth / 2;\n"
11780
" var Y = nHeight - 30;\n"
11781
" MouseInCaptureButton = MouseInside(X, Y, w, 4 + FontHeight);\n"
11782
" context.textAlign = \'center\';\n"
11783
" context.fillStyle = MouseInCaptureButton ? nBackColors[1] : \'black\';\n"
11784
" context.fillRect(X, Y, w, 4 + FontHeight);\n"
11785
" context.fillStyle = \'#ffffff\';\n"
11786
" context.fillText(CaptureText, XCenter, Y + FontHeight);\n"
11787
"\n"
11788
"\n"
11789
"\n"
11790
" X += w + 2;\n"
11791
" var MenuText = \"^\";\n"
11792
" var w2 = 10 + context.measureText(MenuText).width;\n"
11793
" var bMouseInCaptureMenu = MouseInside(X, Y, w2, 4 + FontHeight);\n"
11794
" context.fillStyle = bMouseInCaptureMenu ? nBackColors[1] : \'black\';\n"
11795
" context.fillRect(X, Y, w2, 4 + FontHeight);\n"
11796
"\n"
11797
" context.fillStyle = \'#ffffff\';\n"
11798
" context.fillText(MenuText, X + w2*0.5, Y + FontHeight);\n"
11799
"\n"
11800
" let X1 = X + w2 + 10;\n"
11801
" if(CaptureTriggerDelta)\n"
11802
" {\n"
11803
" let text = FormatTime(CaptureTriggerDelta);\n"
11804
" let w = 10 + context.measureText(\"text\").width;\n"
11805
" context.fillStyle = \'black\';\n"
11806
" context.fillRect(X1, Y, w, 4 + FontHeight);\n"
11807
" context.fillStyle = \'#ffffff\';\n"
11808
" context.fillText(text, X1 + w*0.5, Y + FontHeight);\n"
11809
" X1 += w;\n"
11810
" }\n"
11811
"\n"
11812
" let Pending = (CaptureTriggerTime != null && CaptureTriggerTimeType == 2);\n"
11813
" if(AutoCaptureEnabled || Pending)\n"
11814
" {\n"
11815
" let d = Dots();\n"
11816
" let AutoStatus = Pending ? (\" pending\" + Dots()) : \"\";\n"
11817
" let Source = GetAutoCaptureString();\n"
11818
" let Threshold = FormatTime(Settings.AutoCaptureTheshold);\n"
11819
" let str = \"Autocapture \" + AutoStatus + \" Source:\'\" + Source + \"\' Threshold:\" + Threshold + \"ms Repeat=\" + (Pending?Settings.AutoCaptureRepeat:AutoCaptureEnabled);\n"
11820
" let w = 10 + context.measureText(str).width;\n"
11821
" context.fillStyle = \'black\';\n"
11822
" context.fillRect(X1, Y, w, 4 + FontHeight);\n"
11823
" context.fillStyle = \'#ffffff\';\n"
11824
" context.fillText(str, X1 + w*0.5, Y + FontHeight);\n"
11825
" X1 += w;\n"
11826
" }\n"
11827
"\n"
11828
" context.textAlign = \'left\';\n"
11829
" if(bMouseInCaptureMenu)\n"
11830
" {\n"
11831
" CaptureButtonX = X + w2;\n"
11832
" CaptureButtonY = Y;\n"
11833
" EnableMenu(SubMenuCapture);\n"
11834
" }\n"
11835
"}\n"
11836
"function UpdateX7Views()\n"
11837
"{\n"
11838
" if(Settings.ViewActive == VIEW_BAR_SINGLE || Settings.ViewActive == VIEW_BAR_ALL)\n"
11839
" {\n"
11840
" var NumSubViews = 0;\n"
11841
" var BarColumnEnabled = GetBarColumnEnabled();\n"
11842
" X7BarFirstView = -1;\n"
11843
" X7BarLastView = -1;\n"
11844
" var ViewMask = 0;\n"
11845
" for(var i = 0; i < BarColumnEnabled.length; ++i)\n"
11846
" {\n"
11847
" if(BarColumnEnabled[i])\n"
11848
" {\n"
11849
" if(X7BarFirstView == -1)\n"
11850
" X7BarFirstView = i;\n"
11851
" X7BarColumnRemap[NumSubViews++] = i;\n"
11852
" ViewMask = ViewMask | (1 << i);\n"
11853
" X7BarLastView = i;\n"
11854
" }\n"
11855
" }\n"
11856
" if(ViewMask != X7BarColumnMask)\n"
11857
" {\n"
11858
" console.log(\"resizing views\");\n"
11859
" var w = NumSubViews ? nWidth / NumSubViews : 1;\n"
11860
" for(var i = 0; i < X7Views.length; ++i)\n"
11861
" {\n"
11862
" X7Views[i].visible = i < NumSubViews;\n"
11863
" if(i < NumSubViews)\n"
11864
" {\n"
11865
" var HistoryH = Settings.ViewCompressed ? 0 : HistoryHeight;\n"
11866
" ResizeView(X7Views[i], w*i, HistoryH, w, nHeight - HistoryH);\n"
11867
" }\n"
11868
" }\n"
11869
" X7BarColumnMask = ViewMask;\n"
11870
" }\n"
11871
" X7LegendView.visible = true;\n"
11872
" ReferenceBarAutomatic = 0;\n"
11873
" }\n"
11874
"}\n"
11875
"function DrawViews()\n"
11876
"{\n"
11877
" Plotf(\"DrawViews\");\n"
11878
" UpdateX7Views();\n"
11879
" ProfileEnter(\"UpdateViews\");\n"
11880
" ViewIndex = 0;\n"
11881
" for(var i = 0; i < Views.length; ++i)\n"
11882
" {\n"
11883
" var View = Views[i];\n"
11884
" if(View.visible)\n"
11885
" {\n"
11886
" var LocalMouseX = MouseX - View.x;\n"
11887
" var LocalMouseY = MouseY - View.y;\n"
11888
" View.DisplayFunc(View, LocalMouseX, LocalMouseY, View.index);\n"
11889
" var Canvas = View.Canvas[View.BackBuffer];\n"
11890
" var Context = Canvas.getContext(\'2d\');\n"
11891
" ViewIndex++;\n"
11892
" }\n"
11893
" }\n"
11894
" ProfileLeave();\n"
11895
" var context = CanvasDetailedView.getContext(\'2d\');\n"
11896
" context.clearRect(0, 0, nWidth, nHeight);\n"
11897
" ProfileEnter(\"BlitViews\");\n"
11898
" for(var i = 0; i < Views.length; ++i)\n"
11899
" {\n"
11900
" var View = Views[i];\n"
11901
" if(View.visible)\n"
11902
" {\n"
11903
" context.drawImage(View.Canvas[View.BackBuffer], Math.floor(View.x), Math.floor(View.y), View.w, View.h);\n"
11904
" }\n"
11905
" }\n"
11906
"\n"
11907
" if(!Settings.ViewCompressed)\n"
11908
" {\n"
11909
" DrawCaptureMenu(context);\n"
11910
" DrawGraphSettingsMenu(context, MainView.x, MainView.y, MainView.w, MainView.h);\n"
11911
" }\n"
11912
"\n"
11913
" ProfileLeave();\n"
11914
"\n"
11915
"}\n"
11916
"const SubMenuGroup = 0;\n"
11917
"const SubMenuTimers = 1;\n"
11918
"const SubMenuCounters = 2;\n"
11919
"const SubMenuModules = 3;\n"
11920
"const SubMenuFunctions = 4;\n"
11921
"const SubMenuPatched = 5;\n"
11922
"const SubMenuSettings = 6;\n"
11923
"const SubMenuViews = 7;\n"
11924
"const SubMenuPresets = 8;\n"
11925
"const SubMenuColumns = 9;\n"
11926
"const SubMenuCapture = 10;\n"
11927
"const SubMenuGraphSettings = 11;\n"
11928
"let SubMenuGraphSettingsIndex = -1;\n"
11929
"let SubMenuGraphSettingsKey = \"\";\n"
11930
"\n"
11931
"let SubMenuActive = -1;\n"
11932
"let SubMenuTimeoutBase = 0.7;\n"
11933
"let SubMenuMouseX = 0;\n"
11934
"let SubMenuMouseY = 0;\n"
11935
"let SubMenuTimeout = new Date();\n"
11936
"let MenuItems = [];\n"
11937
"let FilterInputTimersValue = \'\';\n"
11938
"let FilterInputGroupsValue = \'\';\n"
11939
"let FilterInputCountersValue = \'\';\n"
11940
"let FilterInputModulesValue = \'\';\n"
11941
"let FilterInputFunctionsValue = \'\';\n"
11942
"let FilterInputPatchedValue = \'\';\n"
11943
"\n"
11944
"\n"
11945
"function MakeMenuItem(name, f, visible)\n"
11946
"{\n"
11947
" var Item = {};\n"
11948
" Item.name = name;\n"
11949
" Item.f = f;\n"
11950
" Item.w = name.length;\n"
11951
" Item.x = 0;\n"
11952
" Item.y = 0;\n"
11953
" Item.visible = visible;\n"
11954
" return Item;\n"
11955
"}\n"
11956
"function EnableMenu(m)\n"
11957
"{\n"
11958
" if(m != SubMenuActive)\n"
11959
" {\n"
11960
" if(SubMenuActive == SubMenuTimers)\n"
11961
" {\n"
11962
" FilterInputTimersValue = FilterInput.value;\n"
11963
" }\n"
11964
" else if(SubMenuActive == SubMenuGroup)\n"
11965
" {\n"
11966
" FilterInputGroupsValue = FilterInput.value;\n"
11967
" }\n"
11968
" else if(SubMenuActive == SubMenuCounters)\n"
11969
" {\n"
11970
" FilterInputCountersValue = FilterInput.value;\n"
11971
" }\n"
11972
" else if(SubMenuActive == SubMenuModules)\n"
11973
" {\n"
11974
" FilterInputModulesValue = FilterInput.value;\n"
11975
" }\n"
11976
" else if(SubMenuActive == SubMenuFunctions)\n"
11977
" {\n"
11978
" FilterInputFunctionsValue = FilterInput.value;\n"
11979
" }\n"
11980
" else if(SubMenuActive == SubMenuPatched)\n"
11981
" {\n"
11982
" FilterInputPatchedValue = FilterInput.value;\n"
11983
" }\n"
11984
"\n"
11985
" SubMenuActive = m;\n"
11986
" SubMenuTimeout = new Date();\n"
11987
"\n"
11988
" if(SubMenuActive == SubMenuTimers)\n"
11989
" {\n"
11990
" FilterInput.value = FilterInputTimersValue;\n"
11991
" }\n"
11992
" else if(SubMenuActive == SubMenuGroup)\n"
11993
" {\n"
11994
" FilterInput.value = FilterInputGroupsValue;\n"
11995
" }\n"
11996
" else if(SubMenuActive == SubMenuCounters)\n"
11997
" {\n"
11998
" FilterInput.value = FilterInputCountersValue;\n"
11999
" }\n"
12000
" else if(SubMenuActive == SubMenuModules)\n"
12001
" {\n"
12002
" FilterInput.value = FilterInputModulesValue;\n"
12003
" }\n"
12004
" else if(SubMenuActive == SubMenuFunctions)\n"
12005
" {\n"
12006
" FilterInput.value = FilterInputFunctionsValue;\n"
12007
" }\n"
12008
" else if(SubMenuActive == SubMenuPatched)\n"
12009
" {\n"
12010
" FilterInput.value = FilterInputPatchedValue;\n"
12011
" }\n"
12012
"\n"
12013
" FilterInputValueLast = FilterInput.value;\n"
12014
" }\n"
12015
" if(m == -1)\n"
12016
" {\n"
12017
" SubMenuTimeout = 0;\n"
12018
" }\n"
12019
"\n"
12020
" if(SubMenuActive == SubMenuTimers || SubMenuActive == SubMenuGroup || SubMenuActive == SubMenuCounters || SubMenuActive == SubMenuModules || SubMenuActive == SubMenuFunctions || SubMenuActive == SubMenuPatched)\n"
12021
" {\n"
12022
" FilterInputDiv.style[\'display\'] = \'inline\';\n"
12023
" FilterInput.focus();\n"
12024
" }\n"
12025
" else\n"
12026
" {\n"
12027
" FilterInputDiv.style[\'display\'] = \'none\';\n"
12028
" }\n"
12029
"}\n"
12030
"\n"
12031
"function Clamp(v, low, high)\n"
12032
"{\n"
12033
" return v < low ? low : (v > high ? high : v);\n"
12034
"}\n"
12035
"function TriggerCapture()\n"
12036
"{\n"
12037
" if(Settings.CaptureDelay <= 0)\n"
12038
" {\n"
12039
" Capture();\n"
12040
" }\n"
12041
" else\n"
12042
" {\n"
12043
" CaptureTriggerTime = new Date();\n"
12044
" CaptureTriggerTimeType = 1;\n"
12045
" }\n"
12046
"}\n"
12047
"function CaptureUpdate()\n"
12048
"{\n"
12049
" if(CaptureTriggerTime)\n"
12050
" {\n"
12051
" let Time = new Date();\n"
12052
" let Delta = Time - CaptureTriggerTime;\n"
12053
" CaptureTriggerDelta = Math.max(0.0, (Settings.CaptureDelay * 1000 - Delta) / 1000.0);\n"
12054
" if(Delta > Settings.CaptureDelay * 1000)\n"
12055
" {\n"
12056
" if(CaptureTriggerTimeType == 1)\n"
12057
" {\n"
12058
" Capture();\n"
12059
" }\n"
12060
" else if(CaptureTriggerTimeType == 2)\n"
12061
" {\n"
12062
" AutoCaptureEnabled = Settings.AutoCaptureRepeat > 0 ? Settings.AutoCaptureRepeat : 1;\n"
12063
" }\n"
12064
" CaptureTriggerTime = null;\n"
12065
" CaptureTriggerDelta = 0;\n"
12066
" CaptureTriggerTimeType = 0;\n"
12067
" }\n"
12068
" }\n"
12069
"\n"
12070
"}\n"
12071
"let OpenWindowIndex = 1;\n"
12072
"\n"
12073
"function OpenWindow(url)\n"
12074
"{\n"
12075
" if (window.matchMedia(\'(display-mode: browser)\').matches)\n"
12076
" {\n"
12077
" return window.open(url);\n"
12078
" }\n"
12079
" else\n"
12080
" {\n"
12081
"\n"
12082
" const width = window.outerWidth;\n"
12083
" const height = window.outerHeight;\n"
12084
"\n"
12085
" let left = window.screenX + 20 * (OpenWindowIndex%16+1);\n"
12086
" let top = window.screenY + 20 * (OpenWindowIndex%16+1);\n"
12087
"\n"
12088
" const features = `width=${width},height=${height},left=${left},top=${top}`;\n"
12089
" const name = \"new-window-\"+OpenWindowIndex;\n"
12090
" OpenWindowIndex += 1;\n"
12091
" return window.open(url, name, features);\n"
12092
" }\n"
12093
"}\n"
12094
"function Capture()\n"
12095
"{\n"
12096
" AutoCaptureCooldown = Settings.CaptureFrames + 5;\n"
12097
" var ext = \'\' + Settings.CaptureFrames;\n"
12098
" if(MouseDragActiveXEnd > MouseDragActiveXStart)\n"
12099
" {\n"
12100
" var idx0 = Math.ceil(FRAME_COUNT * MouseDragActiveXStart / nWidth);\n"
12101
" var idx1 = Math.floor(FRAME_COUNT * MouseDragActiveXEnd / nWidth);\n"
12102
" idx0 = Clamp(idx0, 0, FRAME_COUNT-1);\n"
12103
" idx1 = Clamp(idx1, 0, FRAME_COUNT-1);\n"
12104
" var id0 = FrameData.Ids[idx0];\n"
12105
" var id1 = FrameData.Ids[idx1];\n"
12106
" ext = \'r/\'+id0+\'/\'+id1;\n"
12107
" }\n"
12108
" let url = \'/\' + ext;\n"
12109
" OpenWindow(url);\n"
12110
"}\n"
12111
"function InitMenu()\n"
12112
"{\n"
12113
" MenuItems = [];\n"
12114
" MenuItems.push(MakeMenuItem(\"Control\", function(){EnableMenu(SubMenuGroup); } ));\n"
12115
" MenuItems.push(MakeMenuItem(\"Timers\", function(){EnableMenu(SubMenuTimers); } ));\n"
12116
" MenuItems.push(MakeMenuItem(\"Counters\", function(){EnableMenu(SubMenuCounters); } ));\n"
12117
" MenuItems.push(MakeMenuItem(\"Modules\", function(){EnableMenu(SubMenuModules); } ));\n"
12118
" MenuItems.push(MakeMenuItem(\"Functions\", function(){EnableMenu(SubMenuFunctions); } ));\n"
12119
" MenuItems.push(MakeMenuItem(\"Patched\", function(){EnableMenu(SubMenuPatched); }, function(){ return FunctionsInstrumented.length > 0;} ));\n"
12120
" MenuItems.push(MakeMenuItem(\"Settings\", function(){ EnableMenu(SubMenuSettings); } ));\n"
12121
" MenuItems.push(MakeMenuItem(\"Views\", function(){ EnableMenu(SubMenuViews); } ));\n"
12122
" MenuItems.push(MakeMenuItem(\"Presets\", function(){ EnableMenu(SubMenuPresets); } ));\n"
12123
" MenuItems.push(MakeMenuItem(\"Columns\", function(){ EnableMenu(SubMenuColumns); } ));\n"
12124
"}\n"
12125
"function DrawTopMenu()\n"
12126
"{\n"
12127
" var context = CanvasDetailedView.getContext(\'2d\');\n"
12128
" var X = 2;\n"
12129
" var Y = 0;\n"
12130
" var MouseInY = MouseY < BoxHeight;\n"
12131
" for(var i = 0; i < MenuItems.length; ++i)\n"
12132
" {\n"
12133
" if(i == SubMenuColumns)\n"
12134
" {\n"
12135
" if(Settings.ViewActive == VIEW_GRAPH_SPLIT ||\n"
12136
" Settings.ViewActive == VIEW_GRAPH_THREAD_GROUP ||\n"
12137
" Settings.ViewActive == VIEW_GRAPH_PERCENTILE ||\n"
12138
" Settings.ViewActive == VIEW_COUNTERS)\n"
12139
" {\n"
12140
" continue;\n"
12141
" }\n"
12142
" }\n"
12143
" var Item = MenuItems[i];\n"
12144
" if(Item.visible == null || Item.visible())\n"
12145
" {\n"
12146
" var w = context.measureText(Item.name).width + 4;\n"
12147
" var MouseIn = MouseInY && MouseX >= X && MouseX < X + w;\n"
12148
" var color = MouseIn ? nBackColors[1] : \"black\";\n"
12149
" Item.x = X;\n"
12150
" Item.y = Y + BoxHeight;\n"
12151
" if(MouseIn)\n"
12152
" {\n"
12153
" context.fillStyle = \'white\';\n"
12154
" context.fillRect(X-2, Y, w+4, BoxHeight);\n"
12155
" // Enable\n"
12156
" EnableMenu(i);\n"
12157
" }\n"
12158
" context.fillStyle = color;\n"
12159
" context.fillRect(X, Y, w, BoxHeight);\n"
12160
" context.fillStyle = \"white\";\n"
12161
" context.fillText(Item.name, X+2, Y+BoxHeight-FontAscent);\n"
12162
" if(MouseIn && MouseReleased)\n"
12163
" {\n"
12164
" Item.f();\n"
12165
" }\n"
12166
" X += w + 6;\n"
12167
" }\n"
12168
" }\n"
12169
"}\n"
12170
"\n"
12171
"function AggregateMenuSize()\n"
12172
"{\n"
12173
" var w = 250 + 5 + FontWidth;\n"
12174
" return WindowRect(nWidth / 2 - w / 2,HistoryHeight + 50, w, nHeight);\n"
12175
"}\n"
12176
"function TimerMenuSize()\n"
12177
"{\n"
12178
" return MenuSize(Math.max(WidthArray[TYPE_TIMER] + WidthArray[TYPE_GROUP], WidthArray[TYPE_COUNTER]) + 5 + FontWidth);\n"
12179
"}\n"
12180
"\n"
12181
"function GroupMenuSize()\n"
12182
"{\n"
12183
" return MenuSize(WidthTree);\n"
12184
"}\n"
12185
"function CounterMenuSize()\n"
12186
"{\n"
12187
" return MenuSize(CounterNameMenuWidth);\n"
12188
"}\n"
12189
"\n"
12190
"function MenuSize(w)\n"
12191
"{\n"
12192
" return WindowRect(nWidth / 2 - w / 2, HistoryHeight + 50,w, nHeight);\n"
12193
"}\n"
12194
"\n"
12195
"function CreateFilter(Filter)\n"
12196
"{\n"
12197
" if(!Filter || Filter.length == 0)\n"
12198
" {\n"
12199
" return null;\n"
12200
" }\n"
12201
" Filter = Filter.split(\' \');\n"
12202
"\n"
12203
" var regexp = \"\";\n"
12204
" for(var i = 0; i < Filter.length; ++i)\n"
12205
" {\n"
12206
" regexp = regexp + \".*\" + Filter[i];\n"
12207
" }\n"
12208
" Filter = new Array();\n"
12209
" regexp = regexp + \".*\";\n"
12210
" Filter.push(new RegExp(regexp, \"i\"));\n"
12211
" return Filter;\n"
12212
"}\n"
12213
"\n"
12214
"function FilterMatch(FilterArray, value)\n"
12215
"{\n"
12216
" if(!FilterArray)\n"
12217
" return true;\n"
12218
" for(var i = 0; i < FilterArray.length; ++i)\n"
12219
" {\n"
12220
" var res = value.search(FilterArray[i]);\n"
12221
" if(res<0)\n"
12222
" return false;\n"
12223
" }\n"
12224
" return true;\n"
12225
"}\n"
12226
"\n"
12227
"function AddPreset(Name)\n"
12228
"{\n"
12229
" var O = {};\n"
12230
" O[Name] = {};\n"
12231
" var OO = {};\n"
12232
" OO.p = O;\n"
12233
" OO.r = {};\n"
12234
" AddPresets(OO);\n"
12235
"}\n"
12236
"function JSONTryParse(str)\n"
12237
"{\n"
12238
" if(typeof str == \'string\')\n"
12239
" {\n"
12240
" try{\n"
12241
" return JSON.parse(str);\n"
12242
" }\n"
12243
" catch(e){}\n"
12244
" }\n"
12245
" return {};\n"
12246
"}\n"
12247
"\n"
12248
"function ProcessPresets(Data, Names, Cache)\n"
12249
"{\n"
12250
" for(var idx in Data)\n"
12251
" {\n"
12252
" if(Names.indexOf(idx) == -1)\n"
12253
" {\n"
12254
" Names.push(idx);\n"
12255
" }\n"
12256
" Cache[idx] = JSONTryParse(Data[idx]);\n"
12257
" Cache[idx].PresetName = idx;\n"
12258
" }\n"
12259
"}\n"
12260
"function AddPresets(Obj)\n"
12261
"{\n"
12262
" var Names = Obj.p;\n"
12263
" var ReadOnlyNames = Obj.r;\n"
12264
" ProcessPresets(Obj.p, Presets, PresetsCache);\n"
12265
" ProcessPresets(Obj.r, ReadOnlyPresets, ReadOnlyPresetsCache);\n"
12266
"}\n"
12267
"function GetFullName(T)\n"
12268
"{\n"
12269
" if(T.idtype == TYPE_COUNTER)\n"
12270
" {\n"
12271
" return T.countername;\n"
12272
" }\n"
12273
" else\n"
12274
" {\n"
12275
" let parent = T.parent;\n"
12276
" let ParentName = \"unknown\";\n"
12277
" let Name = T.name;\n"
12278
" if(parent && parent >= 0 && parent < TimerArray.length)\n"
12279
" {\n"
12280
" ParentName = TimerArray[parent].name;\n"
12281
" }\n"
12282
" return ParentName + \"/\" + Name;\n"
12283
" }\n"
12284
"}\n"
12285
"\n"
12286
"function ColorFromFullName(name, type)\n"
12287
"{\n"
12288
" for(var i = 0; i < TimerArray.length; ++i)\n"
12289
" {\n"
12290
" var t = TimerArray[i];\n"
12291
" if(t.idtype == type && GetFullName(t) == name)\n"
12292
" {\n"
12293
" return t.color;\n"
12294
" }\n"
12295
" }\n"
12296
" return \'white\';\n"
12297
"\n"
12298
"}\n"
12299
"function EnableByName(name, type)\n"
12300
"{\n"
12301
" for(var i = 0; i < TimerArray.length; ++i)\n"
12302
" {\n"
12303
" var t = TimerArray[i];\n"
12304
" if(t.idtype == type && GetFullName(t) == name)\n"
12305
" {\n"
12306
" WSSendMessage(\"c\" + t.id);\n"
12307
" }\n"
12308
" }\n"
12309
"}\n"
12310
"\n"
12311
"\n"
12312
"function OnLoadPreset(NewSettings, Apply, RO, Name)\n"
12313
"{\n"
12314
" if(Apply)\n"
12315
" {\n"
12316
" WSSendMessage(\"d\");\n"
12317
" PresetPending = 0;\n"
12318
" }\n"
12319
" ActivePreset = Name ? Name : NewSettings.PresetName;\n"
12320
" ActivePresetRO = RO ? 1 : 0;\n"
12321
" console.log(\'loading preset \' + ActivePresetRO);\n"
12322
" var EnableCount = 0;\n"
12323
" for(var idx in NewSettings)\n"
12324
" {\n"
12325
" if(idx == \'Timers\')\n"
12326
" {\n"
12327
" if(Apply)\n"
12328
" {\n"
12329
" var Timers = NewSettings[idx];\n"
12330
" for(var i = 0; i < Timers.length; ++i)\n"
12331
" {\n"
12332
" var FullName = Timers[i];\n"
12333
" EnableCount++;\n"
12334
" EnableByName(FullName, TYPE_TIMER);\n"
12335
" }\n"
12336
" }\n"
12337
" }\n"
12338
" else if(idx == \'Groups\')\n"
12339
" {\n"
12340
" if(Apply)\n"
12341
" {\n"
12342
" var Groups = NewSettings[idx];\n"
12343
" for(var i = 0; i < Groups.length; ++i)\n"
12344
" {\n"
12345
" var FullName = Groups[i];\n"
12346
" EnableByName(FullName, TYPE_GROUP);\n"
12347
" }\n"
12348
" }\n"
12349
" }\n"
12350
" else if(idx == \'Counters\')\n"
12351
" {\n"
12352
" if(Apply)\n"
12353
" {\n"
12354
" var Counters = NewSettings[idx];\n"
12355
" for(var i = 0; i < Counters.length; ++i)\n"
12356
" {\n"
12357
" var FullName = Counters[i];\n"
12358
" EnableByName(FullName, TYPE_COUNTER);\n"
12359
" }\n"
12360
" }\n"
12361
" }\n"
12362
" else\n"
12363
" {\n"
12364
" Settings[idx] = NewSettings[idx];\n"
12365
" }\n"
12366
" }\n"
12367
"\n"
12368
" if(Settings.FunctionsInstrumented && Apply)\n"
12369
" {\n"
12370
" if(Settings.FunctionsInstrumented.length == Settings.FunctionsInstrumentedModule.length && Settings.FunctionsInstrumented.length == Settings.FunctionsInstrumentedUnmangled.length)\n"
12371
" {\n"
12372
" var Msg = \"D\" + Settings.FunctionsInstrumented.length + \" \";\n"
12373
" for(var i = 0; i < Settings.FunctionsInstrumented.length; ++i)\n"
12374
" {\n"
12375
" Msg += Settings.FunctionsInstrumentedModule[i] + \"!\" + Settings.FunctionsInstrumentedUnmangled[i] + \"!\";\n"
12376
" }\n"
12377
" WSSendMessage(Msg);\n"
12378
" }\n"
12379
" }\n"
12380
" if(Settings.ViewActive >= 0)\n"
12381
" {\n"
12382
" ResizeCanvas();\n"
12383
" }\n"
12384
"}\n"
12385
"function SanitizeString(s)\n"
12386
"{\n"
12387
" let r = \"\";\n"
12388
" for(let i = 0; i < s.length; ++i)\n"
12389
" {\n"
12390
" let c = s[i];\n"
12391
" if(!((c>=\'a\' && c<=\'z\') || (c >=\'A\' && c <= \'Z\') || (c >= \'0\' && c <= \'9\')))\n"
12392
" {\n"
12393
" r += \'_\';\n"
12394
" }\n"
12395
" else\n"
12396
" {\n"
12397
" r += c;\n"
12398
" }\n"
12399
" }\n"
12400
" return r;\n"
12401
"}\n"
12402
"function LoadPreset(Name, RO)\n"
12403
"{\n"
12404
" Name = SanitizeString(Name);\n"
12405
" WSSendMessage((RO?\"m\":\"l\")+Name);\n"
12406
"}\n"
12407
"\n"
12408
"function SavePreset(Name)\n"
12409
"{\n"
12410
" Name = SanitizeString(Name);\n"
12411
" AddPreset(Name);\n"
12412
" let Timers = [];\n"
12413
" let Groups = [];\n"
12414
" let Counters = [];\n"
12415
" for(var i = 0; i < TimerArray.length; ++i)\n"
12416
" {\n"
12417
" let t = TimerArray[i];\n"
12418
" let idtype = TimerArray[i].idtype;\n"
12419
" if(t.e)\n"
12420
" {\n"
12421
" if(idtype == TYPE_TIMER)\n"
12422
" {\n"
12423
" Timers.push(GetFullName(t));\n"
12424
" }\n"
12425
" else if(idtype == TYPE_GROUP)\n"
12426
" {\n"
12427
" Groups.push(GetFullName(t));\n"
12428
" }\n"
12429
" else if(idtype == TYPE_COUNTER)\n"
12430
" {\n"
12431
" Counters.push(t.countername);\n"
12432
" }\n"
12433
" }\n"
12434
" }\n"
12435
"\n"
12436
" Settings.Timers = Timers;\n"
12437
" Settings.Groups = Groups;\n"
12438
" Settings.Counters = Counters;\n"
12439
" Settings.PresetName = Name;\n"
12440
" let Clone = function(A)\n"
12441
" {\n"
12442
" let N = Array(A.length);\n"
12443
" for(var i = 0; i < A.length; ++i)\n"
12444
" {\n"
12445
" N[i] = A[i];\n"
12446
" }\n"
12447
" return N;\n"
12448
" };\n"
12449
" Settings.FunctionsInstrumented = Clone(FunctionsInstrumented);\n"
12450
" Settings.FunctionsInstrumentedModule = Clone(FunctionsInstrumentedModule);\n"
12451
" Settings.FunctionsInstrumentedUnmangled = Clone(FunctionsInstrumentedUnmangled);\n"
12452
"\n"
12453
" var JsonSettings = JSON.stringify(Settings);\n"
12454
" console.log(\'settings stored \' + JsonSettings);\n"
12455
" WSSendMessage(\"s\"+Name+\",\"+JsonSettings);\n"
12456
" ActivePreset = Name;\n"
12457
" ActivePresetRO = 0;\n"
12458
"}\n"
12459
"function DrawMenuPresets()\n"
12460
"{\n"
12461
" var Selection = null;\n"
12462
" var SizeInfo = {};\n"
12463
" SizeInfo.h = BoxHeight * (Presets.length * 2);\n"
12464
" if(ReadOnlyPresets.length)\n"
12465
" {\n"
12466
" SizeInfo.h += BoxHeight * (Presets.length + 1);\n"
12467
" }\n"
12468
" var x = MenuItems[SubMenuPresets].x;\n"
12469
" var y = MenuItems[SubMenuPresets].y;\n"
12470
"\n"
12471
" var Width = 50;\n"
12472
" var WLeft = MeasureArray(0, [\"Save \", \"Load \", \"Save As ..\", \"Builtin\" ]);\n"
12473
" Width = MeasureArray(Width, Presets);\n"
12474
" var Width = 35 + Width + WLeft;\n"
12475
" SizeInfo.w = Width;\n"
12476
" SizeInfo.x = x;\n"
12477
" SizeInfo.y = y;\n"
12478
"\n"
12479
" var M = CreateMenuState(SizeInfo);\n"
12480
" var context = CanvasDetailedView.getContext(\'2d\');\n"
12481
"\n"
12482
" var SettingsCached;\n"
12483
" var SettingsCachedY = 0;\n"
12484
"\n"
12485
" for(var i = 0; i < Presets.length; ++i)\n"
12486
" {\n"
12487
" var Active = (ActivePresetRO == 0 && ActivePreset == Presets[i]) ? 1 : 0;\n"
12488
" if(DrawMenuElementMouseIn(M))\n"
12489
" {\n"
12490
" SettingsCachedY = M.y;\n"
12491
" SettingsCached = PresetsCache[Presets[i]];\n"
12492
" }\n"
12493
"\n"
12494
" if(DrawMenuElement(M, Active, \"Load\", Presets[i], \'white\', 0))\n"
12495
" {\n"
12496
" LoadPreset(Presets[i]);\n"
12497
" }\n"
12498
" }\n"
12499
" DrawMenuElement(M, 0, \"---\", \"\", \'white\', 0);\n"
12500
" if(DrawMenuElement(M, 0, \"Save As..\", \"\", \'white\', 0))\n"
12501
" {\n"
12502
" var str = ShowPrompt(\'Enter Preset Name\', \'\');\n"
12503
" if(str.length>1)\n"
12504
" {\n"
12505
" SavePreset(str);\n"
12506
" }\n"
12507
"\n"
12508
" }\n"
12509
"\n"
12510
" for(var i = 0; i < Presets.length; ++i)\n"
12511
" {\n"
12512
" var Active = (ActivePresetRO == 0 && ActivePreset == Presets[i]) ? 1 : 0;\n"
12513
" if(DrawMenuElement(M, Active, \"Save\", Presets[i], \'white\', 0))\n"
12514
" {\n"
12515
" SavePreset(Presets[i]);\n"
12516
" }\n"
12517
" }\n"
12518
" if(ReadOnlyPresets && ReadOnlyPresets.length > 0)\n"
12519
" {\n"
12520
" DrawMenuElement(M, 0, \"---\", \"\", \'white\', 0);\n"
12521
" for(var i = 0; i < ReadOnlyPresets.length; ++i)\n"
12522
" {\n"
12523
" var Active = (ActivePresetRO && ActivePreset == ReadOnlyPresets[i]) ? 1 : 0;\n"
12524
" if(DrawMenuElementMouseIn(M))\n"
12525
" {\n"
12526
" SettingsCachedY = M.y;\n"
12527
" SettingsCached = ReadOnlyPresetsCache[ReadOnlyPresets[i]];\n"
12528
" }\n"
12529
" if(DrawMenuElement(M, Active, \"Builtin\", ReadOnlyPresets[i], \'white\', 0))\n"
12530
" {\n"
12531
" LoadPreset(ReadOnlyPresets[i], 1);\n"
12532
" }\n"
12533
" }\n"
12534
" }\n"
12535
" SizeInfo.h = M.y - SizeInfo.y;\n"
12536
"\n"
12537
"\n"
12538
" if(SettingsCached)\n"
12539
" {\n"
12540
" let SizeLeft = 10 * FontWidth;\n"
12541
" let Timers = SettingsCached.Timers;\n"
12542
" let Groups = SettingsCached.Groups;\n"
12543
" let Counters = SettingsCached.Counters;\n"
12544
" let Patched = SettingsCached.Patched;\n"
12545
" let W = 0;\n"
12546
" let H = 0;\n"
12547
" if(Timers)\n"
12548
" {\n"
12549
" W = MeasureArray(W, Timers);\n"
12550
" H = 1 + Timers.length;\n"
12551
" }\n"
12552
" if(Groups)\n"
12553
" {\n"
12554
" W = MeasureArray(W, Groups);\n"
12555
" H = 1 + Groups.length;\n"
12556
" }\n"
12557
" if(Counters)\n"
12558
" {\n"
12559
" W = MeasureArray(W, Counters);\n"
12560
" H = 1 + Counters.length;\n"
12561
" }\n"
12562
" if(Patched)\n"
12563
" {\n"
12564
" W = MeasureArray(W, Patched);\n"
12565
" H = 1 + Patched.length;\n"
12566
" }\n"
12567
" W += 40;\n"
12568
" H = H * (FontHeight+1);\n"
12569
" let M = CreateMenuState(SizeInfo);\n"
12570
" M.x += M.w + 5;\n"
12571
" M.y = SettingsCachedY;\n"
12572
" M.w = W;\n"
12573
" M.h = H;\n"
12574
"\n"
12575
" if(Groups && Groups.length)\n"
12576
" {\n"
12577
" DrawMenuElement(M, 0, \"Groups\", \"\", \'white\', 0);\n"
12578
" for(let i = 0; i < Groups.length; ++i)\n"
12579
" {\n"
12580
" DrawMenuElement(M, 0, \"\", Groups[i], \'white\', 0);\n"
12581
" }\n"
12582
" }\n"
12583
" if(Timers && Timers.length)\n"
12584
" {\n"
12585
" DrawMenuElement(M, 0, \"Timers\", \"\", \'white\', 0);\n"
12586
" for(let i = 0; i < Timers.length; ++i)\n"
12587
" {\n"
12588
" DrawMenuElement(M, 0, \"\", Timers[i], ColorFromFullName(Timers[i], TYPE_TIMER), 0);\n"
12589
" }\n"
12590
" }\n"
12591
" if(Counters && Counters.length)\n"
12592
" {\n"
12593
" DrawMenuElement(M, 0, \"Counters\", \"\", \'white\', 0);\n"
12594
" for(let i = 0; i < Counters.length; ++i)\n"
12595
" {\n"
12596
" DrawMenuElement(M, 0, \"\", Counters[i], ColorFromFullName(Counters[i], TYPE_COUNTER), 0);\n"
12597
" }\n"
12598
" }\n"
12599
"\n"
12600
"\n"
12601
" if(Patched && Patched.length)\n"
12602
" {\n"
12603
" DrawMenuElement(M, 0, \"Patched\", \"\", \'white\', 0);\n"
12604
" for(let i = 0; i < Patched.length; ++i)\n"
12605
" {\n"
12606
" DrawMenuElement(M, 0, \"\", Patched[i], \'white\', 0);\n"
12607
" }\n"
12608
" }\n"
12609
"\n"
12610
"\n"
12611
" }\n"
12612
"\n"
12613
" return SizeInfo;\n"
12614
"}\n"
12615
"\n"
12616
"function DrawMenuColumns()\n"
12617
"{\n"
12618
" var Selection = null;\n"
12619
" var SizeInfo = {};\n"
12620
" var BarColumnNames = GetBarColumnNames();\n"
12621
" var BarColumnEnabled = GetBarColumnEnabled();\n"
12622
" SizeInfo.h = BoxHeight * (BarColumnNames.length);\n"
12623
" var x = MenuItems[SubMenuColumns].x;\n"
12624
" var y = MenuItems[SubMenuColumns].y;\n"
12625
"\n"
12626
" var Width = MeasureArray(0, BarColumnNames);\n"
12627
" SizeInfo.w = Width;\n"
12628
" SizeInfo.x = x;\n"
12629
" SizeInfo.y = y;\n"
12630
"\n"
12631
" var M = CreateMenuState(SizeInfo);\n"
12632
" var context = CanvasDetailedView.getContext(\'2d\');\n"
12633
" context.fillRect(M.x, M.y, Width, SizeInfo.h);\n"
12634
"\n"
12635
"\n"
12636
" for(var i = 0; i < BarColumnNames.length; ++i)\n"
12637
" {\n"
12638
" var Active = ActivePreset == Presets[i] ? 1 : 0;\n"
12639
" if(DrawMenuElement(M, BarColumnEnabled[i], BarColumnNames[i], \"\", \'white\', 0))\n"
12640
" {\n"
12641
" BarColumnEnabled[i] = !BarColumnEnabled[i];\n"
12642
" for(var j = 0; j < ColumnsWidth.length; ++j)\n"
12643
" {\n"
12644
" ColumnsWidth[i] = 20;\n"
12645
" }\n"
12646
" }\n"
12647
" }\n"
12648
"\n"
12649
" SizeInfo.h = M.y - SizeInfo.y;\n"
12650
" return SizeInfo;\n"
12651
"\n"
12652
"}\n"
12653
"\n"
12654
"\n"
12655
"function ToggleView()\n"
12656
"{\n"
12657
" Settings.ViewActive = (Settings.ViewActive+1) % VIEW_SIZE;\n"
12658
" ActivateView(Settings.ViewActive);\n"
12659
"}\n"
12660
"\n"
12661
"function ActivateView(idx)\n"
12662
"{\n"
12663
" for(var i = 1; i < Views.length; ++i)\n"
12664
" {\n"
12665
" Views[i].visible = false;\n"
12666
" }\n"
12667
" if(idx == VIEW_GRAPH_SPLIT)\n"
12668
" {\n"
12669
" MainView.DisplayFunc = DrawGraphSplit;\n"
12670
" MainView.visible = true;\n"
12671
" }\n"
12672
" else if(idx == VIEW_GRAPH_PERCENTILE)\n"
12673
" {\n"
12674
" MainView.DisplayFunc = DrawGraphPercentile;\n"
12675
" MainView.visible = true;\n"
12676
" }\n"
12677
" else if(idx == VIEW_GRAPH_THREAD_GROUP)\n"
12678
" {\n"
12679
" MainView.DisplayFunc = DrawGraphThreadGroup;\n"
12680
" MainView.visible = true;\n"
12681
" }\n"
12682
" else if(idx == VIEW_BAR)\n"
12683
" {\n"
12684
" MainView.DisplayFunc = DrawTableView;\n"
12685
" MainView.visible = true;\n"
12686
" }\n"
12687
" else if(idx == VIEW_COUNTERS)\n"
12688
" {\n"
12689
" MainView.DisplayFunc = DrawCounterView;\n"
12690
" MainView.visible = true;\n"
12691
" }\n"
12692
" else if(idx == VIEW_BAR_SINGLE || idx == VIEW_BAR_ALL)\n"
12693
" {\n"
12694
" for(var i = 0; i < X7Views.length; ++i)\n"
12695
" {\n"
12696
" X7Views[i].visible = true;\n"
12697
" }\n"
12698
" SingleTimerBars = idx == VIEW_BAR_SINGLE;\n"
12699
" }\n"
12700
" Settings.ViewActive = idx;\n"
12701
" X7BarColumnMask = -1;\n"
12702
" ViewBarMaxMsTextLength = 0;\n"
12703
"}\n"
12704
"function DrawMenuViews()\n"
12705
"{\n"
12706
" let ViewClick = function(idx, name)\n"
12707
" {\n"
12708
" ActivateView(idx);\n"
12709
" };\n"
12710
" let x = MenuItems[SubMenuViews].x;\n"
12711
" let y = MenuItems[SubMenuViews].y;\n"
12712
" return DrawMenuGeneric(ViewNames, Settings.ViewActive, ViewClick, x, y, ViewNames2);\n"
12713
"}\n"
12714
"\n"
12715
"function TweakValue(Value, Tweak, amount, Min, Max)\n"
12716
"{\n"
12717
" let V = 0.98;\n"
12718
" const FloatStepLimitBase10 = 1;\n"
12719
" if(Value <= Math.pow(10, FloatStepLimitBase10) + 0.001)\n"
12720
" {\n"
12721
" let StepBase10 = FloatStepLimitBase10;\n"
12722
" let ScaleToInt = 10;\n"
12723
" while(Value < Math.pow(10, StepBase10))\n"
12724
" {\n"
12725
" StepBase10 -= 1;\n"
12726
" ScaleToInt *= 10;\n"
12727
" }\n"
12728
" let Step = Math.pow(10, StepBase10) / 10.0;\n"
12729
" Value += Tweak * Step;\n"
12730
" Value = Math.floor(Value*ScaleToInt) / ScaleToInt;\n"
12731
" }\n"
12732
" else\n"
12733
" {\n"
12734
" if(Tweak<0)\n"
12735
" {\n"
12736
" for(var x = 0; x < Math.abs(Tweak); ++x)\n"
12737
" {\n"
12738
" var newValue = Math.floor(Value*V);\n"
12739
" if(newValue == Value)\n"
12740
" {\n"
12741
" Value--;\n"
12742
" }\n"
12743
" else\n"
12744
" {\n"
12745
" Value = newValue;\n"
12746
" }\n"
12747
" }\n"
12748
" }\n"
12749
" else\n"
12750
" {\n"
12751
" var RcpV = 1.0 / V;\n"
12752
"\n"
12753
" for(var x = 0; x < Tweak; ++x)\n"
12754
" {\n"
12755
" var newValue = Math.ceil(Value*RcpV);\n"
12756
" if(newValue == Value)\n"
12757
" {\n"
12758
" Value++;\n"
12759
" }\n"
12760
" else\n"
12761
" {\n"
12762
" Value = newValue;\n"
12763
" }\n"
12764
" }\n"
12765
" }\n"
12766
" }\n"
12767
" if(Min!=null && Value < Min)\n"
12768
" Value = Min;\n"
12769
" if(Max!=null && Value > Max)\n"
12770
" Value = Max;\n"
12771
" return Value;\n"
12772
"\n"
12773
"}\n"
12774
"\n"
12775
"function NextValue(Presets, Value, Dir)\n"
12776
"{\n"
12777
" var idx = 0;\n"
12778
" if(Dir > 0)\n"
12779
" {\n"
12780
" for(idx = 0;idx < Presets.length; ++idx)\n"
12781
" {\n"
12782
" if(Presets[idx] > Value)\n"
12783
" {\n"
12784
" break;\n"
12785
" }\n"
12786
" }\n"
12787
" }\n"
12788
" else\n"
12789
" {\n"
12790
" for(idx = Presets.length; idx >= 0; idx -= 1)\n"
12791
" {\n"
12792
" if(Presets[idx] < Value)\n"
12793
" {\n"
12794
" break;\n"
12795
" }\n"
12796
" }\n"
12797
" }\n"
12798
" idx = (idx + Presets.length) % Presets.length;\n"
12799
" return Presets[idx];\n"
12800
"}\n"
12801
"function AutoCaptureRoll(Direction, Tweak, SetDirect)\n"
12802
"{\n"
12803
" if(SetDirect)\n"
12804
" {\n"
12805
" Settings.AutoCaptureTheshold = SetDirect;\n"
12806
" }\n"
12807
" else if(Tweak)\n"
12808
" {\n"
12809
" Settings.AutoCaptureTheshold = TweakValue(Settings.AutoCaptureTheshold, Tweak, 0.98, 1, 500);\n"
12810
" }\n"
12811
" else if(Direction)\n"
12812
" {\n"
12813
" Settings.AutoCaptureTheshold = NextValue(AutoCaptureThesholdPresets, Settings.AutoCaptureTheshold, Direction);\n"
12814
" }\n"
12815
"}\n"
12816
"function AutoCaptureRepeatRoll(Direction, Tweak, SetDirect)\n"
12817
"{\n"
12818
" if(SetDirect)\n"
12819
" {\n"
12820
" Settings.AutoCaptureRepeat = SetDirect;\n"
12821
" }\n"
12822
" else if(Tweak)\n"
12823
" {\n"
12824
" Settings.AutoCaptureRepeat = TweakValue(Settings.AutoCaptureRepeat, Tweak, 0.98, 1, 500);\n"
12825
" }\n"
12826
" else if(Direction)\n"
12827
" {\n"
12828
" Settings.AutoCaptureRepeat = NextValue(AutoCaptureRepeatPresets, Settings.AutoCaptureRepeat, Direction);\n"
12829
" }\n"
12830
"}\n"
12831
"function CaptureRoll(Direction, Tweak, SetDirect)\n"
12832
"{\n"
12833
" if(SetDirect)\n"
12834
" {\n"
12835
" Settings.CaptureFrames = SetDirect;\n"
12836
" }\n"
12837
" else if(Tweak)\n"
12838
" {\n"
12839
" Settings.CaptureFrames = TweakValue(Settings.CaptureFrames, Tweak, 0.98, 5, 300);\n"
12840
"\n"
12841
" }\n"
12842
" else if(Direction)\n"
12843
" {\n"
12844
" Settings.CaptureFrames = NextValue(CaptureFramesPresets, Settings.CaptureFrames, Direction);\n"
12845
" }\n"
12846
"}\n"
12847
"function CaptureDelayRoll(Direction, Tweak, SetDirect)\n"
12848
"{\n"
12849
" if(SetDirect)\n"
12850
" {\n"
12851
" Settings.CaptureDelay = SetDirect;\n"
12852
" }\n"
12853
" else if(Tweak)\n"
12854
" {\n"
12855
" Settings.CaptureDelay = TweakValue(Settings.CaptureDelay, Tweak, 0.98, 5, 300);\n"
12856
"\n"
12857
" }\n"
12858
" else if(Direction)\n"
12859
" {\n"
12860
" Settings.CaptureDelay = NextValue(CaptureDelayPresets, Settings.CaptureDelay, Direction);\n"
12861
" }\n"
12862
"}\n"
12863
"\n"
12864
"function GetAutoCaptureString()\n"
12865
"{\n"
12866
" if(AutoCaptureSourceIndex >= 0)\n"
12867
" {\n"
12868
" if(AutoCaptureSourceIndex >= EnabledArray.length)\n"
12869
" {\n"
12870
" AutoCaptureSourceIndex = -1;\n"
12871
" AutoCaptureSourceIndex = -1;\n"
12872
" }\n"
12873
" else\n"
12874
" {\n"
12875
" var idx = EnabledArray[AutoCaptureSourceIndex];\n"
12876
" return TimerArray[idx].name;\n"
12877
" }\n"
12878
" }\n"
12879
" return \"Frame Time\";\n"
12880
"}\n"
12881
"\n"
12882
"function AutoCaptureSourceRoll(Direction, Tweak, SetDirect)\n"
12883
"{\n"
12884
" if(SetDirect)\n"
12885
" {\n"
12886
"\n"
12887
" }else if(Tweak||Direction)\n"
12888
" {\n"
12889
" if(!Direction)\n"
12890
" Direction = Tweak;\n"
12891
" if(Direction<0)\n"
12892
" {\n"
12893
" AutoCaptureSourceIndex--;\n"
12894
" if(AutoCaptureSourceIndex<-1)\n"
12895
" {\n"
12896
" AutoCaptureSourceIndex = EnabledArray.length-1;\n"
12897
" }\n"
12898
" }\n"
12899
" else\n"
12900
" {\n"
12901
" AutoCaptureSourceIndex++;\n"
12902
" if(AutoCaptureSourceIndex >= EnabledArray.length)\n"
12903
" {\n"
12904
" AutoCaptureSourceIndex = -1;\n"
12905
" }\n"
12906
" }\n"
12907
"\n"
12908
" }\n"
12909
"}\n"
12910
"function IsPromptActive()\n"
12911
"{\n"
12912
" let Delta = (new Date()) - PromptExitTime;\n"
12913
" let Result = PromptActive || Delta < 200;\n"
12914
" return Result;\n"
12915
"}\n"
12916
"function EnterPrompt()\n"
12917
"{\n"
12918
" PromptActive = 1;\n"
12919
"}\n"
12920
"function ExitPrompt()\n"
12921
"{\n"
12922
" PromptActive = 0;\n"
12923
" PromptExitTime = new Date();\n"
12924
"}\n"
12925
"\n"
12926
"function ShowPrompt(Title, Value, Type)\n"
12927
"{\n"
12928
" PromptActive = 1;\n"
12929
" EnterPrompt();\n"
12930
" let v;\n"
12931
" if(Type == \'int\')\n"
12932
" {\n"
12933
" let newValue = prompt(\'\' + Title, \'\' + Value);\n"
12934
" v = parseInt(newValue);\n"
12935
" }\n"
12936
" else if(Type == \'float\')\n"
12937
" {\n"
12938
" let newValue = prompt(\'\' + Title, \'\' + Value);\n"
12939
" v = parseFloat(newValue);\n"
12940
" }\n"
12941
" else\n"
12942
" {\n"
12943
" let v = prompt(\'\' + Title, \'\' + Value);\n"
12944
" ExitPrompt();\n"
12945
" return v;\n"
12946
" }\n"
12947
" ExitPrompt();\n"
12948
" if(isNaN(v))\n"
12949
" {\n"
12950
" return Value;\n"
12951
" }\n"
12952
" else\n"
12953
" {\n"
12954
" return v;\n"
12955
" }\n"
12956
"\n"
12957
"}\n"
12958
"function MeasureArray(v, A, f)\n"
12959
"{\n"
12960
" var context = CanvasDetailedView.getContext(\'2d\');\n"
12961
" for(var i = 0; i < A.length; ++i)\n"
12962
" {\n"
12963
" var s = A[i];\n"
12964
" if(f)\n"
12965
" s=f(s, i);\n"
12966
" var l = context.measureText(s).width;\n"
12967
" v = v < l ? l : v;\n"
12968
" }\n"
12969
" return v;\n"
12970
"}\n"
12971
"\n"
12972
"function CreateMenuState(SizeInfo)\n"
12973
"{\n"
12974
" var MenuState = {};\n"
12975
" for(var i in SizeInfo)\n"
12976
" {\n"
12977
" MenuState[i] = SizeInfo[i];\n"
12978
" }\n"
12979
" MenuState.cidx = 0;\n"
12980
" return MenuState;\n"
12981
"}\n"
12982
"function DrawMenuElementMouseIn(M)\n"
12983
"{\n"
12984
" return MouseY >= M.y && MouseY < M.y + BoxHeight;\n"
12985
"}\n"
12986
"function DrawMenuElement(M, Selected, Name, Value, color)\n"
12987
"{\n"
12988
" var context = CanvasDetailedView.getContext(\'2d\');\n"
12989
"\n"
12990
" var bMouseIn = DrawMenuElementMouseIn(M);\n"
12991
" var YText = M.y + BoxHeight - FontAscent;\n"
12992
"\n"
12993
" var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[M.cidx];\n"
12994
" context.fillStyle = Selected?\'white\':bgcolor;\n"
12995
" context.fillRect(M.x-2, M.y, M.w + 4, BoxHeight);\n"
12996
" context.fillStyle = bgcolor;\n"
12997
" context.fillRect(M.x, M.y, M.w, BoxHeight);\n"
12998
" context.fillStyle = color;\n"
12999
" context.fillText(Name, M.x, YText);\n"
13000
" context.textAlign = \'right\';\n"
13001
" context.fillText(\'\' + Value, M.x + M.w - 2, YText);\n"
13002
" context.textAlign = \'left\';\n"
13003
" M.cidx = 1-M.cidx;\n"
13004
" M.y += BoxHeight;\n"
13005
" return bMouseIn && MouseReleased;\n"
13006
"}\n"
13007
"function DrawMenuRoll(M, Name, RollValue, RollExt, RollFunction, Tweak, Type)\n"
13008
"{\n"
13009
" var context = CanvasDetailedView.getContext(\'2d\');\n"
13010
"\n"
13011
" var YText = M.y + BoxHeight - FontAscent;\n"
13012
" var SizeMinus = context.measureText(\'-\').width;\n"
13013
" var SizePlus = context.measureText(\'+\').width;\n"
13014
"\n"
13015
" var bMouseIn = MouseY >= M.y && MouseY < M.y + BoxHeight;\n"
13016
" var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[M.cidx];\n"
13017
" context.fillStyle = bgcolor;\n"
13018
" context.fillRect(M.x-2, M.y, M.w+4, BoxHeight);\n"
13019
" context.fillStyle = \'white\';\n"
13020
" context.fillText(Name, M.x, YText);\n"
13021
" context.textAlign = \'right\';\n"
13022
" var XTemp = M.x + ";
13023
13024
const size_t g_MicroProfileHtmlLive_begin_2_size = sizeof(g_MicroProfileHtmlLive_begin_2);
13025
const char g_MicroProfileHtmlLive_begin_3[] =
13026
"M.w - 3;\n"
13027
"\n"
13028
" if(KeyShiftDown && bMouseIn)\n"
13029
" {\n"
13030
" if(Tweak>=0)\n"
13031
" {\n"
13032
" RollFunction(0, MouseX-Tweak);\n"
13033
" }\n"
13034
" Tweak = MouseX;\n"
13035
" bMouseIn = false;\n"
13036
" }\n"
13037
" else\n"
13038
" {\n"
13039
" Tweak = -1;\n"
13040
" }\n"
13041
"\n"
13042
" var MouseReleasedUsed = false;\n"
13043
" if(bMouseIn && MouseX >= XTemp - SizePlus && MouseX <= XTemp)\n"
13044
" {\n"
13045
" context.fillStyle = \'red\';\n"
13046
" if(MouseReleased)\n"
13047
" {\n"
13048
" RollFunction(1);\n"
13049
" MouseReleasedUsed = true;\n"
13050
" }\n"
13051
" }\n"
13052
" else\n"
13053
" {\n"
13054
" context.fillStyle = \'white\';\n"
13055
" }\n"
13056
" context.fillText(\'+\', XTemp, YText);\n"
13057
" XTemp -= SizePlus + 3;\n"
13058
"\n"
13059
"\n"
13060
"\n"
13061
" if(bMouseIn && MouseX >= XTemp - SizeMinus && MouseX <= XTemp)\n"
13062
" {\n"
13063
" context.fillStyle = \'red\';\n"
13064
" if(MouseReleased)\n"
13065
" {\n"
13066
" RollFunction(-1);\n"
13067
" MouseReleasedUsed = true;\n"
13068
" }\n"
13069
" }\n"
13070
" else\n"
13071
" {\n"
13072
" context.fillStyle = \'white\';\n"
13073
" }\n"
13074
"\n"
13075
" context.fillText(\'-\', XTemp, YText);\n"
13076
" XTemp -= SizeMinus + 3;\n"
13077
" var RollText = \'\'+RollValue + RollExt;\n"
13078
" var RollWidth = context.measureText(RollText).width;\n"
13079
" context.fillStyle = \'white\';\n"
13080
"\n"
13081
" context.fillText(RollText, XTemp, YText);\n"
13082
" XTemp -= RollWidth;\n"
13083
"\n"
13084
" context.textAlign = \'left\';\n"
13085
"\n"
13086
" M.cidx = 1-M.cidx;\n"
13087
"\n"
13088
" M.y += BoxHeight;\n"
13089
" if(Type && MouseReleased && bMouseIn && !MouseReleasedUsed)\n"
13090
" {\n"
13091
" var V = ShowPrompt(Name, RollValue, Type);\n"
13092
" RollFunction(0,0,V);\n"
13093
" }\n"
13094
" return Tweak;\n"
13095
"\n"
13096
"}\n"
13097
"function CheckPopupAllowed()\n"
13098
"{\n"
13099
" if(!PopupsAllowed && !PopupTestPending)\n"
13100
" {\n"
13101
" PopupTestPending = 1;\n"
13102
" PopupsAllowed = 0;\n"
13103
" PopupsFailed = 0;\n"
13104
" let DoPopupTest = function()\n"
13105
" {\n"
13106
" var W = window.open(\"about:blank\");\n"
13107
" var Fail = function()\n"
13108
" {\n"
13109
" PopupTestPending = 0;\n"
13110
" PopupsFailed = 1;\n"
13111
" PopupsAllowed = 0;\n"
13112
" };\n"
13113
" var Check = function()\n"
13114
" {\n"
13115
" if(!(W.innerHeight>0))\n"
13116
" Fail();\n"
13117
" else\n"
13118
" {\n"
13119
" PopupTestPending = 0;\n"
13120
" PopupsFailed = 0;\n"
13121
" PopupsAllowed = 1;\n"
13122
" W.close();\n"
13123
" }\n"
13124
" };\n"
13125
" if(W)\n"
13126
" {\n"
13127
" if(/chrome/.test(navigator.userAgent.toLowerCase()))\n"
13128
" setTimeout(Check, 200);\n"
13129
" else\n"
13130
" W.onload = Check;\n"
13131
" }\n"
13132
" else\n"
13133
" {\n"
13134
" Fail();\n"
13135
" }\n"
13136
" };\n"
13137
" setTimeout(DoPopupTest, 5000);\n"
13138
" }\n"
13139
"}\n"
13140
"\n"
13141
"function GetSubGraphReferenceTime(T, SubGraphSettings, TimerState)\n"
13142
"{\n"
13143
" if(SubGraphSettings.AutomaticReference)\n"
13144
" {\n"
13145
" return TimerState.historymaxsoft ? TimerState.historymax : TimerState.historymax;\n"
13146
" }\n"
13147
" else\n"
13148
" {\n"
13149
" if(T.idtype == TYPE_COUNTER && T.format == FormatCounterBytes)\n"
13150
" {\n"
13151
" return (1 << (10*SubGraphSettings.Bytes)) * SubGraphSettings.ReferenceTime;\n"
13152
" }\n"
13153
" else\n"
13154
" {\n"
13155
" return SubGraphSettings.ReferenceTime;\n"
13156
" }\n"
13157
" }\n"
13158
"}\n"
13159
"\n"
13160
"function GetSubGraphSettings(key)\n"
13161
"{\n"
13162
" let Source = Settings.ViewActive == VIEW_GRAPH_PERCENTILE ? Settings.SubGraphSettingsPercentile : Settings.SubGraphSettings;\n"
13163
" let SubGraphSettings = Source[key];\n"
13164
" if(!SubGraphSettings)\n"
13165
" {\n"
13166
" SubGraphSettings = {\"ReferenceTime\":10.0, \"TargetTime\":-1, \"AutomaticReference\":1, \"Percentile\":0.0, \"Bytes\":0};\n"
13167
" Source[key] = SubGraphSettings;\n"
13168
" }\n"
13169
" if(!SubGraphSettings.Bytes)\n"
13170
" SubGraphSettings.Bytes = 0;\n"
13171
" return SubGraphSettings;\n"
13172
"}\n"
13173
"\n"
13174
"\n"
13175
"function DrawMenuGraphSettings()\n"
13176
"{\n"
13177
" let Percentile = Settings.ViewActive == VIEW_GRAPH_PERCENTILE;\n"
13178
" let Selection = null;\n"
13179
" let SizeInfo = {};\n"
13180
" SizeInfo.h = (Percentile?3:2) * BoxHeight;\n"
13181
" let Strings = [\"AutoCapture Enabled\", \"AutoCapture Threshold\", \"AutoCapture Source\", \"Capture Length\"];\n"
13182
" let wLeft = MeasureArray(0, Strings);\n"
13183
" let wRight = 50;\n"
13184
" wRight = MeasureArray(wRight, [\"Frame Time\"]);\n"
13185
" let Width = wLeft + 35 + wRight;\n"
13186
" SizeInfo.w = Width;\n"
13187
" SizeInfo.x = Math.floor(CaptureButtonX);\n"
13188
" SizeInfo.y = Math.floor(CaptureButtonY);\n"
13189
"\n"
13190
" let M = CreateMenuState(SizeInfo);\n"
13191
" let context = CanvasDetailedView.getContext(\'2d\');\n"
13192
" context.fillRect(M.x, M.y, Width, SizeInfo.h);\n"
13193
" let SubGraphSettings = GetSubGraphSettings(SubMenuGraphSettingsKey);\n"
13194
" let idx = GetTimerFromFullName(SubMenuGraphSettingsKey);\n"
13195
" let T = TimerArray[idx];\n"
13196
" const IsByteCounter = T.idtype == TYPE_COUNTER && T.format == FormatCounterBytes;\n"
13197
" \n"
13198
" let RefTime = SubGraphSettings.ReferenceTime;\n"
13199
" ReferenceTimeTweak = DrawMenuRoll(M, \"Reference Value\", SubGraphSettings.ReferenceTime, \'\', ReferenceRollSubGraph, ReferenceTimeTweak, \'float\');\n"
13200
" if(RefTime != SubGraphSettings.ReferenceTime)\n"
13201
" SubGraphSettings.AutomaticReference = 0;\n"
13202
"\n"
13203
" if(IsByteCounter)\n"
13204
" {\n"
13205
" DrawMenuRoll(M, \"\", CounterByteNames[SubGraphSettings.Bytes], \'\', ReferenceRollBytes, -1);\n"
13206
" }\n"
13207
" if(DrawMenuElement(M, SubGraphSettings.AutomaticReference, \"Automatic Reference Value\", SubGraphSettings.AutomaticReference, \'white\'))\n"
13208
" {\n"
13209
" SubGraphSettings.AutomaticReference = 1-SubGraphSettings.AutomaticReference;\n"
13210
" }\n"
13211
" function ClearPercentile(SettingsKey)\n"
13212
" {\n"
13213
" let idx = GetTimerFromFullName(SettingsKey);\n"
13214
" let T = TimerArray[idx];\n"
13215
" let TimerMap = FrameData.TimerMap;\n"
13216
" if(TimerMap)\n"
13217
" {\n"
13218
" let TimerState = TimerMap[T.id];\n"
13219
" TimerState.PercentileMax = -1e38;\n"
13220
" TimerState.PercentileMin = 1e38;\n"
13221
" TimerState.Percentile = new Float32Array(PERCENTILE_SAMPLES);\n"
13222
" TimerState.Percentile.fill(0.0);\n"
13223
" TimerState.PercentileCount = 0;\n"
13224
" }\n"
13225
" }\n"
13226
" if(Percentile)\n"
13227
" {\n"
13228
" if(DrawMenuElement(M, 0, \"Clear Percentile\", \"\", \'white\'))\n"
13229
" {\n"
13230
" ClearPercentile(SubMenuGraphSettingsKey);\n"
13231
" }\n"
13232
" }\n"
13233
"\n"
13234
" DrawMenuElement(M, 0, \"---------- \", \"\", \'white\');\n"
13235
" let Apply = function(Callback){\n"
13236
" let AllSettings = Percentile ? Settings.SubGraphSettingsPercentile : Settings.SubGraphSettings;\n"
13237
" for(let key in AllSettings)\n"
13238
" {\n"
13239
" let idx = GetTimerFromFullName(key);\n"
13240
" if(idx)\n"
13241
" {\n"
13242
" let T0 = TimerArray[idx];\n"
13243
" if(T0.idtype == T.idtype && T.format == T0.format)\n"
13244
" {\n"
13245
" Callback(AllSettings[key], key);\n"
13246
" }\n"
13247
" }\n"
13248
" } \n"
13249
" }\n"
13250
" {\n"
13251
" let str = T.idtype == TYPE_TIMER ? \"TIMERS\" : (T.format == FormatCounterBytes ? \"BYTE COUNTERS\" : \"COUNTERS\");\n"
13252
" if(DrawMenuElement(M, 0, \"Copy to All \" + str + \" Graphs \", \"\", \'white\'))\n"
13253
" {\n"
13254
" Apply(function(T){\n"
13255
" T.ReferenceTime = SubGraphSettings.ReferenceTime;\n"
13256
" });\n"
13257
" if(IsByteCounter)\n"
13258
" {\n"
13259
" Apply(function(T){\n"
13260
" T.Bytes = SubGraphSettings.Bytes;\n"
13261
" });\n"
13262
" }\n"
13263
" Apply(function(T){\n"
13264
" T.AutomaticReference = SubGraphSettings.AutomaticReference;\n"
13265
" }); \n"
13266
" }\n"
13267
" if(Percentile)\n"
13268
" {\n"
13269
" if(DrawMenuElement(M, 0, \"Clear All Percentile\", \"\", \'white\'))\n"
13270
" {\n"
13271
" ClearPercentile(SubMenuGraphSettingsKey);\n"
13272
" Apply(function(T, k){\n"
13273
" ClearPercentile(k);\n"
13274
" });\n"
13275
" }\n"
13276
" }\n"
13277
" }\n"
13278
" DrawMenuElement(M, 0, \"--- SHARED --- \", \"\", \'white\');\n"
13279
" DrawMenuRoll(M, \"Soft Mode\", GraphSoftFrameModeNames[Settings.GraphSoftMode], \'\', RollSoftFrameNames, -1);\n"
13280
" DrawMenuRoll(M, \"Soft Frames\", Settings.GraphSoftFrames, \'\', RollSoftFrames, -1);\n"
13281
"\n"
13282
"\n"
13283
" SizeInfo.h = M.y - SizeInfo.y;\n"
13284
" return SizeInfo;\n"
13285
"\n"
13286
"}\n"
13287
"\n"
13288
"function Dots()\n"
13289
"{\n"
13290
" let t = new Date().getMilliseconds() / 200;\n"
13291
" let dots = [\". \",\".. \",\"...\",\".. \"];\n"
13292
" let x = Math.floor(t) %4;\n"
13293
" return dots[x];\n"
13294
"}\n"
13295
"\n"
13296
"function DrawMenuCapture()\n"
13297
"{\n"
13298
" let Selection = null;\n"
13299
" let SizeInfo = {};\n"
13300
" SizeInfo.h = 7 * BoxHeight;\n"
13301
" let Strings = [\"Popups Allowed\", \"AutoCapture Enabled\", \"AutoCapture Threshold\", \"AutoCapture Source\", \"Capture Length\", \"Capture Delay\"];\n"
13302
" let wLeft = MeasureArray(0, Strings);\n"
13303
" let wRight = 50;\n"
13304
" wRight = MeasureArray(wRight, [\"Frame Time\"]);\n"
13305
" wRight = MeasureArray(wRight, EnabledArray, function(a){return TimerArray[a].name; } );\n"
13306
" let Width = wLeft + 35 + wRight;\n"
13307
" SizeInfo.w = Width;\n"
13308
" SizeInfo.x = CaptureButtonX - SizeInfo.w;\n"
13309
" SizeInfo.y = CaptureButtonY - SizeInfo.h;\n"
13310
"\n"
13311
" let M = CreateMenuState(SizeInfo);\n"
13312
" let context = CanvasDetailedView.getContext(\'2d\');\n"
13313
" context.fillRect(M.x, M.y, Width, SizeInfo.h);\n"
13314
" let d = Dots();\n"
13315
" let PopupStatus = PopupsAllowed ? \"Yes\" : (PopupsFailed ? \"No\" : (PopupTestPending ? (\"Testing\"+d) : \"Untested\"));\n"
13316
" if(DrawMenuElement(M, 0, \"Popups Allowed\", PopupStatus, \'white\', 0))\n"
13317
" {\n"
13318
" CheckPopupAllowed();\n"
13319
" }\n"
13320
" let AutoStatus = AutoCaptureEnabled > 0 ? \"on\" : \"off\";\n"
13321
" if(CaptureTriggerTime != null && CaptureTriggerTimeType == 2)\n"
13322
" {\n"
13323
" AutoStatus = \"pending\"+d;\n"
13324
" }\n"
13325
" if(DrawMenuElement(M, 0, \"AutoCapture Enabled\", AutoStatus, \'white\', 0))\n"
13326
" {\n"
13327
" if(!AutoCaptureEnabled && CaptureTriggerTime == null)\n"
13328
" {\n"
13329
" if(Settings.CaptureDelay <= 0)\n"
13330
" {\n"
13331
" AutoCaptureEnabled = Settings.AutoCaptureRepeat > 0 ? Settings.AutoCaptureRepeat : 1;\n"
13332
" }\n"
13333
" else\n"
13334
" {\n"
13335
" CaptureTriggerTime = new Date();\n"
13336
" CaptureTriggerTimeType = 2;\n"
13337
" }\n"
13338
" }\n"
13339
" else\n"
13340
" {\n"
13341
" AutoCaptureEnabled = 0;\n"
13342
" if(CaptureTriggerTimeType == 2)\n"
13343
" {\n"
13344
" CaptureTriggerTimeType = 0;\n"
13345
" CaptureTriggerTime = null;\n"
13346
" }\n"
13347
" }\n"
13348
" }\n"
13349
" AutoCaptureSourceTweak = DrawMenuRoll(M, \"AutoCapture Source\", GetAutoCaptureString(), \'\', AutoCaptureSourceRoll, AutoCaptureSourceTweak);\n"
13350
" AutoCaptureTweak = DrawMenuRoll(M, \"AutoCapture Threshold\", Settings.AutoCaptureTheshold, \'ms\', AutoCaptureRoll, AutoCaptureTweak, \'int\');\n"
13351
" AutoCaptureRepeatTweak = DrawMenuRoll(M, \"AutoCapture Repeat\", Settings.AutoCaptureRepeat, \'\', AutoCaptureRepeatRoll, AutoCaptureRepeatTweak, \'int\');\n"
13352
" CaptureTweak = DrawMenuRoll(M, \"Capture Length\", Settings.CaptureFrames, \'\', CaptureRoll, CaptureTweak, \'int\');\n"
13353
" CaptureDelayTweak = DrawMenuRoll(M, \"Capture Delay\", Settings.CaptureDelay, \'\', CaptureDelayRoll, CaptureDelayTweak, \'int\');\n"
13354
"\n"
13355
" SizeInfo.h = M.y - SizeInfo.y;\n"
13356
" return SizeInfo;\n"
13357
"\n"
13358
"}\n"
13359
"function WindowRect(x,y,w,h)\n"
13360
"{\n"
13361
" let s = {};\n"
13362
" s.x = x;\n"
13363
" s.y = y;\n"
13364
" s.w = w;\n"
13365
" s.h = h;\n"
13366
" return s;\n"
13367
"}\n"
13368
"function GetAggregateString()\n"
13369
"{\n"
13370
" if(0 == Settings.AggregateFrames)\n"
13371
" return \'infinite\';\n"
13372
" else\n"
13373
" return Settings.AggregateFrames + \'\';\n"
13374
"}\n"
13375
"\n"
13376
"function AggregateRoll(Direction, Tweak, SetDirect)\n"
13377
"{\n"
13378
" if(SetDirect || SetDirect == 0)\n"
13379
" {\n"
13380
" if(SetDirect <= 0 || SetDirect == \'infinite\')\n"
13381
" {\n"
13382
" Settings.AggregateFrames = 0;\n"
13383
" }\n"
13384
" else\n"
13385
" {\n"
13386
" Settings.AggregateFrames = SetDirect;\n"
13387
" }\n"
13388
" }\n"
13389
" else if(Tweak)\n"
13390
" {\n"
13391
" Settings.AggregateFrames = TweakValue(Settings.AggregateFrames, Tweak, 0.98, 0, 500);\n"
13392
"\n"
13393
" }\n"
13394
" else if(Direction)\n"
13395
" {\n"
13396
" Settings.AggregateFrames = NextValue(AggregatePresets, Settings.AggregateFrames, Direction);\n"
13397
" }\n"
13398
"}\n"
13399
"function ReferenceRoll(Direction, Tweak, SetDirect)\n"
13400
"{\n"
13401
" if(SetDirect)\n"
13402
" {\n"
13403
" Settings.ReferenceTime = SetDirect;\n"
13404
" }\n"
13405
" else if(Tweak)\n"
13406
" {\n"
13407
" Settings.ReferenceTime = TweakValue(Settings.ReferenceTime, Tweak, 0.98, 0.01, 1000);\n"
13408
"\n"
13409
" }\n"
13410
" else if(Direction)\n"
13411
" {\n"
13412
" Settings.ReferenceTime = NextValue(ReferencePresets, Settings.ReferenceTime, Direction);\n"
13413
" }\n"
13414
"}\n"
13415
"\n"
13416
"function ReferenceRollSubGraph(Direction, Tweak, SetDirect)\n"
13417
"{\n"
13418
" let SubGraphSettings = GetSubGraphSettings(SubMenuGraphSettingsKey);\n"
13419
" if(SetDirect)\n"
13420
" {\n"
13421
" SubGraphSettings.ReferenceTime = SetDirect;\n"
13422
" }\n"
13423
" else if(Tweak)\n"
13424
" {\n"
13425
" SubGraphSettings.ReferenceTime = TweakValue(SubGraphSettings.ReferenceTime, Tweak, 0.98, 0.001, 1000);\n"
13426
"\n"
13427
" }\n"
13428
" else if(Direction)\n"
13429
" {\n"
13430
" SubGraphSettings.ReferenceTime = NextValue(ReferencePresets, SubGraphSettings.ReferenceTime, Direction);\n"
13431
" }\n"
13432
"}\n"
13433
"\n"
13434
"function RollSoftFrames(Direction, Tweak, SetDirect)\n"
13435
"{\n"
13436
" if(SetDirect)\n"
13437
" {\n"
13438
" Settings.GraphSoftFrames = SetDirect;\n"
13439
" }\n"
13440
" else if(Tweak)\n"
13441
" {\n"
13442
" Settings.GraphSoftFrames = TweakValue(Settings.GraphSoftFrames, Tweak, 0.98, 2, 30);\n"
13443
"\n"
13444
" }\n"
13445
" else if(Direction)\n"
13446
" {\n"
13447
" Settings.GraphSoftFrames = NextValue(GraphSoftFramePresets, Settings.GraphSoftFrames , Direction);\n"
13448
" }\n"
13449
"}\n"
13450
"\n"
13451
"function ReferenceRollBytes(Direction, Tweak, SetDirect)\n"
13452
"{\n"
13453
" let SubGraphSettings = GetSubGraphSettings(SubMenuGraphSettingsKey);\n"
13454
" if(SetDirect)\n"
13455
" {\n"
13456
" debugger;\n"
13457
" }\n"
13458
" else if(Tweak)\n"
13459
" {\n"
13460
" debugger;\n"
13461
" }\n"
13462
" else if(Direction)\n"
13463
" {\n"
13464
" SubGraphSettings.Bytes = (SubGraphSettings.Bytes + Direction);\n"
13465
" if(SubGraphSettings.Bytes<0)\n"
13466
" SubGraphSettings.Bytes = CounterByteNames.length-1;\n"
13467
" }\n"
13468
"}\n"
13469
"\n"
13470
"\n"
13471
"function RollSoftFrameNames(Direction, Tweak, SetDirect)\n"
13472
"{\n"
13473
" if(Direction)\n"
13474
" {\n"
13475
" Settings.GraphSoftMode = (Settings.GraphSoftMode + Direction);\n"
13476
" if(Settings.GraphSoftMode < 0)\n"
13477
" Settings.GraphSoftMode = GraphSoftFrameModeNames.length-1;\n"
13478
" if(Settings.GraphSoftMode >= GraphSoftFrameModeNames.length)\n"
13479
" Settings.GraphSoftMode = 0\n"
13480
" }\n"
13481
"\n"
13482
"}\n"
13483
"\n"
13484
"function PercentileRollSubGraph(Direction, Tweak, SetDirect)\n"
13485
"{\n"
13486
" let SubGraphSettings = GetSubGraphSettings(SubMenuGraphSettingsKey);\n"
13487
" if(SetDirect)\n"
13488
" {\n"
13489
" SubGraphSettings.Percentile = SetDirect;\n"
13490
" }\n"
13491
" else if(Tweak)\n"
13492
" {\n"
13493
" SubGraphSettings.Percentile = TweakValue(SubGraphSettings.Percentile, Tweak, 0.98, 5, 1000);\n"
13494
" }\n"
13495
" else if(Direction)\n"
13496
" {\n"
13497
" SubGraphSettings.Percentile = NextValue(PercentilePresets, SubGraphSettings.Percentile, Direction);\n"
13498
" }\n"
13499
"}\n"
13500
"\n"
13501
"\n"
13502
"function TargetRoll(Direction, Tweak, SetDirect)\n"
13503
"{\n"
13504
" if(SetDirect)\n"
13505
" {\n"
13506
" Settings.TargetTime = SetDirect;\n"
13507
" }\n"
13508
" else if(Tweak)\n"
13509
" {\n"
13510
" Settings.TargetTime = TweakValue(Settings.TargetTime, Tweak, 0.98, 0.01, 1000);\n"
13511
"\n"
13512
" }\n"
13513
" else if(Direction)\n"
13514
" {\n"
13515
" Settings.TargetTime = NextValue(ReferencePresets, Settings.TargetTime, Direction);\n"
13516
" }\n"
13517
"}\n"
13518
"function TargetRollSubGraph(Direction, Tweak, SetDirect)\n"
13519
"{\n"
13520
" let SubGraphSettings = GetSubGraphSettings(SubMenuGraphSettingsKey);\n"
13521
" if(SetDirect)\n"
13522
" {\n"
13523
" SubGraphSettings.TargetTime = SetDirect;\n"
13524
" }\n"
13525
" else if(Tweak)\n"
13526
" {\n"
13527
" SubGraphSettings.TargetTime = TweakValue(SubGraphSettings.TargetTime, Tweak, 0.98, 5, 1000);\n"
13528
"\n"
13529
" }\n"
13530
" else if(Direction)\n"
13531
" {\n"
13532
" SubGraphSettings.TargetTime = NextValue(ReferencePresets, SubGraphSettings.TargetTime, Direction);\n"
13533
" }\n"
13534
"}\n"
13535
"\n"
13536
"function ToggleCompressedView()\n"
13537
"{\n"
13538
" Settings.ViewCompressed = 1-Settings.ViewCompressed;\n"
13539
" if(Settings.ViewCompressed)\n"
13540
" ViewCompressedTimeout = 3000.0;\n"
13541
" ResizeCanvas();\n"
13542
"}\n"
13543
"\n"
13544
"function DrawMenuSettings()\n"
13545
"{\n"
13546
" var context = CanvasDetailedView.getContext(\'2d\');\n"
13547
" var nColorIndex = 0;\n"
13548
" var SizeInfo = AggregateMenuSize();\n"
13549
" SizeInfo.x = MenuItems[SubMenuSettings].x;\n"
13550
" SizeInfo.y = MenuItems[SubMenuSettings].y;\n"
13551
"\n"
13552
" SizeInfo.w = 200;\n"
13553
" var M = CreateMenuState(SizeInfo);\n"
13554
"\n"
13555
" AggregateTweak = DrawMenuRoll(M, \"Aggregate Frames\", GetAggregateString(), \'\', AggregateRoll, AggregateTweak, \'int\');\n"
13556
" ReferenceTimeTweak = DrawMenuRoll(M, \"Reference Time\", Settings.ReferenceTime, \'\', ReferenceRoll, ReferenceTimeTweak, \'float\');\n"
13557
" TargetTimeTweak = DrawMenuRoll(M, \"Target Time\", Settings.TargetTime, \'\', TargetRoll, TargetTimeTweak, \'float\');\n"
13558
" if(DrawMenuElement(M, Settings.AutomaticReference, \"Automatic Reference Time\", Settings.AutomaticReference, \'white\'))\n"
13559
" {\n"
13560
" Settings.AutomaticReference = 1-Settings.AutomaticReference;\n"
13561
" }\n"
13562
" if(DrawMenuElement(M, Settings.ViewCompressed, \"Compressed View\", Settings.ViewCompressed, \'white\'))\n"
13563
" {\n"
13564
" ToggleCompressedView();\n"
13565
" }\n"
13566
"\n"
13567
" if(Settings.AggregateFrames <= 0)\n"
13568
" {\n"
13569
" if(DrawMenuElement(M, 0, \"Clear Aggregate\", \"Current[\" + AggregateCurrent + \"]\", \'white\'))\n"
13570
" {\n"
13571
" WSSendMessage(\"r\");\n"
13572
" }\n"
13573
" }\n"
13574
" if(DrawMenuElement(M, 0, \"Clear Percentile Aggregate\", \"\", \'white\'))\n"
13575
" {\n"
13576
" let TimerMap = FrameData.TimerMap;\n"
13577
" if(TimerMap)\n"
13578
" {\n"
13579
" for(let key in TimerMap)\n"
13580
" {\n"
13581
" let idx = GetTimer(key);\n"
13582
" let TimerState = TimerMap[key];\n"
13583
" if(!IsGroup(key) && TimerState.Percentile)\n"
13584
" {\n"
13585
" TimerState.PercentileMax = -1e38;\n"
13586
" TimerState.PercentileMin = 1e38;\n"
13587
" TimerState.Percentile = new Float32Array(PERCENTILE_SAMPLES);\n"
13588
" TimerState.Percentile.fill(0.0);\n"
13589
" TimerState.PercentileCount = 0;\n"
13590
" }\n"
13591
" }\n"
13592
" }\n"
13593
" }\n"
13594
"\n"
13595
"\n"
13596
" if(DrawMenuElement(M, Settings.AllowHighDPI, \"Allow High DPI\", Settings.AllowHighDPI, \'white\'))\n"
13597
" {\n"
13598
" Settings.AllowHighDPI = 1 - Settings.AllowHighDPI;\n"
13599
" ResizeCanvas();\n"
13600
" }\n"
13601
" if(DrawMenuElement(M, Cookie.CodeReportMode == 0, \"Code Report: Prompt\", Cookie.CodeReportMode == 0 ? 1 : 0, \'white\'))\n"
13602
" {\n"
13603
" Cookie.CodeReportMode = 0;\n"
13604
" WriteCookie();\n"
13605
" }\n"
13606
"\n"
13607
" if(DrawMenuElement(M, Cookie.CodeReportMode == 1, \"Code Report: Report Silently\", Cookie.CodeReportMode == 1 ? 1 : 0, \'white\'))\n"
13608
" {\n"
13609
" Cookie.CodeReportMode = 1;\n"
13610
" WriteCookie();\n"
13611
" }\n"
13612
" if(DrawMenuElement(M, Cookie.CodeReportMode == 2, \"Code Report: Never Report\", Cookie.CodeReportMode == 2 ? 1 : 0, \'white\'))\n"
13613
" {\n"
13614
" Cookie.CodeReportMode = 2;\n"
13615
" WriteCookie();\n"
13616
" }\n"
13617
"\n"
13618
" SizeInfo.h = M.y - SizeInfo.y;\n"
13619
" return SizeInfo;\n"
13620
"}\n"
13621
"\n"
13622
"function MoveFilterInputDiv(x, y, w)\n"
13623
"{\n"
13624
" if(FilterInputDivPos.x != x || FilterInputDivPos.y != y || FilterInputDivPos.w != w)\n"
13625
" {\n"
13626
" FilterInputDivPos.x = x;\n"
13627
" FilterInputDivPos.y = y;\n"
13628
" FilterInputDivPos.w = w;\n"
13629
" FilterInputDiv.style[\'left\'] = x + \'px\';\n"
13630
" FilterInputDiv.style[\'top\'] = y + \'px\';\n"
13631
" FilterInput.style[\'width\'] = w + \'px\';\n"
13632
" }\n"
13633
"}\n"
13634
"\n"
13635
"function DrawMenuTimer()\n"
13636
"{\n"
13637
" if(FilterInputValueLast != FilterInput.value)\n"
13638
" {\n"
13639
" nOffsetMenuTimers = 0;\n"
13640
" }\n"
13641
" FilterInputValueLast = FilterInput.value;\n"
13642
" var FilterArray = CreateFilter(FilterInput.value);\n"
13643
" var context = CanvasDetailedView.getContext(\'2d\');\n"
13644
" var nColorIndex = 0;\n"
13645
" var SizeInfo = TimerMenuSize();\n"
13646
" SizeInfo.x = MenuItems[SubMenuTimers].x;\n"
13647
" SizeInfo.y = MenuItems[SubMenuTimers].y;\n"
13648
" var Y = SizeInfo.y;\n"
13649
" var Width = SizeInfo.w;\n"
13650
" var Selection = null;\n"
13651
" var X = SizeInfo.x;\n"
13652
" MoveFilterInputDiv(SizeInfo.x, SizeInfo.y, SizeInfo.w);\n"
13653
" Y += 35;\n"
13654
"\n"
13655
" var bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight;\n"
13656
" var bMouseInClear = MouseY >= Y && MouseY < Y + BoxHeight;\n"
13657
" var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
13658
" var TextY = Y+BoxHeight-FontAscent;\n"
13659
" var YClear = Y;\n"
13660
" var TextYClear = TextY;\n"
13661
" var YStart = Y;\n"
13662
"\n"
13663
" var MouseTaken = bMouseIn;\n"
13664
"\n"
13665
" Y += BoxHeight;\n"
13666
" nColorIndex = 1-nColorIndex;\n"
13667
"\n"
13668
" Y -= nOffsetMenuTimers;\n"
13669
"\n"
13670
" for(var i = 0; i < TimerArray.length; ++i)\n"
13671
" {\n"
13672
" var v = TimerArray[i];\n"
13673
" if(v.idtype == TYPE_TIMER\n"
13674
" //|| v.idtype == TYPE_GROUP\n"
13675
" )\n"
13676
" {\n"
13677
" var Name = v.name;\n"
13678
" var ParentName = TimerArray[v.parent].name;\n"
13679
" if(FilterMatch(FilterArray, ParentName + \" \" + Name) && (0 == TimersActiveOnly || v.e))\n"
13680
" {\n"
13681
" if(Y > YStart)\n"
13682
" {\n"
13683
" var ParentColor = TimerArray[v.parent].e ? \'white\' : \'grey\';\n"
13684
" bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight && !MouseTaken;\n"
13685
" bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
13686
" TextY = Y+BoxHeight-FontAscent;\n"
13687
" context.fillStyle = v.e?\'white\':bgcolor;\n"
13688
" context.fillRect(X-2, Y, Width+4, BoxHeight);\n"
13689
" context.fillStyle = bgcolor;\n"
13690
" context.fillRect(X, Y, Width, BoxHeight);\n"
13691
" context.fillStyle = ParentColor;\n"
13692
" context.fillText(ParentName, X + 2, TextY);\n"
13693
" context.fillStyle = v.color;\n"
13694
" context.textAlign = \'right\';\n"
13695
" context.fillText(Name, X + Width - 2, TextY);\n"
13696
" context.textAlign = \'left\';\n"
13697
" if(bMouseIn)\n"
13698
" {\n"
13699
" Selection = v.id;\n"
13700
" }\n"
13701
" }\n"
13702
" Y += BoxHeight;\n"
13703
" nColorIndex = 1-nColorIndex;\n"
13704
" }\n"
13705
" }\n"
13706
" }\n"
13707
"\n"
13708
" {\n"
13709
"\n"
13710
" var c0 = nBackColorOffset;\n"
13711
" var c1 = nBackColors[1];\n"
13712
" var W = Width + 4;\n"
13713
" var WHalf = W / 2;\n"
13714
" var InsideClear = bMouseInClear && MouseX-X< WHalf-1;\n"
13715
" var InsideActive = bMouseInClear && MouseX-X > WHalf+1;\n"
13716
" context.fillStyle = nBackColors[0];\n"
13717
" context.fillRect(X-2, YClear, W, BoxHeight);\n"
13718
"\n"
13719
" context.fillStyle = InsideClear ? c0 :c1;\n"
13720
" context.fillRect(X-2, YClear, WHalf-1, BoxHeight);\n"
13721
" context.fillStyle = InsideActive ? c0 :c1;\n"
13722
" context.fillRect(X-2 + WHalf + 1, YClear, WHalf-1, BoxHeight);\n"
13723
"\n"
13724
"\n"
13725
" context.fillStyle = \'white\';\n"
13726
" context.textAlign = \'center\';\n"
13727
" context.fillText(\"[clear] \", X + 2 + Width * 0.25, TextYClear);\n"
13728
" context.fillStyle = TimersActiveOnly ? \'white\' : \'grey\';\n"
13729
" context.fillText(\"[active only]\", X + 2 + Width * 0.75, TextYClear);\n"
13730
" if(MouseReleased)\n"
13731
" {\n"
13732
" if(InsideActive)\n"
13733
" {\n"
13734
" TimersActiveOnly = 1-TimersActiveOnly;\n"
13735
" }\n"
13736
" if(InsideClear)\n"
13737
" {\n"
13738
" WSSendMessage(\"x\");\n"
13739
" }\n"
13740
" }\n"
13741
" }\n"
13742
" context.textAlign = \'left\';\n"
13743
" if(Selection && MouseReleased && !MouseTaken)\n"
13744
" {\n"
13745
" WSSendMessage(\"c\" + Selection);\n"
13746
" }\n"
13747
" SizeInfo.h = Y-SizeInfo.y;\n"
13748
" return SizeInfo;\n"
13749
"}\n"
13750
"\n"
13751
"var LoadSymbolAnim = -1;\n"
13752
"function LoadSymbolAnimRestart()\n"
13753
"{\n"
13754
" if(LoadSymbolAnim > 0)\n"
13755
" {\n"
13756
" LoadSymbolAnim += 1;\n"
13757
" }\n"
13758
" else\n"
13759
" {\n"
13760
" LoadSymbolAnim = 1;\n"
13761
" }\n"
13762
"}\n"
13763
"function LoadSymbolAnimUpdateAndGet()\n"
13764
"{\n"
13765
" if(LoadSymbolAnim>=0)\n"
13766
" {\n"
13767
" LoadSymbolAnim -= 0.03;\n"
13768
" if(LoadSymbolAnim < 0)\n"
13769
" {\n"
13770
" LoadSymbolAnim = -1;\n"
13771
" }\n"
13772
" else\n"
13773
" {\n"
13774
" return Math.sin(3.14 * LoadSymbolAnim);\n"
13775
" }\n"
13776
"\n"
13777
" }\n"
13778
" return -1;\n"
13779
"}\n"
13780
"\n"
13781
"\n"
13782
"var CircleSteps = 30;\n"
13783
"var CircleX = Array(CircleSteps);\n"
13784
"var CircleY = Array(CircleSteps);\n"
13785
"function InitCircle()\n"
13786
"{\n"
13787
" var twopi = 2 * Math.PI;\n"
13788
" for(var i = 0; i < CircleSteps; ++i)\n"
13789
" {\n"
13790
" var s = (1.0*i) / CircleSteps;\n"
13791
"\n"
13792
" var f = (1.0 * s) * twopi;\n"
13793
" CircleX[i] = Math.sin(f);\n"
13794
" CircleY[i] = Math.cos(f);\n"
13795
" }\n"
13796
"}\n"
13797
"function SpinnerResize(Spinner, w, h)\n"
13798
"{\n"
13799
" if(h != Spinner.CanvasH || w != Spinner.CanvasW || DPR != Spinner.CanvasDPR)\n"
13800
" {\n"
13801
" Spinner.Canvas.style.width = w + \'px\';\n"
13802
" Spinner.Canvas.style.height = h + \'px\';\n"
13803
" Spinner.Canvas.width = w * DPR;\n"
13804
" Spinner.Canvas.height = h * DPR;\n"
13805
" Spinner.Canvas.getContext(\'2d\').scale(DPR, DPR);\n"
13806
" Spinner.CanvasBack.style.width = w + \'px\';\n"
13807
" Spinner.CanvasBack.style.height = h + \'px\';\n"
13808
" Spinner.CanvasBack.width = w * DPR;\n"
13809
" Spinner.CanvasBack.height = h * DPR;\n"
13810
"\n"
13811
" Spinner.CanvasBack.getContext(\'2d\').scale(DPR, DPR);\n"
13812
" Spinner.CanvasH = h;\n"
13813
" Spinner.CanvasW = w;\n"
13814
" Spinner.CanvasDPR = DPR;\n"
13815
" }\n"
13816
"}\n"
13817
"function SpinnerCircle(Phase0, Shift0, Phase1, Shift1, Phase2, Shift2)\n"
13818
"{\n"
13819
" return {\"Phase0\" : Phase0, \"Shift0\": Shift0, \"Phase1\":Phase1, \"Shift1\":Shift1, \"Phase2\": Phase2, \"Shift2\": Shift2, \"Q\": 0, \"QQ\": 0, \"A0\":0, \"A1\":0, \"A2\":0};\n"
13820
"}\n"
13821
"\n"
13822
"function SpinnerInit(Blur, Color)\n"
13823
"{\n"
13824
" var Spinner = {};\n"
13825
" Spinner.x = 0;\n"
13826
" Spinner.y = 0;\n"
13827
" Spinner.Canvas = document.createElement(\'canvas\');\n"
13828
" Spinner.CanvasBack = document.createElement(\'canvas\');\n"
13829
" Spinner.CanvasOffscreenData;\n"
13830
" Spinner.CanvasW = -1;\n"
13831
" Spinner.CanvasH = -1;\n"
13832
" Spinner.CanvasDPR = -1;\n"
13833
" Spinner.Circles = [];\n"
13834
" var x = 1 / 4;\n"
13835
" var y = 0.07;\n"
13836
" Spinner.Circles.push(SpinnerCircle(x, 0, y, 0, 0.0, 0.25));\n"
13837
" Spinner.Circles.push(SpinnerCircle(2/4, 0, 0, 0, 0.14, 0.25));\n"
13838
" Spinner.Fade = 0;\n"
13839
" Spinner.Blur = Blur;\n"
13840
" Spinner.Color = Color;\n"
13841
" return Spinner;\n"
13842
"}\n"
13843
"\n"
13844
"var SpinnerCorner = SpinnerInit(0.8, \'white\');\n"
13845
"var SpinnerLoadButton = SpinnerInit(0, \'white\');\n"
13846
"var SpinnerText1 = SpinnerInit(0.0, \'red\');\n"
13847
"var SpinnerText0 = SpinnerInit(0.0, \'red\');\n"
13848
"\n"
13849
"\n"
13850
"function SpinnerShow()\n"
13851
"{\n"
13852
" return SymbolState != null && (SymbolState.q == 1 || SymbolState.r != SymbolState.f || FunctionQueryLastRequest != FunctionQueryReceived);\n"
13853
"}\n"
13854
"\n"
13855
"function SpinnerDraw(Enable, context, Spinner, X, Y, w, h)\n"
13856
"{\n"
13857
" SpinnerResize(Spinner, w, h);\n"
13858
" var ContextSpinner = Spinner.Canvas.getContext(\'2d\');\n"
13859
"\n"
13860
"\n"
13861
" var now = Date.now();\n"
13862
" if(!ContextSpinner.last)\n"
13863
" {\n"
13864
" ContextSpinner.last = now;\n"
13865
" }\n"
13866
" var DT = now - ContextSpinner.last;\n"
13867
" ContextSpinner.last = now;\n"
13868
" if(Enable)\n"
13869
" {\n"
13870
" Spinner.Fade += DT / 200;\n"
13871
" }\n"
13872
" else\n"
13873
" {\n"
13874
" Spinner.Fade -= DT / 1000;\n"
13875
" }\n"
13876
" Spinner.Fade = Math.max(0, Spinner.Fade);\n"
13877
" Spinner.Fade = Math.min(1, Spinner.Fade);\n"
13878
" var F = Spinner.Fade * Spinner.Fade;\n"
13879
"\n"
13880
" if(Spinner.Fade <= 0)\n"
13881
" return;\n"
13882
" ContextSpinner.clearRect(0, 0, w, h);\n"
13883
" if(Spinner.Blur > 0)\n"
13884
" {\n"
13885
" ContextSpinner.globalAlpha = Spinner.Blur;\n"
13886
" ContextSpinner.drawImage(Spinner.CanvasBack, 0, 0, w, h);\n"
13887
" ContextSpinner.globalAlpha = 1.0;\n"
13888
" }\n"
13889
" var twopi = 2 * Math.PI;\n"
13890
" for(var jjj = 0; jjj < Spinner.Circles.length; ++jjj)\n"
13891
" {\n"
13892
" var C = Spinner.Circles[jjj];\n"
13893
" InitCircle();\n"
13894
" var xs = CircleX;\n"
13895
" var ys = CircleY;\n"
13896
" var scale = (w-2) / 2;\n"
13897
" var offset = (w) / 2;\n"
13898
" var SPEED = 100.0;\n"
13899
"\n"
13900
" var angle = (C.Q / SPEED) * twopi;\n"
13901
"\n"
13902
" var QQSPEED = 1000;\n"
13903
"\n"
13904
" C.A0 += (twopi * DT / 1000.0) * C.Phase0;\n"
13905
" if(C.A0 > twopi)\n"
13906
" C.A0 -= twopi;\n"
13907
" C.A1 += (twopi * DT / 1000.0) * C.Phase1;\n"
13908
" if(C.A1 > twopi)\n"
13909
" C.A1 -= twopi;\n"
13910
" C.A2 += (twopi * DT / 1000.0) * C.Phase2;\n"
13911
" if(C.A2 > twopi)\n"
13912
" C.A2 -= twopi;\n"
13913
"\n"
13914
" var A0 = C.A0 + twopi * C.Shift0;\n"
13915
" var A1 = C.A1 + twopi * C.Shift1;\n"
13916
" var A2 = C.A2 + twopi * C.Shift2;\n"
13917
" var m = Math.cos(A0);\n"
13918
" var m0 = Math.sin(A2);\n"
13919
" var cs = Math.cos(A1);\n"
13920
" var ss = Math.sin(A1);\n"
13921
" for(var i = 0; i < xs.length; ++i)\n"
13922
" {\n"
13923
" var x = xs[i] * m;\n"
13924
" var y = ys[i] * m0;\n"
13925
" xs[i] = cs * scale * x - ss * scale * y;\n"
13926
" ys[i] = ss * scale * x + cs * scale * y;\n"
13927
" xs[i] += offset;\n"
13928
" ys[i] += offset;\n"
13929
" }\n"
13930
" ContextSpinner.strokeStyle = Spinner.Color;\n"
13931
" ContextSpinner.beginPath();\n"
13932
" ContextSpinner.moveTo(xs[0], ys[0]);\n"
13933
" for(var i = 1; i < CircleSteps; ++i)\n"
13934
" {\n"
13935
" ContextSpinner.lineTo(xs[i], ys[i]);\n"
13936
" }\n"
13937
" ContextSpinner.lineTo(xs[0], ys[0]);\n"
13938
" ContextSpinner.stroke();\n"
13939
"\n"
13940
"\n"
13941
" }\n"
13942
" context.globalAlpha = F;\n"
13943
" context.drawImage(Spinner.Canvas, X, Y, w, h);\n"
13944
" context.globalAlpha = 1;\n"
13945
" var tmp = Spinner.CanvasBack;\n"
13946
" Spinner.CanvasBack = Spinner.Canvas;\n"
13947
" Spinner.Canvas = tmp;\n"
13948
"}\n"
13949
"\n"
13950
"\n"
13951
"function DrawMenuPatched()\n"
13952
"{\n"
13953
" if(FilterInputValueLast != FilterInput.value)\n"
13954
" {\n"
13955
" nOffsetMenuPatched = 0;\n"
13956
" }\n"
13957
"\n"
13958
" var FilterArray = CreateFilter(FilterInput.value);\n"
13959
" var context = CanvasDetailedView.getContext(\'2d\');\n"
13960
" var nColorIndex = 0;\n"
13961
" var SizeInfo = TimerMenuSize();\n"
13962
" SizeInfo.x = MenuItems[SubMenuPatched].x;\n"
13963
" SizeInfo.y = MenuItems[SubMenuPatched].y;\n"
13964
" var Y = SizeInfo.y;\n"
13965
" var Width = SizeInfo.w;\n"
13966
" Width = Math.max(300, Width);\n"
13967
" Width = 10+ MeasureArray(Width, FunctionsInstrumented, function(s, i){return s + \" \" + FunctionsInstrumentedModule[i];} );\n"
13968
"\n"
13969
" if(Width + SizeInfo.x + 50 > nWidth)\n"
13970
" {\n"
13971
" Width = nWidth - (SizeInfo.x+50);\n"
13972
" }\n"
13973
" SizeInfo.w = Width;\n"
13974
" var MaxStringLength = Math.floor(Width/(FontWidth));\n"
13975
"\n"
13976
" var Selection = null;\n"
13977
" var X = SizeInfo.x;\n"
13978
" context.fillStyle = nBackColors[0];\n"
13979
" TextY = Y+BoxHeight-FontAscent;\n"
13980
" context.fillRect(X, Y, Width, BoxHeight);\n"
13981
"\n"
13982
" var bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight && MouseX-X < 100;\n"
13983
" context.fillRect(X, Y, 99, BoxHeight);\n"
13984
" context.textAlign = \'center\';\n"
13985
" context.fillStyle = \'white\';\n"
13986
" context.fillText(\"Patched functions\", X + Width/2, TextY);\n"
13987
"\n"
13988
" Y += BoxHeight;\n"
13989
" MoveFilterInputDiv(SizeInfo.x, Y, SizeInfo.w-6);\n"
13990
" Y += 45;\n"
13991
"\n"
13992
" bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight;\n"
13993
" var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
13994
" var TextY = Y+BoxHeight-FontAscent;\n"
13995
" var YClear = Y;\n"
13996
" var TextYClear = TextY;\n"
13997
" var bgcolorClear = bgcolor;\n"
13998
" var YStart = Y-BoxHeight*2;\n"
13999
"\n"
14000
" nColorIndex = 1-nColorIndex;\n"
14001
"\n"
14002
" Y -= nOffsetMenuFunctions + 10;\n"
14003
" var Selection = -1;\n"
14004
"\n"
14005
" var StringColor = function(Name)\n"
14006
" {\n"
14007
" var h = StringHash(Name);\n"
14008
" var cidx = h % 360;\n"
14009
" return cidx;\n"
14010
" };\n"
14011
"\n"
14012
" var GetColor = function(Str)\n"
14013
" {\n"
14014
" var cidx = StringColor(Str);\n"
14015
" return \"hsl(\" + cidx + \",50%, 70%)\";\n"
14016
" };\n"
14017
" for(var i = 0; i < FunctionsInstrumented.length; ++i)\n"
14018
" {\n"
14019
" var Name = FunctionsInstrumented[i];\n"
14020
" var ModuleName = FunctionsInstrumentedModule[i];\n"
14021
" if(FilterMatch(FilterArray, ModuleName + \" \" + Name))\n"
14022
" {\n"
14023
"\n"
14024
" var Color = GetColor(Name);\n"
14025
" var ColorModule = GetColor(Name);\n"
14026
" if(Y >= YStart)\n"
14027
" {\n"
14028
" bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight;\n"
14029
" bgcolor = bMouseIn && MouseX > X ? nBackColorOffset : nBackColors[nColorIndex];\n"
14030
" TextY = Y+BoxHeight-FontAscent;\n"
14031
"\n"
14032
" context.fillStyle = bgcolor;\n"
14033
" context.fillRect(X, Y, Width, BoxHeight);\n"
14034
" context.fillStyle = Color;\n"
14035
" context.textAlign = \'right\';\n"
14036
" context.fillText(Name, X + Width - 2, TextY);\n"
14037
" context.textAlign = \'left\';\n"
14038
" context.fillStyle = ColorModule;\n"
14039
" context.fillText(ModuleName, X, TextY);\n"
14040
" }\n"
14041
" Y += BoxHeight;\n"
14042
" nColorIndex = 1-nColorIndex;\n"
14043
" }\n"
14044
" }\n"
14045
" context.textAlign = \'left\';\n"
14046
" SizeInfo.h = Y-SizeInfo.y;\n"
14047
" return SizeInfo;\n"
14048
"}\n"
14049
"\n"
14050
"\n"
14051
"function DrawMenuModules()\n"
14052
"{\n"
14053
" if(FilterInputValueLast != FilterInput.value)\n"
14054
" {\n"
14055
" nOffsetMenuModules = 0;\n"
14056
" }\n"
14057
" FilterInputValueLast = FilterInput.value;\n"
14058
" let M = ModuleState;\n"
14059
" let FilterArray = CreateFilter(FilterInput.value);\n"
14060
" let context = CanvasDetailedView.getContext(\'2d\');\n"
14061
" let nColorIndex = 0;\n"
14062
" let SizeInfo = TimerMenuSize(); //broken, fix!\n"
14063
"\n"
14064
" SizeInfo.x = MenuItems[SubMenuModules].x;\n"
14065
" SizeInfo.y = MenuItems[SubMenuModules].y;\n"
14066
" let Y = SizeInfo.y;\n"
14067
" let Width = SizeInfo.w;\n"
14068
" Width = Math.max(300, Width);\n"
14069
" Width = 10+ MeasureArray(Width, M, function(s){return s.n + \" \" + s.s;} );\n"
14070
"\n"
14071
" if(Width + SizeInfo.x + 50 > nWidth)\n"
14072
" {\n"
14073
" Width = nWidth - (SizeInfo.x+50);\n"
14074
" }\n"
14075
" SizeInfo.w = Width;\n"
14076
"\n"
14077
"\n"
14078
" let MaxStringLength = Math.floor(Width/(FontWidth));\n"
14079
"\n"
14080
"\n"
14081
" let X = SizeInfo.x;\n"
14082
" DrawSymbolHeaderMenu(context, X, Y, Width);\n"
14083
"\n"
14084
" Y += BoxHeight;\n"
14085
" MoveFilterInputDiv(SizeInfo.x, Y, SizeInfo.w-6);\n"
14086
" Y += 45;\n"
14087
"\n"
14088
" let bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight;\n"
14089
" let bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
14090
" let TextY = Y+BoxHeight-FontAscent;\n"
14091
" let YClear = Y;\n"
14092
" let TextYClear = TextY;\n"
14093
" let bgcolorClear = bgcolor;\n"
14094
" let YStart = Y-BoxHeight*2;\n"
14095
"\n"
14096
" nColorIndex = 1-nColorIndex;\n"
14097
"\n"
14098
" Y -= nOffsetMenuModules + 10;\n"
14099
" let Selection = -1;\n"
14100
"\n"
14101
" let StringColor = function(Name)\n"
14102
" {\n"
14103
" let h = StringHash(Name);\n"
14104
" let cidx = h % 360;\n"
14105
" return cidx;\n"
14106
" };\n"
14107
"\n"
14108
" for(let i = 0; i < M.length; ++i)\n"
14109
" {\n"
14110
" let Name = M[i].n;\n"
14111
" let Count = M[i].s;\n"
14112
" let Prc = M[i].p;\n"
14113
" if(Prc<0||Prc>1)\n"
14114
" Prc = 0;\n"
14115
" let cidx = StringColor(Name);\n"
14116
" let Color = \"hsl(\" + cidx + \",50%, 70%)\";\n"
14117
" let C1 = \"hsl(\" + cidx + \",30%, 40%)\";\n"
14118
" let N = Name;\n"
14119
" if(M[i].d)\n"
14120
" N = N + \"[downloading]\";\n"
14121
" if(N.length > MaxStringLength)\n"
14122
" {\n"
14123
" N = N.substring(N.length - MaxStringLength);\n"
14124
" }\n"
14125
" if(FilterMatch(FilterArray, Name))\n"
14126
" {\n"
14127
"\n"
14128
" if(Y >= YStart)\n"
14129
" {\n"
14130
" bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight;\n"
14131
" bgcolor = bMouseIn && MouseX > X ? nBackColorOffset : nBackColors[nColorIndex];\n"
14132
" TextY = Y+BoxHeight-FontAscent;\n"
14133
"\n"
14134
" context.fillStyle = bgcolor;\n"
14135
" context.fillRect(X, Y, Width, BoxHeight);\n"
14136
" if(Prc>0 && Prc <= 1)\n"
14137
" {\n"
14138
" context.fillStyle = C1;\n"
14139
" context.fillRect(X, Y, Prc*Width, BoxHeight);\n"
14140
" }\n"
14141
" context.fillStyle = \'white\';\n"
14142
" context.textAlign = \'right\';\n"
14143
" context.fillText(Count + \'\', X + Width - 2, TextY);\n"
14144
" context.textAlign = \'left\';\n"
14145
" context.fillStyle = Color;\n"
14146
" context.fillText(N, X, TextY);\n"
14147
" if(bMouseIn)\n"
14148
" {\n"
14149
" Selection = i;\n"
14150
" }\n"
14151
" }\n"
14152
" Y += BoxHeight;\n"
14153
" nColorIndex = 1-nColorIndex;\n"
14154
" }\n"
14155
" }\n"
14156
" context.textAlign = \'left\';\n"
14157
" if(Selection != -1 && MouseReleased)\n"
14158
" {\n"
14159
" WSSendMessage(\"L\" + M[Selection].n);\n"
14160
" }\n"
14161
" SizeInfo.h = Y-SizeInfo.y;\n"
14162
" return SizeInfo;\n"
14163
"}\n"
14164
"function DrawSymbolHeaderMenu(context, X, Y, Width)\n"
14165
"{\n"
14166
" context.fillStyle = nBackColors[0];\n"
14167
" let TextY = Y+BoxHeight-FontAscent;\n"
14168
" context.fillRect(X+100, Y, Width-100, BoxHeight);\n"
14169
" let bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight && MouseX-X < 100;\n"
14170
" if(bMouseIn)\n"
14171
" {\n"
14172
" context.fillStyle = nBackColorOffset;\n"
14173
" }\n"
14174
"\n"
14175
" context.fillRect(X, Y, 99, BoxHeight);\n"
14176
"\n"
14177
"\n"
14178
" let NumSymbols = 0;\n"
14179
" let SymbolStateString = \"Load all\";\n"
14180
" let SymbolButtonActive = 1;\n"
14181
" let SymbolSpinnerActive = 0;\n"
14182
" let FinishedSymbols = 0;\n"
14183
" if(SymbolState)\n"
14184
" {\n"
14185
" FinishedSymbols = SymbolState.f;\n"
14186
" var s = SymbolState.s;\n"
14187
" NumSymbols = SymbolState.l;\n"
14188
" SymbolButtonActive = 1;\n"
14189
" if(SymbolState.q == 1 || FunctionQueryLastRequest != FunctionQueryReceived)\n"
14190
" {\n"
14191
" SymbolStateString = \"Querying\";\n"
14192
" SymbolButtonActive = 0;\n"
14193
" SymbolSpinnerActive = 1;\n"
14194
" }\n"
14195
" else if(SymbolState.f != SymbolState.r)\n"
14196
" {\n"
14197
" SymbolButtonActive = 0;\n"
14198
" SymbolSpinnerActive = 1;\n"
14199
" SymbolStateString = \"Loading\";\n"
14200
" }\n"
14201
" else if(SymbolState.f == ModuleState.length)\n"
14202
" {\n"
14203
" SymbolButtonActive = 0;\n"
14204
" SymbolStateString = \"Loaded\";\n"
14205
" }\n"
14206
" }\n"
14207
" let LoadButtonAnimation = LoadSymbolAnimUpdateAndGet();\n"
14208
"\n"
14209
" context.textAlign = \'right\';\n"
14210
" context.fillStyle = \'white\';\n"
14211
" context.fillText(NumSymbols + \" Symbols \" + FinishedSymbols + \"/\" + ModuleState.length + \" Modules\", X+Width-2, TextY);\n"
14212
" context.textAlign = \'center\';\n"
14213
"\n"
14214
" if(LoadButtonAnimation>0)\n"
14215
" {\n"
14216
" var c = \"hsl(0,0%,\" + (LoadButtonAnimation * 100)+\"%)\";\n"
14217
" context.fillStyle = c;\n"
14218
" }\n"
14219
" if(SymbolButtonActive)\n"
14220
" {\n"
14221
" if(bMouseIn && MouseReleased)\n"
14222
" {\n"
14223
" WSSendMessage(\"S\"); //load symbols\n"
14224
" }\n"
14225
" context.fillText(SymbolStateString, X + 50, TextY);\n"
14226
" }\n"
14227
" else\n"
14228
" {\n"
14229
" context.fillStyle = \'grey\';\n"
14230
" context.fillText(SymbolStateString, X + 50, TextY);\n"
14231
" }\n"
14232
" SpinnerDraw(SymbolSpinnerActive, context, SpinnerLoadButton, X+2, Y, FontHeight, FontHeight );\n"
14233
"\n"
14234
"\n"
14235
"}\n"
14236
"\n"
14237
"function DrawMenuFunctions()\n"
14238
"{\n"
14239
" if(FilterInputValueLast != FilterInput.value)\n"
14240
" {\n"
14241
" nOffsetMenuFunctions = 0;\n"
14242
" var m = FilterInput.value.trim();\n"
14243
" if(m != \"\")\n"
14244
" {\n"
14245
" if(SymbolState && SymbolState.r == SymbolState.f)\n"
14246
" {\n"
14247
" var Req = ++FunctionQueryLastRequest;\n"
14248
" var Q = \"q\" + Req + \"x\" + m;\n"
14249
" WSSendMessage(Q);\n"
14250
" FunctionQueryPending = null;\n"
14251
" }\n"
14252
" else\n"
14253
" {\n"
14254
" FunctionQueryPending = m;\n"
14255
" if(SymbolState) //wtf?\n"
14256
" {\n"
14257
" LoadSymbolAnimRestart();\n"
14258
" }\n"
14259
" }\n"
14260
" }\n"
14261
" }\n"
14262
"\n"
14263
" FilterInputValueLast = FilterInput.value;\n"
14264
" var FF = FunctionQueryArray;\n"
14265
" var FilterArray = CreateFilter(FilterInput.value);\n"
14266
" var context = CanvasDetailedView.getContext(\'2d\');\n"
14267
" var nColorIndex = 0;\n"
14268
" var SizeInfo = TimerMenuSize(); //broken, fix\n"
14269
" SizeInfo.x = MenuItems[SubMenuFunctions].x;\n"
14270
" SizeInfo.y = MenuItems[SubMenuFunctions].y;\n"
14271
" var Y = SizeInfo.y;\n"
14272
" var Width = SizeInfo.w;\n"
14273
" Width = Math.max(300, Width);\n"
14274
" Width = 10+ MeasureArray(Width, FF, function(s){return s.n + \" \" + s.m;} );\n"
14275
"\n"
14276
" if(Width + SizeInfo.x + 50 > nWidth)\n"
14277
" {\n"
14278
" Width = nWidth - (SizeInfo.x+50);\n"
14279
" }\n"
14280
" SizeInfo.w = Width;\n"
14281
" var MaxStringLength = Math.floor(Width/(FontWidth));\n"
14282
"\n"
14283
" var Selection = null;\n"
14284
" var X = SizeInfo.x;\n"
14285
"\n"
14286
" {\n"
14287
" DrawSymbolHeaderMenu(context, X, Y, Width);\n"
14288
" }\n"
14289
"\n"
14290
"\n"
14291
" Y += BoxHeight;\n"
14292
" MoveFilterInputDiv(SizeInfo.x, Y, SizeInfo.w-6);\n"
14293
" Y += 45;\n"
14294
"\n"
14295
" let bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight;\n"
14296
" var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
14297
" var TextY = Y+BoxHeight-FontAscent;\n"
14298
" var YClear = Y;\n"
14299
" var TextYClear = TextY;\n"
14300
" var bgcolorClear = bgcolor;\n"
14301
" var YStart = Y-BoxHeight*2;\n"
14302
"\n"
14303
" nColorIndex = 1-nColorIndex;\n"
14304
"\n"
14305
" Y -= nOffsetMenuFunctions + 10;\n"
14306
" var Selection = -1;\n"
14307
"\n"
14308
" var StringColor = function(Name)\n"
14309
" {\n"
14310
" var h = StringHash(Name);\n"
14311
" var cidx = h % 360;\n"
14312
" return cidx;\n"
14313
" };\n"
14314
"\n"
14315
" for(var i = 0; i < FF.length; ++i)\n"
14316
" {\n"
14317
" if(true)\n"
14318
" {\n"
14319
" var Name = FF[i].n;\n"
14320
" var ShortName = FF[i].sn;\n"
14321
" var Color = FF[i].c;\n"
14322
" var ColorModule = FF[i].cm;\n"
14323
" var ModuleName = FF[i].m;\n"
14324
" if(!Color || !ColorModule)\n"
14325
" {\n"
14326
" var cidx = StringColor(ShortName);\n"
14327
" FF[i].c = \"hsl(\" + cidx + \",50%, 70%)\";\n"
14328
" FF[i].rgb = ConvertHslToRGB(cidx/ 360, 0.5, 0.7);\n"
14329
" var cidxModule = StringColor(ModuleName);\n"
14330
" FF[i].cm = \"hsl(\" + cidxModule + \",50%, 70%)\";\n"
14331
" FF[i].rgbm = ConvertHslToRGB(cidxModule/ 360, 0.5, 0.7);\n"
14332
" Colo";
14333
14334
const size_t g_MicroProfileHtmlLive_begin_3_size = sizeof(g_MicroProfileHtmlLive_begin_3);
14335
const char g_MicroProfileHtmlLive_begin_4[] =
14336
"r = FF[i].c;\n"
14337
" ColorModule = FF[i].cm;\n"
14338
" }\n"
14339
" var UseAlt = 0;\n"
14340
" var N = UseAlt ? Name : ShortName;\n"
14341
" if(N.length > MaxStringLength)\n"
14342
" {\n"
14343
" N = N.substring(N.length - MaxStringLength);\n"
14344
" }\n"
14345
" var E = false;\n"
14346
" if(true)\n"
14347
" {\n"
14348
"\n"
14349
" if(Y >= YStart)\n"
14350
" {\n"
14351
" bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight;\n"
14352
" bgcolor = bMouseIn && MouseX > X ? nBackColorOffset : nBackColors[nColorIndex];\n"
14353
" TextY = Y+BoxHeight-FontAscent;\n"
14354
"\n"
14355
" context.fillStyle = bgcolor;\n"
14356
" context.fillRect(X, Y, Width, BoxHeight);\n"
14357
" context.fillStyle = Color;\n"
14358
" context.textAlign = \'right\';\n"
14359
" context.fillText(N, X + Width - 2, TextY);\n"
14360
" context.textAlign = \'left\';\n"
14361
" context.fillStyle = ColorModule;\n"
14362
" context.fillText(ModuleName, X, TextY);\n"
14363
" if(bMouseIn)\n"
14364
" {\n"
14365
" context.fillStyle = Color;\n"
14366
" var bgcolorin = bMouseIn && MouseX < X ? nBackColorOffset : nBackColors[nColorIndex];\n"
14367
"\n"
14368
" Selection = i;\n"
14369
" var W = context.measureText(\'>>\').width;\n"
14370
" W = Math.max(W, BoxHeight) + 2;\n"
14371
" var Corner = X - W - 1;\n"
14372
" if(Corner < SizeInfo.x)\n"
14373
" {\n"
14374
" SizeInfo.w += SizeInfo.x - Corner;\n"
14375
" SizeInfo.x = Corner;\n"
14376
" }\n"
14377
" context.fillStyle = bgcolorin;\n"
14378
" context.fillRect(Corner, Y, W, BoxHeight);\n"
14379
" context.fillStyle = Color;\n"
14380
" context.textAlign = \'center\';\n"
14381
" context.fillText(\">>\", Corner + Math.floor(W / 2), TextY);\n"
14382
"\n"
14383
" context.textAlign = \'left\';\n"
14384
" }\n"
14385
" }\n"
14386
" Y += BoxHeight;\n"
14387
" nColorIndex = 1-nColorIndex;\n"
14388
" }\n"
14389
" }\n"
14390
" }\n"
14391
"\n"
14392
" context.textAlign = \'left\';\n"
14393
" if(Selection != -1 && MouseReleased)\n"
14394
" {\n"
14395
" if(KeyShiftDown || MouseX < X)\n"
14396
" {\n"
14397
" let messageStart = \"I\" + FF[Selection].a + \' \' + FF[Selection].rgb;\n"
14398
" let messageEnd = FF[Selection].m + \'!\' + FF[Selection].n;\n"
14399
" let cb = function(result)\n"
14400
" {\n"
14401
" let size = parseInt(result[0]);\n"
14402
" if(isNaN(size))\n"
14403
" size = 0;\n"
14404
" let MaxFunctions = parseInt(result[1]);\n"
14405
" if(isNaN(MaxFunctions))\n"
14406
" MaxFunctions = 0;\n"
14407
" WSSendMessage(messageStart + \' \' + size + \' \' + MaxFunctions + \' \' + messageEnd);\n"
14408
" };\n"
14409
" let text = \"Instrument functions called by \" + messageEnd\n"
14410
" showPopup(text, [\n"
14411
" {label:\"Minimum function size(bytes)\", value:\"128\"},\n"
14412
" {label:\"Max functions to instrument\", value:\"0\"},\n"
14413
" ], cb);\n"
14414
" }\n"
14415
" else\n"
14416
" {\n"
14417
" WSSendMessage(\"i\" + FF[Selection].a + \' \' + FF[Selection].rgb + \' 0 0 \' + FF[Selection].m + \'!\' + FF[Selection].n);\n"
14418
" }\n"
14419
" }\n"
14420
" SizeInfo.h = Y-SizeInfo.y;\n"
14421
" return SizeInfo;\n"
14422
"}\n"
14423
"\n"
14424
"function DrawMenuGeneric(Elements, Active, OnClick, x, y, Elements2)\n"
14425
"{\n"
14426
" var context = CanvasDetailedView.getContext(\'2d\');\n"
14427
" var nColorIndex = 0;\n"
14428
" if(Elements2.length != Elements.length)\n"
14429
" {\n"
14430
" Elements2 = null;\n"
14431
" }\n"
14432
"\n"
14433
" var h = FontHeight * Elements.length;\n"
14434
" var w = 20;\n"
14435
" var w2 = 0;\n"
14436
" for(var i = 0; i < Elements.length; ++i)\n"
14437
" {\n"
14438
" var m = context.measureText(Elements[i]).width;\n"
14439
" w = w > m ? w : m;\n"
14440
" if(Elements2)\n"
14441
" {\n"
14442
" m = context.measureText(Elements2[i]).width;\n"
14443
" w2 = w2 > m ? w2 : m;\n"
14444
" }\n"
14445
" }\n"
14446
" w += 10 + w2;\n"
14447
" var SizeInfo = MenuSize(w);\n"
14448
" SizeInfo.x = x;\n"
14449
" SizeInfo.y = y;\n"
14450
" var X = x;\n"
14451
" var Y = y;\n"
14452
"\n"
14453
"\n"
14454
" for(var i = 0; i < Elements.length; ++i)\n"
14455
" {\n"
14456
" var Selected = Active == i;\n"
14457
" var Name = Elements[i];\n"
14458
" var bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight;\n"
14459
" var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
14460
" var TextY = Y+BoxHeight-FontAscent;\n"
14461
" context.fillStyle = Selected?\'white\':bgcolor;\n"
14462
" context.fillRect(X-2, Y, w+4, BoxHeight);\n"
14463
" context.fillStyle = bgcolor;\n"
14464
" context.fillRect(X, Y, w, BoxHeight);\n"
14465
" context.fillStyle = \'white\';\n"
14466
" context.fillText(Name, X + 2, TextY);\n"
14467
" if(Elements2)\n"
14468
" {\n"
14469
" context.textAlign = \"right\";\n"
14470
" context.fillText(Elements2[i], X + w , TextY);\n"
14471
" context.textAlign = \"left\";\n"
14472
" }\n"
14473
" context.fillText(Name, X + 2, TextY);\n"
14474
" if(bMouseIn && MouseReleased)\n"
14475
" {\n"
14476
" OnClick(i, Name);\n"
14477
" }\n"
14478
" Y += BoxHeight;\n"
14479
" nColorIndex = 1-nColorIndex;\n"
14480
" }\n"
14481
" SizeInfo.h = Y - SizeInfo.y;\n"
14482
" return SizeInfo;\n"
14483
"}\n"
14484
"\n"
14485
"function DrawMenuGroup()\n"
14486
"{\n"
14487
" if(FilterInputValueLast != FilterInput.value)\n"
14488
" {\n"
14489
" nOffsetMenuGroup = 0;\n"
14490
" }\n"
14491
" FilterInputValueLast = FilterInput.value;\n"
14492
"\n"
14493
" var context = CanvasDetailedView.getContext(\'2d\');\n"
14494
" var nColorIndex = 0;\n"
14495
" var Selection = null;\n"
14496
" var SizeInfo = GroupMenuSize();\n"
14497
" SizeInfo.x = MenuItems[SubMenuGroup].x;\n"
14498
" SizeInfo.y = MenuItems[SubMenuGroup].y;\n"
14499
" var Y = SizeInfo.y;\n"
14500
" var X = SizeInfo.x;\n"
14501
" var Width = SizeInfo.w;\n"
14502
" var FilterArray = CreateFilter(FilterInput.value);\n"
14503
" MoveFilterInputDiv(SizeInfo.x-2, SizeInfo.y, SizeInfo.w-1);\n"
14504
" var YStart = Y+20;\n"
14505
" Y += 35;\n"
14506
" Y -= nOffsetMenuGroup;\n"
14507
"\n"
14508
"\n"
14509
" function DrawMenuElement(Selected, Name, color, Indent)\n"
14510
" {\n"
14511
" var bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight;\n"
14512
" var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
14513
" context.fillStyle = Selected?\'white\':bgcolor;\n"
14514
" context.fillRect(X-2, Y, Width+4, BoxHeight);\n"
14515
" context.fillStyle = bgcolor;\n"
14516
" context.fillRect(X, Y, Width, BoxHeight);\n"
14517
" context.fillStyle = color;\n"
14518
" if(!Indent) Indent = 0;\n"
14519
" context.fillText(Name, X + Indent*FontWidth, Y+BoxHeight-FontAscent);\n"
14520
" nColorIndex = 1-nColorIndex;\n"
14521
" Y += BoxHeight;\n"
14522
" return bMouseIn;\n"
14523
" }\n"
14524
" function DrawMenuRecursive(Index, Indent, categorymatch)\n"
14525
" {\n"
14526
" ProfileEnter(\"DrawMenuRecursive\");\n"
14527
" var v = TimerArray[Index];\n"
14528
" if(v.idtype == TYPE_TIMER || v.idtype == TYPE_COUNTER)\n"
14529
" {\n"
14530
" return;\n"
14531
" }\n"
14532
" if(v.idtype == TYPE_GROUP && !categorymatch)\n"
14533
" {\n"
14534
" if(!FilterMatch(FilterArray, v.name))\n"
14535
" {\n"
14536
" return;\n"
14537
" }\n"
14538
" }\n"
14539
" var catmatch = 0;\n"
14540
" if(v.idtype == TYPE_CATEGORY)\n"
14541
" {\n"
14542
" if(FilterMatch(FilterArray, v.name))\n"
14543
" {\n"
14544
" catmatch = 1;\n"
14545
" }\n"
14546
" }\n"
14547
" var Closed = 0;\n"
14548
" if(Index > 0)\n"
14549
" {\n"
14550
" if(Y > YStart)\n"
14551
" {\n"
14552
" if(DrawMenuElement(v.e, v.name, v.color, Indent))\n"
14553
" {\n"
14554
" Selection = v.id;\n"
14555
" }\n"
14556
" }\n"
14557
" else\n"
14558
" {\n"
14559
" Y += BoxHeight;\n"
14560
" }\n"
14561
" }\n"
14562
"\n"
14563
" if(!Closed)\n"
14564
" {\n"
14565
" var ChildIndex = v.firstchild;\n"
14566
" while(ChildIndex != -1)\n"
14567
" {\n"
14568
" DrawMenuRecursive(ChildIndex, Indent + 1, catmatch);\n"
14569
" ChildIndex = TimerArray[ChildIndex].sibling;\n"
14570
" }\n"
14571
" }\n"
14572
" ProfileLeave();\n"
14573
" }\n"
14574
" DrawMenuRecursive(0, -1);\n"
14575
" if(Selection && MouseReleased)\n"
14576
" {\n"
14577
" WSSendMessage(\"c\" + Selection);\n"
14578
" }\n"
14579
" SizeInfo.h = Y - SizeInfo.y;\n"
14580
" return SizeInfo;\n"
14581
"}\n"
14582
"\n"
14583
"function DrawMenuCounters()\n"
14584
"{\n"
14585
" if(FilterInputValueLast != FilterInput.value)\n"
14586
" {\n"
14587
" nOffsetMenuCounters = 0;\n"
14588
" }\n"
14589
" FilterInputValueLast = FilterInput.value;\n"
14590
"\n"
14591
" var context = CanvasDetailedView.getContext(\'2d\');\n"
14592
" var nColorIndex = 0;\n"
14593
" var Selection = null;\n"
14594
" var SizeInfo = CounterMenuSize();\n"
14595
" SizeInfo.x = MenuItems[SubMenuCounters].x;\n"
14596
" SizeInfo.y = MenuItems[SubMenuCounters].y;\n"
14597
" var Y = SizeInfo.y;\n"
14598
" var X = SizeInfo.x;\n"
14599
" var Width = SizeInfo.w;\n"
14600
" var FilterArray = CreateFilter(FilterInput.value);\n"
14601
" MoveFilterInputDiv(SizeInfo.x-2, SizeInfo.y, SizeInfo.w-1);\n"
14602
" var YStart = Y+20;\n"
14603
" Y += 35;\n"
14604
" Y -= nOffsetMenuCounters;\n"
14605
"\n"
14606
"\n"
14607
" function DrawMenuElement(Selected, Name, color, Indent)\n"
14608
" {\n"
14609
" var bMouseIn = MouseY >= Y && MouseY < Y + BoxHeight;\n"
14610
" var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
14611
" context.fillStyle = Selected?\'white\':bgcolor;\n"
14612
" context.fillRect(X-2, Y, Width+4, BoxHeight);\n"
14613
" context.fillStyle = bgcolor;\n"
14614
" context.fillRect(X, Y, Width, BoxHeight);\n"
14615
" context.fillStyle = color;\n"
14616
" if(!Indent) Indent = 0;\n"
14617
" context.fillText(Name, X + Indent*FontWidth, Y+BoxHeight-FontAscent);\n"
14618
" nColorIndex = 1-nColorIndex;\n"
14619
" Y += BoxHeight;\n"
14620
" return bMouseIn;\n"
14621
" }\n"
14622
" function DrawMenuRecursive(Index, Indent, categorymatch)\n"
14623
" {\n"
14624
" ProfileEnter(\"DrawMenuRecursive\");\n"
14625
" var v = TimerArray[Index];\n"
14626
" if(v.idtype == TYPE_GROUP || v.idtype == TYPE_TIMER || v.idtype == TYPE_GROUP || v.idtype == TYPE_SETTING)\n"
14627
" {\n"
14628
" return;\n"
14629
" }\n"
14630
" \n"
14631
" if(v.sortkey)\n"
14632
" {\n"
14633
" if(!FilterMatch(FilterArray, v.sortkey))\n"
14634
" {\n"
14635
" return;\n"
14636
" }\n"
14637
" }\n"
14638
" var catmatch = 0;\n"
14639
" var Closed = 0;\n"
14640
" if(Index > 0)\n"
14641
" {\n"
14642
" if(Y > YStart)\n"
14643
" {\n"
14644
" if(DrawMenuElement(v.e, v.name, v.color, Indent*2))\n"
14645
" {\n"
14646
" Selection = v.id;\n"
14647
" }\n"
14648
" }\n"
14649
" else\n"
14650
" {\n"
14651
" Y += BoxHeight;\n"
14652
" }\n"
14653
" }\n"
14654
"\n"
14655
" if(!Closed)\n"
14656
" {\n"
14657
" var ChildIndex = v.firstchild;\n"
14658
" while(ChildIndex != -1)\n"
14659
" {\n"
14660
" DrawMenuRecursive(ChildIndex, Indent + 1, catmatch);\n"
14661
" ChildIndex = TimerArray[ChildIndex].sibling;\n"
14662
" }\n"
14663
" }\n"
14664
" ProfileLeave();\n"
14665
" }\n"
14666
" DrawMenuRecursive(0, -1);\n"
14667
" if(Selection && MouseReleased)\n"
14668
" {\n"
14669
" WSSendMessage(\"c\" + Selection);\n"
14670
" }\n"
14671
" SizeInfo.h = Y - SizeInfo.y;\n"
14672
" return SizeInfo;\n"
14673
"}\n"
14674
"\n"
14675
"\n"
14676
"function ShowMenu()\n"
14677
"{\n"
14678
" if(!Settings.ViewCompressed)\n"
14679
" return true;\n"
14680
" else\n"
14681
" {\n"
14682
" var Time = new Date();\n"
14683
" var Delta = Time - MouseMoveTime;\n"
14684
" console.log(\'delta time is \' + Delta);\n"
14685
" return Delta < 2000;\n"
14686
" }\n"
14687
"}\n"
14688
"\n"
14689
"function DrawMenu()\n"
14690
"{\n"
14691
" if(WSConnected && WS && WS.readyState == 1 && !Settings.ViewCompressed)\n"
14692
" {\n"
14693
" var context = CanvasDetailedView.getContext(\'2d\');\n"
14694
" var nColorIndex = 0;\n"
14695
" var Y = 50;\n"
14696
" var Width = 300;\n"
14697
" var Selection = null;\n"
14698
" if(!ShowMenu())\n"
14699
" {\n"
14700
" return;\n"
14701
" }\n"
14702
" ProfileEnter(\"DrawMenu\");\n"
14703
" DrawTopMenu();\n"
14704
" var MenuRect = WindowRect(0,0,nWidth,nHeight);\n"
14705
" if(SubMenuActive != -1)\n"
14706
" {\n"
14707
" MouseMoveTime = new Date();\n"
14708
" }\n"
14709
" if(SubMenuActive == SubMenuGroup)\n"
14710
" {\n"
14711
" MenuRect = DrawMenuGroup();\n"
14712
" }\n"
14713
" else if(SubMenuActive == SubMenuTimers)\n"
14714
" {\n"
14715
" MenuRect = DrawMenuTimer();\n"
14716
" }\n"
14717
" else if(SubMenuActive == SubMenuCounters)\n"
14718
" {\n"
14719
" MenuRect = DrawMenuCounters();\n"
14720
" }\n"
14721
" else if(SubMenuActive == SubMenuModules)\n"
14722
" {\n"
14723
" MenuRect = DrawMenuModules();\n"
14724
" }\n"
14725
" else if(SubMenuActive == SubMenuFunctions)\n"
14726
" {\n"
14727
" MenuRect = DrawMenuFunctions();\n"
14728
" }\n"
14729
" else if(SubMenuActive == SubMenuPatched)\n"
14730
" {\n"
14731
" MenuRect = DrawMenuPatched();\n"
14732
" }\n"
14733
" else if(SubMenuActive == SubMenuSettings)\n"
14734
" {\n"
14735
" MenuRect = DrawMenuSettings();\n"
14736
" }\n"
14737
" else if(SubMenuActive == SubMenuViews)\n"
14738
" {\n"
14739
" MenuRect = DrawMenuViews();\n"
14740
" }\n"
14741
" else if(SubMenuActive == SubMenuPresets)\n"
14742
" {\n"
14743
" MenuRect = DrawMenuPresets();\n"
14744
" }\n"
14745
" else if(SubMenuActive == SubMenuColumns)\n"
14746
" {\n"
14747
" MenuRect = DrawMenuColumns();\n"
14748
" }\n"
14749
" else if(SubMenuActive == SubMenuCapture)\n"
14750
" {\n"
14751
" MenuRect = DrawMenuCapture();\n"
14752
" }\n"
14753
" else if(SubMenuActive == SubMenuGraphSettings)\n"
14754
" {\n"
14755
" MenuRect = DrawMenuGraphSettings();\n"
14756
" }\n"
14757
" var Grow = 10;\n"
14758
" MenuRect.x -= Grow;\n"
14759
" MenuRect.y -= Grow;\n"
14760
" MenuRect.h += 2*Grow;\n"
14761
" MenuRect.w += 2*Grow;\n"
14762
" var MouseMoved = MouseX != SubMenuMouseX || MouseY != SubMenuMouseY;\n"
14763
"\n"
14764
" if(MouseInRect(MenuRect) || !MouseMoved)\n"
14765
" {\n"
14766
" SubMenuTimeout = new Date();\n"
14767
" SubMenuMouseX = MouseX;\n"
14768
" SubMenuMouseY = MouseY;\n"
14769
" }\n"
14770
" else\n"
14771
" {\n"
14772
" var Time = new Date() - SubMenuTimeout;\n"
14773
" var Dest = SubMenuTimeoutBase * 1000;\n"
14774
" if(Time > Dest)\n"
14775
" {\n"
14776
" EnableMenu(-1);\n"
14777
" }\n"
14778
" }\n"
14779
" if(0)//debugging of menu extents. dont delete\n"
14780
" {\n"
14781
" context.strokeStyle = \'red\';\n"
14782
" context.beginPath();\n"
14783
" context.moveTo(MenuRect.x,MenuRect.y);\n"
14784
" context.lineTo(MenuRect.x + MenuRect.w,MenuRect.y);\n"
14785
" context.lineTo(MenuRect.x + MenuRect.w,MenuRect.y+MenuRect.h);\n"
14786
" context.lineTo(MenuRect.x,MenuRect.y+MenuRect.h);\n"
14787
" context.lineTo(MenuRect.x,MenuRect.y);\n"
14788
" context.stroke();\n"
14789
" }\n"
14790
" SpinnerDraw(SpinnerShow(), context, SpinnerCorner, 0, nHeight-20, 20, 20);\n"
14791
" ProfileLeave();\n"
14792
" }\n"
14793
"}\n"
14794
"\n"
14795
"function DrawConnectionStatus()\n"
14796
"{\n"
14797
" if(WSConnected && WS && WS.readyState == 1)\n"
14798
" {\n"
14799
" if(!ProfileMode)\n"
14800
" return;\n"
14801
" }\n"
14802
" var Strings = new Array();\n"
14803
" Strings.push(\"Status\");\n"
14804
" if(WSConnected && WS && WS.readyState == 1)\n"
14805
" {\n"
14806
" Strings.push(\"[X]\");\n"
14807
" }\n"
14808
" else\n"
14809
" {\n"
14810
" ConnectionIdx = (ConnectionIdx + 1 ) % ConnectionStr.length;\n"
14811
" Strings.push(\"[\" + ConnectionStr[ConnectionIdx]+\"]\");\n"
14812
" }\n"
14813
" Strings.push(\"Port\");\n"
14814
" Strings.push(\"\" + WSPort);\n"
14815
" Strings.push(\"Path\");\n"
14816
" Strings.push(\"\" + WSPath);\n"
14817
" Strings.push(\"Sends\");\n"
14818
" Strings.push(\"\" + WSSend);\n"
14819
" Strings.push(\"Receives\");\n"
14820
" Strings.push(\"\" + WSReceive);\n"
14821
" Strings.push(\"SendBytes\");\n"
14822
" Strings.push(\"\" + WSSendBytes);\n"
14823
" Strings.push(\"ReceiveBytes\");\n"
14824
" Strings.push(\"\" + WSReceiveBytes);\n"
14825
" Strings.push(\"Seconds\");\n"
14826
" Strings.push(\"\" + WSSeconds);\n"
14827
" DrawToolTip(Strings, CanvasDetailedView, 50000, 0);\n"
14828
"}\n"
14829
"function DrawActiveToolTip()\n"
14830
"{\n"
14831
" if(SubMenuActive == -1)\n"
14832
" {\n"
14833
" if(ToolTipCallback && SubMenuActive == -1)\n"
14834
" {\n"
14835
" var Strings = ToolTipCallback(CanvasDetailedView, MouseX, MouseY);\n"
14836
" if(Strings)\n"
14837
" {\n"
14838
" DrawToolTip(Strings, CanvasDetailedView, MouseX, MouseY);\n"
14839
" }\n"
14840
" }\n"
14841
" }\n"
14842
" ToolTipCallback = null;\n"
14843
"}\n"
14844
"function UpdateSettings()\n"
14845
"{\n"
14846
" if(Settings.AutomaticReference)\n"
14847
" {\n"
14848
" if( Math.abs(ReferenceGraph - ReferenceGraphAutomatic) > 0.02 ||\n"
14849
" Math.abs(ReferenceHistory - ReferenceHistoryAutomatic) > 0.02)\n"
14850
" {\n"
14851
" RequestDraw();\n"
14852
" }\n"
14853
" ReferenceGraph = 0.9 * ReferenceGraph + 0.1 * ReferenceGraphAutomatic;\n"
14854
" ReferenceHistory = 0.9 * ReferenceHistory + 0.1 * ReferenceHistoryAutomatic;\n"
14855
" ReferenceBar = 0.9 * ReferenceBar + 0.1 * ReferenceBarAutomatic;\n"
14856
" var TimerMap = FrameData.TimerMap;\n"
14857
" if(!TimerMap)\n"
14858
" return;\n"
14859
"\n"
14860
"\n"
14861
" for(var key in TimerMap)\n"
14862
" {\n"
14863
" var TimerState = TimerMap[key];\n"
14864
" if(!TimerState.historymaxsoft)\n"
14865
" {\n"
14866
" TimerState.historymaxsoft = TimerState.historymax;\n"
14867
" }\n"
14868
" else\n"
14869
" {\n"
14870
" TimerState.historymaxsoft = 0.9 * TimerState.historymaxsoft + 0.1 * TimerState.historymax;\n"
14871
" }\n"
14872
" }\n"
14873
"\n"
14874
" }\n"
14875
" else\n"
14876
" {\n"
14877
" ReferenceGraph = Settings.ReferenceTime;\n"
14878
" ReferenceHistory = Settings.ReferenceTime;\n"
14879
" ReferenceBar = Settings.ReferenceTime;\n"
14880
" }\n"
14881
" if(Settings.AggregateFrames != AggregateFrames)\n"
14882
" {\n"
14883
" WSSendMessage(\"a\" + Settings.AggregateFrames);\n"
14884
" AggregateFrames = Settings.AggregateFrames;\n"
14885
" }\n"
14886
"}\n"
14887
"\n"
14888
"var PendingDraw = 0;\n"
14889
"\n"
14890
"function Draw()\n"
14891
"{\n"
14892
" CaptureUpdate();\n"
14893
" PendingDraw = 0;\n"
14894
" ProfileEnter(\"Total\");\n"
14895
"\n"
14896
" UpdateSettings();\n"
14897
"\n"
14898
" if(WSConnected && WS && WS.readyState == 1)\n"
14899
" {\n"
14900
" DrawViews();\n"
14901
" DrawMessage();\n"
14902
" DrawMenu();\n"
14903
" }\n"
14904
" else\n"
14905
" {\n"
14906
" var context = CanvasDetailedView.getContext(\'2d\');\n"
14907
" context.clearRect(0, 0, nWidth, nHeight);\n"
14908
" DrawMessage();\n"
14909
" }\n"
14910
"\n"
14911
" DrawConnectionStatus();\n"
14912
" DrawPlotf(CanvasDetailedView);\n"
14913
" DrawActiveToolTip();\n"
14914
"\n"
14915
"\n"
14916
" ProfileLeave();\n"
14917
" ProfileModeDraw(CanvasDetailedView);\n"
14918
" ProfileModeClear();\n"
14919
"\n"
14920
"\n"
14921
" PlotfClear();\n"
14922
"\n"
14923
" MouseReleased = false;\n"
14924
"}\n"
14925
"function RequestDraw()\n"
14926
"{\n"
14927
" if(!PendingDraw)\n"
14928
" {\n"
14929
" PendingDraw = 1;\n"
14930
" requestAnimationFrame(Draw);\n"
14931
" }\n"
14932
"}\n"
14933
"\n"
14934
"\n"
14935
"\n"
14936
"\n"
14937
"function WSOpen(event)\n"
14938
"{\n"
14939
" SetMessage(\"Connected!\", 1000);\n"
14940
" WSSend = 0;\n"
14941
" WSReceive = 0;\n"
14942
" WSSendBytes = 0;\n"
14943
" WSReceiveBytes = 0;\n"
14944
" WSIsOpen = 1;\n"
14945
"\n"
14946
" Empty = {\"id\":0, \"w\":0, \"depth\":0, \"sibling\":-1,\"parent\":-1,\"firstchild\":-1};\n"
14947
" TimerArray = [];\n"
14948
" TimerArray.push(Empty);\n"
14949
" WidthArray = [];\n"
14950
" CounterArray = [];\n"
14951
" WidthArray[TYPE_NONE] = 0;\n"
14952
" WidthArray[TYPE_TIMER] = 0;\n"
14953
" WidthArray[TYPE_GROUP] = 0;\n"
14954
" WidthArray[TYPE_CATEGORY] = 0;\n"
14955
" WidthArray[TYPE_COUNTER] = 0;\n"
14956
" WidthTree = FontWidth;\n"
14957
" SymbolState = null;\n"
14958
" FunctionQueryPending = 0;\n"
14959
" FunctionQueryReceived = 0;\n"
14960
" FunctionQueryLastRequest = 0;\n"
14961
" FunctionsInstrumented = [];\n"
14962
" FunctionsInstrumentedModule = [];\n"
14963
" FunctionsInstrumentedUnmangled = [];\n"
14964
"\n"
14965
" FilterInputTimersValue = \"\";\n"
14966
" FilterInputGroupsValue = \"\";\n"
14967
" FilterInputFunctionsValue = \"\";\n"
14968
" FilterInput.value = \"\";\n"
14969
" FunctionQueryArray = [];\n"
14970
" ModuleState = [];\n"
14971
"\n"
14972
" ResetFrameData();\n"
14973
" window.document.title = \"MP:\" + WSHost;\n"
14974
"\n"
14975
" if(PresetToLoad && PresetToLoad != \"\")\n"
14976
" {\n"
14977
" LoadPreset(PresetToLoad, PresetToLoadRO);\n"
14978
" }\n"
14979
" ViewCompressedTimeout = 5000.0;\n"
14980
"}\n"
14981
"\n"
14982
"function SplitIdTop(v)\n"
14983
"{\n"
14984
" return v >> 24; // todo: verify\n"
14985
"}\n"
14986
"\n"
14987
"function SplitIdBottom(v)\n"
14988
"{\n"
14989
" return v & 0xffffff; // todo: verify\n"
14990
"}\n"
14991
"\n"
14992
"function GetTimer(id)\n"
14993
"{\n"
14994
" for(var i = 0; i < TimerArray.length; ++i)\n"
14995
" {\n"
14996
" if(TimerArray[i].id == id)\n"
14997
" {\n"
14998
" return i;\n"
14999
" }\n"
15000
" }\n"
15001
" return null;\n"
15002
"}\n"
15003
"function GetTimerFromFullName(Name)\n"
15004
"{\n"
15005
" for(let i = 0; i < TimerArray.length; ++i)\n"
15006
" {\n"
15007
" if(GetFullName(TimerArray[i]) == Name)\n"
15008
" {\n"
15009
" return i;\n"
15010
" }\n"
15011
" }\n"
15012
" return null;\n"
15013
"}\n"
15014
"\n"
15015
"\n"
15016
"function InitCounterName(T)\n"
15017
"{\n"
15018
" if(T.countername)\n"
15019
" return T.countername;\n"
15020
" let name = \"/\" + T.name;\n"
15021
" if(T.parent)\n"
15022
" name = InitCounterName(TimerArray[T.parent]) + name;\n"
15023
" T.countername = name;\n"
15024
" return name;\n"
15025
"}\n"
15026
"\n"
15027
"\n"
15028
"\n"
15029
"function IsGroup(id)\n"
15030
"{\n"
15031
" var idx = GetTimer(id);\n"
15032
" return TimerArray[idx].idtype == TYPE_GROUP;\n"
15033
"}\n"
15034
"\n"
15035
"function UpdateActive()\n"
15036
"{\n"
15037
" GroupsEnabled = 0;\n"
15038
" TimersEnabled = 0;\n"
15039
" CountersEnabled = 0;\n"
15040
" for(var i = 0; i < TimerArray.length; ++i)\n"
15041
" {\n"
15042
" var T = TimerArray[i];\n"
15043
" if(T.e)\n"
15044
" {\n"
15045
" switch(T.idtype)\n"
15046
" {\n"
15047
" case TYPE_GROUP:\n"
15048
" GroupsEnabled++;\n"
15049
" break;\n"
15050
" case TYPE_TIMER:\n"
15051
" TimersEnabled++;\n"
15052
" case TYPE_COUNTER:\n"
15053
" TimersEnabled++;\n"
15054
" break;\n"
15055
" }\n"
15056
" }\n"
15057
" }\n"
15058
"}\n"
15059
"function UpdateEnabledTimer(idx)\n"
15060
"{\n"
15061
" UpdateActive();\n"
15062
" var type = TimerArray[idx].idtype;\n"
15063
" var enabled = TimerArray[idx].e;\n"
15064
" if(TimerArray[idx].idtype != TYPE_TIMER)\n"
15065
" {\n"
15066
" return;\n"
15067
" }\n"
15068
" var AutoCaptureSourceValue = null;\n"
15069
" if(AutoCaptureSourceIndex >= 0 && AutoCaptureSourceIndex < EnabledArray.length)\n"
15070
" {\n"
15071
" AutoCaptureSourceValue = EnabledArray[AutoCaptureSourceIndex];\n"
15072
" }\n"
15073
"\n"
15074
" var i = EnabledArray.indexOf(idx);\n"
15075
" if(enabled)\n"
15076
" {\n"
15077
" if(i == -1)\n"
15078
" {\n"
15079
" EnabledArray.unshift(idx);\n"
15080
" }\n"
15081
" }\n"
15082
" else\n"
15083
" {\n"
15084
" if(i != -1)\n"
15085
" {\n"
15086
" EnabledArray.splice(i, 1);\n"
15087
" }\n"
15088
" }\n"
15089
" var NewIndex = AutoCaptureSourceValue != null ? EnabledArray.indexOf(AutoCaptureSourceValue) : -1;\n"
15090
" AutoCaptureSourceIndex = NewIndex;\n"
15091
"}\n"
15092
"\n"
15093
"function EnableTimer(T)\n"
15094
"{\n"
15095
" let idx = GetTimer(T.id);\n"
15096
" if(idx != null && idx >= 0)\n"
15097
" {\n"
15098
" TimerArray[idx].e = T.e;\n"
15099
" UpdateEnabledTimer(idx);\n"
15100
" }\n"
15101
" else\n"
15102
" {\n"
15103
" console.log(\'EnableTimer: unknown enable message\');\n"
15104
" }\n"
15105
"}\n"
15106
"\n"
15107
"function MeasureWidth(str)\n"
15108
"{\n"
15109
" let context = CanvasDetailedView.getContext(\'2d\');\n"
15110
" context.font = Font;\n"
15111
" return context.measureText(str).width;\n"
15112
"}\n"
15113
"function AddTimer(T)\n"
15114
"{\n"
15115
" if(!T.color || T.color == \"\")\n"
15116
" {\n"
15117
" T.color = ColorFromString(T.name, 40, 50);\n"
15118
" }\n"
15119
" console.log(\"Added timer\", T.name);\n"
15120
" let idx = TimerArray.length;\n"
15121
" let existing = GetTimer(T.id);\n"
15122
" let Parent;\n"
15123
" if(existing)\n"
15124
" {\n"
15125
" idx = existing;\n"
15126
" }\n"
15127
" else\n"
15128
" {\n"
15129
" TimerArray[idx] = T;\n"
15130
" }\n"
15131
" TimerArray[idx].time = 0;\n"
15132
" TimerArray[idx].excl = 0;\n"
15133
" TimerArray[idx].average = 0;\n"
15134
" TimerArray[idx].max = 0;\n"
15135
" TimerArray[idx].min = 0;\n"
15136
" TimerArray[idx].total = 0;\n"
15137
" TimerArray[idx].exclaverage = 0;\n"
15138
" TimerArray[idx].exclmax = 0;\n"
15139
" TimerArray[idx].excltotal = 0;\n"
15140
" TimerArray[idx].spike = 0;\n"
15141
" TimerArray[idx].callaverage = 0;\n"
15142
" TimerArray[idx].callexclaverage = 0;\n"
15143
" TimerArray[idx].callcount = 0;\n"
15144
" let w = MeasureWidth(T.name);\n"
15145
" let idtype = SplitIdTop(T.id);\n"
15146
" let idelement = SplitIdBottom(T.id);\n"
15147
" TimerArray[idx].idtype = idtype;\n"
15148
" TimerArray[idx].idelement = idelement;\n"
15149
" TimerArray[idx].w = w;\n"
15150
" TimerArray[idx].wtree = w;\n"
15151
" TimerArray[idx].timertype = T.type;\n"
15152
" if(!existing)\n"
15153
" {\n"
15154
" TimerArray[idx].sibling = -1;\n"
15155
" TimerArray[idx].parent = -1;\n"
15156
" TimerArray[idx].firstchild = -1;\n"
15157
" }\n"
15158
" if(w > WidthArray[idtype])\n"
15159
" {\n"
15160
" WidthArray[idtype] = w;\n"
15161
" }\n"
15162
" UpdateEnabledTimer(idx);\n"
15163
" let wparent = 0;\n"
15164
" let pidx = GetTimer(T.pid);\n"
15165
" if(pidx >= 0 && !existing)\n"
15166
" {\n"
15167
" TimerArray[idx].parent = pidx;\n"
15168
" Parent = TimerArray[pidx];\n"
15169
" let Sibling = Parent.firstchild;\n"
15170
" wparent = MeasureWidth(Parent.name);\n"
15171
" Parent.firstchild = idx;\n"
15172
" if(Sibling != -1)\n"
15173
" {\n"
15174
" if(TimerArray[Sibling].sibling == idx)\n"
15175
" {\n"
15176
" debugger;\n"
15177
" }\n"
15178
" }\n"
15179
" TimerArray[idx].sibling = Sibling;\n"
15180
" TimerArray[idx].wtree += Parent.depth * FontWidth;\n"
15181
" TimerArray[idx].depth = Parent.depth + 1;\n"
15182
" if(TimerArray[idx].wtree > WidthTree)\n"
15183
" {\n"
15184
" WidthTree = TimerArray[idx].wtree;\n"
15185
" }\n"
15186
" TimerArray[idx].sortkey = Parent.name + \" __ \" + T.name;\n"
15187
" }\n"
15188
" else\n"
15189
" {\n"
15190
" TimerArray[idx].sortkey = T.name;\n"
15191
" }\n"
15192
" TimerArray[idx].wparent = wparent;\n"
15193
" TimerArray[idx].wtotal = wparent + w;\n"
15194
"\n"
15195
" if(idtype == TYPE_COUNTER)\n"
15196
" {\n"
15197
" if(idelement != CounterArray.length)\n"
15198
" {\n"
15199
" debugger;\n"
15200
" }\n"
15201
" InitCounterName(TimerArray[idx]);\n"
15202
" let w = MeasureWidth(T.countername);\n"
15203
" if(w > WidthArray[idtype])\n"
15204
" {\n"
15205
" WidthArray[idtype] = w;\n"
15206
" }\n"
15207
"\n"
15208
"\n"
15209
" CounterArray.push(idx);\n"
15210
" TimerArray[idx].formattedlimit = FormatCounter(TimerArray[idx].format, TimerArray[idx].limit);\n"
15211
" CounterLimitWidth = Math.max(CounterLimitWidth, TimerArray[idx].formattedlimit.length * (FontWidth+1));\n"
15212
" CounterNameWidth = Math.max(CounterNameWidth, (TimerArray[idx].name.length + 1 + TimerArray[idx].depth) * (FontWidth+1));\n"
15213
" CounterNameMenuWidth = Math.max(CounterNameMenuWidth, (TimerArray[idx].name.length + 1 + (2*TimerArray[idx].depth)) * (FontWidth));\n"
15214
" CounterFullNameWidth = Math.max(CounterFullNameWidth, (TimerArray[idx].countername.length + 1) * (FontWidth));\n"
15215
" TimerArray[idx].counterhistory = {};\n"
15216
" TimerArray[idx].counterhistory.history = AllocClearedArray(120);\n"
15217
" TimerArray[idx].counterhistory.prc = AllocClearedArray(120);\n"
15218
" }\n"
15219
" if(idtype == TYPE_TIMER)\n"
15220
" {\n"
15221
" if(T.color == \"#000000\")\n"
15222
" {\n"
15223
" T.color = ColorFromString(T.name + \"x\" + Parent.name, 40, 50);\n"
15224
" }\n"
15225
"\n"
15226
" }\n"
15227
" RequestDraw();\n"
15228
"}\n"
15229
"\n"
15230
"function AllocClearedArray(Size)\n"
15231
"{\n"
15232
" let A = new Array(Size);\n"
15233
" for(let i = 0; i < Size; ++i)\n"
15234
" {\n"
15235
" A[i] = 0;\n"
15236
" }\n"
15237
" return A;\n"
15238
"}\n"
15239
"function PushIntoArray(A, v)\n"
15240
"{\n"
15241
" A.shift();\n"
15242
" A.push(v);\n"
15243
"}\n"
15244
"function ResetFrameData()\n"
15245
"{\n"
15246
" FrameData = {};\n"
15247
" FrameData.TimerMap = {};\n"
15248
" FrameData.Time = AllocClearedArray(FRAME_COUNT);\n"
15249
" FrameData.TimeSoft = AllocClearedArray(FRAME_COUNT);\n"
15250
" FrameData.Ids = AllocClearedArray(FRAME_COUNT);\n"
15251
" FrameData.Frozen = AllocClearedArray(FRAME_COUNT);\n"
15252
" FrameData.ThreadTime = {};\n"
15253
"}\n"
15254
"function GetFrameData(id)\n"
15255
"{\n"
15256
" if(FrameData.TimerMap[id])\n"
15257
" {\n"
15258
" return FrameData.TimerMap[id];\n"
15259
" }\n"
15260
" else\n"
15261
" {\n"
15262
" var FD = {};\n"
15263
" FD.Count = AllocClearedArray(FRAME_COUNT);\n"
15264
" FD.Time = AllocClearedArray(FRAME_COUNT);\n"
15265
" FD.TimeSoft = AllocClearedArray(FRAME_COUNT);\n"
15266
" FD.TimeExcl = AllocClearedArray(FRAME_COUNT);\n"
15267
" FD.TimeMax = AllocClearedArray(AggregateHistorySize);\n"
15268
" FD.TimeMin = AllocClearedArray(AggregateHistorySize);\n"
15269
" FD.TimeAvg = AllocClearedArray(AggregateHistorySize);\n"
15270
" FD.TimeExclMax = AllocClearedArray(AggregateHistorySize);\n"
15271
" FD.TimeExclMin = AllocClearedArray(AggregateHistorySize);\n"
15272
" FD.TimeExclAvg = AllocClearedArray(AggregateHistorySize);\n"
15273
" FD.TimeCallAvg = AllocClearedArray(AggregateHistorySize);\n"
15274
" FD.TimeCallExclAvg = AllocClearedArray(AggregateHistorySize);\n"
15275
" FD.TimeTotal = AllocClearedArray(AggregateHistorySize);\n"
15276
" FD.TimeExclTotal = AllocClearedArray(AggregateHistorySize);\n"
15277
" FD.CallCount = AllocClearedArray(AggregateHistorySize);\n"
15278
" FD.Percentile = new Float32Array(PERCENTILE_SAMPLES);\n"
15279
" FD.Percentile.fill(0.0);\n"
15280
" FD.PercentileMax = -1e38;\n"
15281
" FD.PercentileMin = 1e38;\n"
15282
" FD.PercentileCount = 0;\n"
15283
" FD.EmptyFrames = 0;\n"
15284
"\n"
15285
"\n"
15286
" FD.AggregateFrames = 0;\n"
15287
" FD.FrameTime = 0.0;\n"
15288
" FD.Aggregate = 0;\n"
15289
" FD.AggregateTime = 0.0;\n"
15290
" FD.AggregateSum = 0;\n"
15291
" FD.AggregateMax = 0;\n"
15292
" FD.AggregateMin = C_HUGE;\n"
15293
" FD.AggregateExclSum = 0;\n"
15294
" FD.AggregateExclMax = 0;\n"
15295
" FD.AggregateCount = 0;\n"
15296
" FD.AggregateExclMin = C_HUGE;\n"
15297
"\n"
15298
"\n"
15299
"\n"
15300
" FrameData.TimerMap[id] = FD;\n"
15301
" return FD;\n"
15302
" }\n"
15303
"}\n"
15304
"\n"
15305
"function ProcessCounters(C)\n"
15306
"{\n"
15307
" for(var i = 0; i < CounterArray.length; ++i)\n"
15308
" {\n"
15309
" if(i > C.length)\n"
15310
" {\n"
15311
" debugger;\n"
15312
" }\n"
15313
" var idx = CounterArray[i];\n"
15314
" var value = C[i];\n"
15315
" var T = TimerArray[idx];\n"
15316
" T.value = value;\n"
15317
" if(T.minvalue == undefined)\n"
15318
" T.minvalue = value;\n"
15319
" else\n"
15320
" T.minvalue = Math.min(T.minvalue, value);\n"
15321
" if(T.maxvalue == undefined)\n"
15322
" T.maxvalue = value;\n"
15323
" else\n"
15324
" T.maxvalue = Math.max(T.maxvalue, value);\n"
15325
" T.formatted = FormatCounter(T.format, value);\n"
15326
" var boxprc = 1.0;\n"
15327
" var counterprc = 0;\n"
15328
" if(T.limit)\n"
15329
" {\n"
15330
" counterprc = value / T.limit;\n"
15331
" if(counterprc > 1.0)\n"
15332
" {\n"
15333
" boxprc = 1.0 / counterprc;\n"
15334
" counterprc = 1.0;\n"
15335
" }\n"
15336
" counterprc = Math.max(counterprc, 0.0);\n"
15337
"\n"
15338
" }\n"
15339
" T.boxprc = boxprc;\n"
15340
" T.counterprc = counterprc;\n"
15341
" PushIntoArray(T.counterhistory.history, value);\n"
15342
" var prc = T.maxvalue > T.minvalue ? (value - T.minvalue) / (T.maxvalue - T.minvalue) : 0.0;\n"
15343
" PushIntoArray(T.counterhistory.prc, prc);\n"
15344
" CounterValueWidth = Math.max(CounterValueWidth, T.formatted.length * (FontWidth+1));\n"
15345
" }\n"
15346
"\n"
15347
"}\n"
15348
"\n"
15349
"\n"
15350
"function ProcessFrame(F, Inactive)\n"
15351
"{\n"
15352
" ProfileEnter(\"ProcessFrame\");\n"
15353
" if(F.s)\n"
15354
" {\n"
15355
" if(F.s.l == F.s.r)\n"
15356
" {\n"
15357
" if(FunctionQueryPending)\n"
15358
" {\n"
15359
" var Req = ++FunctionQueryLastRequest;\n"
15360
" var Q = \"q\" + Req + \"x\" + FunctionQueryPending;\n"
15361
" WSSendMessage(Q);\n"
15362
" FunctionQueryPending = null;\n"
15363
" }\n"
15364
" }\n"
15365
" SymbolState = F.s;\n"
15366
" if(F.M)\n"
15367
" {\n"
15368
" ModuleState = F.M;\n"
15369
" }\n"
15370
" MenuItems[SubMenuFunctions].visible = function(){return true;};\n"
15371
" MenuItems[SubMenuModules].visible = function(){return true;};\n"
15372
" }\n"
15373
" else\n"
15374
" {\n"
15375
" MenuItems[SubMenuFunctions].visible = function(){return false;};\n"
15376
" MenuItems[SubMenuModules].visible = function(){return false;};\n"
15377
" }\n"
15378
" if(F.fr)\n"
15379
" {\n"
15380
" IsFrozen = 10;//allow it to stabilize after freezing\n"
15381
" ProfileLeave();\n"
15382
" return;\n"
15383
" }\n"
15384
" if(IsFrozen)\n"
15385
" {\n"
15386
" IsFrozen--;\n"
15387
" }\n"
15388
" if(!Inactive)\n"
15389
" {\n"
15390
" var TriggerAutoCapture = 0;\n"
15391
" PushIntoArray(FrameData.Time, F.t);\n"
15392
" PushIntoArray(FrameData.Ids, F.f);\n"
15393
" PushIntoArray(FrameData.Frozen, IsFrozen ? 1 : 0);\n"
15394
" var CaptureId = null;\n"
15395
" var AutoCapture = AutoCaptureEnabled && !IsFrozen;\n"
15396
" AggregateCurrent = F.a;\n"
15397
" if(F.m != Settings.ViewActive)\n"
15398
" {\n"
15399
" WSSendMessage(\"v\" + Settings.ViewActive);\n"
15400
" }\n"
15401
" if(AutoCapture > 0 && null == CaptureTriggerTime && AutoCaptureCooldown < 0)\n"
15402
" {\n"
15403
" if(AutoCaptureSourceIndex == -1 && F.t > Settings.AutoCaptureTheshold)\n"
15404
" {\n"
15405
" AutoCaptureEnabled -= 1;\n"
15406
" TriggerAutoCapture = 1;\n"
15407
" }\n"
15408
" else if(AutoCaptureSourceIndex >= 0 && AutoCaptureSourceIndex < EnabledArray.length)\n"
15409
" {\n"
15410
" var id = TimerArray[EnabledArray[AutoCaptureSourceIndex]].id;\n"
15411
" var Data = F.x[id];\n"
15412
" if(Data && Data[0])\n"
15413
" {\n"
15414
" if(Data[0] > Settings.AutoCaptureTheshold)\n"
15415
" {\n"
15416
" TriggerAutoCapture = 1;\n"
15417
" AutoCaptureEnabled -= 1;\n"
15418
" console.log(\'trigger capture! \', Data[0], \' \', Settings.AutoCaptureTheshold);\n"
15419
" }\n"
15420
" }\n"
15421
" }\n"
15422
" }\n"
15423
" AutoCaptureCooldown = AutoCaptureCooldown - 1;\n"
15424
"\n"
15425
" var GraphTimeMax = 0;\n"
15426
" var GraphTimeGroupMax = 0;\n"
15427
" var HistoryTimeMax = 0;\n"
15428
"\n"
15429
" for(var i = 0; i < FrameData.Time.length; ++i)\n"
15430
" {\n"
15431
" if(0 == FrameData.Frozen[i])\n"
15432
" {\n"
15433
" HistoryTimeMax = HistoryTimeMax > FrameData.Time[i] ? HistoryTimeMax : FrameData.Time[i];\n"
15434
" }\n"
15435
" }\n"
15436
" var FindMaxTime = function(A, bIsGroup)\n"
15437
" {\n"
15438
" var MaxTime = 0;\n"
15439
" for(var i = 0; i < A.length; ++i)\n"
15440
" {\n"
15441
" if(0 == FrameData.Frozen[i])\n"
15442
" {\n"
15443
" MaxTime = MaxTime > A[i] ? MaxTime : A[i];\n"
15444
" }\n"
15445
" }\n"
15446
" if(bIsGroup)\n"
15447
" GraphTimeGroupMax = MaxTime > GraphTimeGroupMax ? MaxTime : GraphTimeGroupMax;\n"
15448
" else\n"
15449
" GraphTimeMax = MaxTime > GraphTimeMax ? MaxTime : GraphTimeMax;\n"
15450
" return MaxTime;\n"
15451
" };\n"
15452
" function SetAggregateTimersInArray(FD, id)\n"
15453
" {\n"
15454
" var idx = GetTimer(id);\n"
15455
" var Pos = AggregateHistorySize-1;\n"
15456
" var T = TimerArray[idx];\n"
15457
"\n"
15458
" T.max = FD.TimeMax[Pos];\n"
15459
" T.total = FD.TimeTotal[Pos];\n"
15460
" T.excltotal = FD.TimeExclTotal[Pos];\n"
15461
" T.min = FD.TimeMin[Pos];\n"
15462
" T.spike = (T.average == 0 || T.max == 0) ? 0 : (100*T.max/T.average);\n"
15463
" T.callaverage = FD.TimeCallAvg[Pos];\n"
15464
" T.callcount = FD.CallCount[Pos];\n"
15465
" T.callexclaverage = FD.TimeCallExclAvg[Pos];\n"
15466
" T.exclaverage = FD.TimeExclAvg[Pos];\n"
15467
" T.exclmax = FD.TimeExclMax[Pos];\n"
15468
" T.exclmin = FD.TimeExclMin[Pos];\n"
15469
" T.average = FD.TimeAvg[Pos];\n"
15470
" };\n"
15471
" function SetTimersInArray(FD, id)\n"
15472
" {\n"
15473
" var idx = GetTimer(id);\n"
15474
" var Pos = FD.Time.length-1;\n"
15475
" var T = TimerArray[idx];\n"
15476
" T.time = FD.Time[Pos];\n"
15477
" T.excl = FD.TimeExcl[Pos];\n"
15478
" T.count = FD.Count[Pos];\n"
15479
"\n"
15480
" };\n"
15481
"\n"
15482
" let UpdateFrameDataInternal = function(id, Time, TimeExcl, Count, bIsGroup)\n"
15483
" {\n"
15484
"\n"
15485
" let FD = GetFrameData(id);\n"
15486
" if(!IsFrozen)\n"
15487
" {\n"
15488
" ProfileEnter(\"PercentileAccum\");\n"
15489
" FD.PercentileMax = Math.max(FD.PercentileMax, Time);\n"
15490
" FD.PercentileMin = Math.min(FD.PercentileMin, Time);\n"
15491
" FD.PercentileCount += 1;\n"
15492
" if(Time > FD.Percentile[0])\n"
15493
" {\n"
15494
" FD.Percentile[0] = Time;\n"
15495
" FD.Percentile.sort( function(a,b){return a - b;} );\n"
15496
" }\n"
15497
" ProfileLeave();\n"
15498
" }\n"
15499
" PushIntoArray(FD.Time, Time);\n"
15500
" let beg = Math.max(0, FD.Time.length - Settings.GraphSoftFrames);\n"
15501
" let end = FD.Time.length-1;\n"
15502
" let mod = Settings.GraphSoftMode;\n"
15503
" let soft = 0.0;\n"
15504
" if(mod == 1)\n"
15505
" {\n"
15506
" for(let i = beg; i < end; ++i)\n"
15507
" soft += FD.Time[i];\n"
15508
" if(beg != end)\n"
15509
" soft /= (end-beg);\n"
15510
" }\n"
15511
" else if(mod == 2)\n"
15512
" {\n"
15513
" soft = 1e38;\n"
15514
" for(let i = beg; i < end; ++i)\n"
15515
" soft = Math.min(FD.Time[i], soft);\n"
15516
" }\n"
15517
" else if(mod == 3)\n"
15518
" {\n"
15519
" for(let i = beg; i < end; ++i)\n"
15520
" soft = Math.max(FD.Time[i], soft);\n"
15521
" }\n"
15522
" PushIntoArray(FD.TimeSoft, soft);\n"
15523
" PushIntoArray(FD.TimeExcl, TimeExcl);\n"
15524
" PushIntoArray(FD.Count, Count);\n"
15525
" FD.historymax = FindMaxTime(FD.Time, bIsGroup);\n"
15526
"\n"
15527
" if((FD.Aggregate > Settings.AggregateFrames && Settings.AggregateFrames > 0) || AggregateCurrent == 0)\n"
15528
" {\n"
15529
" SetAggregateTimersInArray(FD, id);\n"
15530
" FD.Aggregate = 0;\n"
15531
" FD.AggregateSum = 0;\n"
15532
" FD.AggregateMax = 0;\n"
15533
" FD.AggregateMin = C_HUGE;\n"
15534
" FD.AggregateExclSum = 0;\n"
15535
" FD.AggregateExclMax = 0;\n"
15536
" FD.AggregateExclMin = C_HUGE;\n"
15537
" FD.AggregateCount = 0;\n"
15538
"\n"
15539
" FD.TimeMax.shift();\n"
15540
" FD.TimeMax.push(0);\n"
15541
"\n"
15542
" FD.TimeMin.shift();\n"
15543
" FD.TimeMin.push(0);\n"
15544
"\n"
15545
" FD.TimeAvg.shift();\n"
15546
" FD.TimeAvg.push(0);\n"
15547
"\n"
15548
" FD.TimeCallAvg.shift();\n"
15549
" FD.TimeCallAvg.push(0);\n"
15550
"\n"
15551
" FD.TimeCallExclAvg.shift();\n"
15552
" FD.TimeCallExclAvg.push(0);\n"
15553
"\n"
15554
" FD.CallCount.shift();\n"
15555
" FD.CallCount.push(0);\n"
15556
"\n"
15557
" FD.TimeTotal.shift();\n"
15558
" FD.TimeTotal.push(0);\n"
15559
"\n"
15560
" FD.TimeExclTotal.shift();\n"
15561
" FD.TimeExclTotal.push(0);\n"
15562
"\n"
15563
" FD.TimeExclMax.shift();\n"
15564
" FD.TimeExclMax.push(0);\n"
15565
"\n"
15566
" FD.TimeExclMin.shift();\n"
15567
" FD.TimeExclMin.push(0);\n"
15568
"\n"
15569
" FD.TimeExclAvg.shift();\n"
15570
" FD.TimeExclAvg.push(0);\n"
15571
" }\n"
15572
"\n"
15573
" FD.Aggregate += 1;\n"
15574
" FD.AggregateSum += Time;\n"
15575
" FD.AggregateMax = FD.AggregateMax > Time ? FD.AggregateMax : Time;\n"
15576
" FD.AggregateMin = FD.AggregateMin < Time ? FD.AggregateMin : Time;\n"
15577
" FD.AggregateExclSum += TimeExcl;\n"
15578
" FD.AggregateExclMax = FD.AggregateExclMax > TimeExcl ? FD.AggregateExclMax : TimeExcl;\n"
15579
" FD.AggregateExclMin = FD.AggregateExclMin < TimeExcl ? FD.AggregateExclMin : TimeExcl;\n"
15580
" FD.AggregateCount += Count;\n"
15581
" var UpdatePos = AggregateHistorySize-1;\n"
15582
" if(UpdatePos != FD.TimeMax.length - 1)\n"
15583
" {\n"
15584
" debugger;\n"
15585
" }\n"
15586
"\n"
15587
" FD.TimeMax[UpdatePos] = FD.AggregateMax;\n"
15588
" FD.TimeMin[UpdatePos] = FD.AggregateMin;\n"
15589
" FD.TimeAvg[UpdatePos] = FD.AggregateSum / FD.Aggregate;\n"
15590
" FD.TimeCallAvg[UpdatePos] = FD.AggregateCount ? FD.AggregateSum / FD.AggregateCount : 0;\n"
15591
" FD.TimeCallExclAvg[UpdatePos] = FD.AggregateCount ? FD.AggregateExclSum / FD.AggregateCount : 0;\n"
15592
" FD.TimeTotal[UpdatePos] = FD.AggregateSum;\n"
15593
" FD.TimeExclTotal[UpdatePos] = FD.AggregateExclSum;\n"
15594
" FD.CallCount[UpdatePos] = FD.AggregateCount;\n"
15595
" FD.TimeExclAvg[UpdatePos] = FD.Aggregate ? FD.AggregateExclSum / FD.Aggregate : 0;\n"
15596
" FD.TimeExclMax[UpdatePos] = FD.AggregateExclMax;\n"
15597
" FD.TimeExclMin[UpdatePos] = FD.AggregateExclMin;\n"
15598
"\n"
15599
" if(Settings.AggregateFrames <= 0)\n"
15600
" {\n"
15601
" SetAggregateTimersInArray(FD, id);\n"
15602
" }\n"
15603
" SetTimersInArray(FD, id);\n"
15604
" };\n"
15605
" \n"
15606
"\n"
15607
" let TimerFrameData = F.x.t;\n"
15608
" for(var id in TimerFrameData)\n"
15609
" {\n"
15610
" var Data = TimerFrameData[id];\n"
15611
" var Time = Data[0];\n"
15612
" var TimeExcl = Data[1];\n"
15613
" var Count = Data[2];\n"
15614
" UpdateFrameDataInternal(id, Data[0], Data[1], Data[2]);\n"
15615
" }\n"
15616
"\n"
15617
" let CounterFrameData = F.x.c;\n"
15618
" for(let id in CounterFrameData)\n"
15619
" {\n"
15620
" let Value = CounterFrameData[id];\n"
15621
" UpdateFrameDataInternal(id, Value, 0, 0); //UpdateCounterDataInternal(id, Value);\n"
15622
" }\n"
15623
" var groups = {};\n"
15624
" for(var i = 0; i < F.g.length; ++i)\n"
15625
" {\n"
15626
" var id = F.gi[i];\n"
15627
" groups[id] = 1;\n"
15628
" var t = F.g[i];\n"
15629
" UpdateFrameDataInternal(id, t[0], t[1], t[2], 1);\n"
15630
" }\n"
15631
"\n"
15632
" let UpdateThreadInfo = function(o)\n"
15633
" {\n"
15634
" let sn = SanitizeString(o.n);\n"
15635
" let TI = ThreadInfo[sn];\n"
15636
" if(!TI)\n"
15637
" {\n"
15638
" TI = { ids:o.gi, a:[], n:o.n, sn:sn };\n"
15639
" for(let i = 0; i < TI.ids.length; ++i)\n"
15640
" {\n"
15641
" TI.a.push(AllocClearedArray(FRAME_COUNT));\n"
15642
" }\n"
15643
" ThreadInfo[sn] = TI;\n"
15644
" }\n"
15645
" for(let i = 0; i < o.gi.length; ++i)\n"
15646
" {\n"
15647
" let id = o.gi[i];\n"
15648
" let t = o.g[i][1];\n"
15649
" let te = FrameData.Time[FrameData.Time.length-1];\n"
15650
" if(t > te)\n"
15651
" {\n"
15652
" console.log(\"fail!\");\n"
15653
" // debugger;\n"
15654
" }\n"
15655
" let idx = TI.ids.indexOf(id);\n"
15656
" if(-1 == idx)\n"
15657
" {\n"
15658
" TI.ids.push(id);\n"
15659
" let a = AllocClearedArray(FRAME_COUNT);\n"
15660
" a[a.length-1] = o.g[i][1];\n"
15661
" TI.a.push(a);\n"
15662
" }\n"
15663
" else\n"
15664
" {\n"
15665
" let l = TI.a[idx].length;\n"
15666
" TI.a[idx][l-1] = o.g[i][1];\n"
15667
" }\n"
15668
" }\n"
15669
" };\n"
15670
" if(F.gt && F.gt.length)\n"
15671
" {\n"
15672
" for(let key in ThreadInfo)\n"
15673
" {\n"
15674
" let TI = ThreadInfo[key];\n"
15675
" for(let i = 0; i < TI.a.length; ++i)\n"
15676
" {\n"
15677
" PushIntoArray(TI.a[i], 0);\n"
15678
" }\n"
15679
" }\n"
15680
"\n"
15681
"\n"
15682
" for(let i = 0; i < F.gt.length; ++i)\n"
15683
" {\n"
15684
" let o = F.gt[i];\n"
15685
" UpdateThreadInfo(o);\n"
15686
" }\n"
15687
" }\n"
15688
"\n"
15689
"\n"
15690
"\n"
15691
" var ToDelete = new Array();\n"
15692
" for(var id in FrameData.TimerMap)\n"
15693
" {\n"
15694
" let FD = FrameData.TimerMap[id];\n"
15695
" if(!(F.x.t[id] || F.x.c[id]) && !groups[id])\n"
15696
" {\n"
15697
" PushIntoArray(FD.Time,0.0);\n"
15698
" PushIntoArray(FD.TimeExcl, 0.0);\n"
15699
" PushIntoArray(FD.Count, 0);\n"
15700
" FindMaxTime(FD.Time);\n"
15701
" FD.EmptyFrames++;\n"
15702
" }\n"
15703
" else\n"
15704
" {\n"
15705
" FD.EmptyFrames = 0;\n"
15706
" }\n"
15707
" FD.FrameTime = FD.Time[FD.Time.length-1]; //Fix her..?\n"
15708
" FD.AggregateTime = FD.Time[FD.Time.length-1];\n"
15709
"\n"
15710
" if(FD.EmptyFrames == FD.Time.length)\n"
15711
" {\n"
15712
" ToDelete.push(id);\n"
15713
" }\n"
15714
" }\n"
15715
" for(var i = 0; i < ToDelete.length; ++i)\n"
15716
" {\n"
15717
" delete FrameData.TimerMap[ToDelete[i]];\n"
15718
" }\n"
15719
" FramePending++;\n"
15720
"\n"
15721
"\n"
15722
" if(TriggerAutoCapture)\n"
15723
" {\n"
15724
" Capture();\n"
15725
" }\n"
15726
" ReferenceGraphAutomaticGroup = 1.05 * GraphTimeGroupMax;\n"
15727
" ReferenceGraphAutomatic = 1.05 * GraphTimeMax;\n"
15728
" ReferenceHistoryAutomatic = 1.05 * HistoryTimeMax;\n"
15729
" }\n"
15730
" RequestDraw();\n"
15731
" ProfileLeave();\n"
15732
"}\n"
15733
"\n"
15734
"function WSMessage(event)\n"
15735
"{\n"
15736
" // console.log(event.data);\n"
15737
" var Obj = JSON.parse(event.data);\n"
15738
" WSReceive++;\n"
15739
" WSReceiveBytes += event.data.length;\n"
15740
" var k = Obj.k;\n"
15741
" if(k == MSG_TIMER_TREE)\n"
15742
" {\n"
15743
" AddTimer(Obj.v);\n"
15744
" }\n"
15745
" else if(k == MSG_ENABLED)";
15746
15747
const size_t g_MicroProfileHtmlLive_begin_4_size = sizeof(g_MicroProfileHtmlLive_begin_4);
15748
const char g_MicroProfileHtmlLive_begin_5[] =
15749
"\n"
15750
" {\n"
15751
" EnableTimer(Obj.v);\n"
15752
" }\n"
15753
" else if(k == MSG_FRAME)\n"
15754
" {\n"
15755
" ProcessFrame(Obj.v);\n"
15756
" }\n"
15757
" else if(k == MSG_LOADSETTINGS)\n"
15758
" {\n"
15759
" OnLoadPreset(Obj.v, 1, Obj.ro, Obj.name);\n"
15760
" }\n"
15761
" else if(k == MSG_CURRENTSETTINGS)\n"
15762
" {\n"
15763
" OnLoadPreset(Obj.v, 0, Obj.ro, Obj.name);\n"
15764
" }\n"
15765
" else if(k == MSG_PRESETS)\n"
15766
" {\n"
15767
" AddPresets(Obj.v);\n"
15768
" }\n"
15769
" else if(k == MSG_COUNTERS)\n"
15770
" {\n"
15771
" ProcessCounters(Obj.v);\n"
15772
" }\n"
15773
" else if(k == MSG_FUNCTION_RESULTS)\n"
15774
" {\n"
15775
" FunctionQueryPending = null;\n"
15776
" if(FunctionQueryReceived< Obj.q)\n"
15777
" {\n"
15778
" FunctionQueryArray = Obj.v;\n"
15779
" FunctionQueryReceived = Obj.q;\n"
15780
" console.log(\'got result from query \' + Obj.q);\n"
15781
" }\n"
15782
" else\n"
15783
" {\n"
15784
" console.log(\'ignored result from query \' + Obj.q);\n"
15785
" }\n"
15786
"\n"
15787
"\n"
15788
" }\n"
15789
" else if(k == MSG_INACTIVE_FRAME)\n"
15790
" {\n"
15791
" ProcessFrame(Obj.v, 1);\n"
15792
" }\n"
15793
" else if(k == MSG_FUNCTION_NAMES)\n"
15794
" {\n"
15795
" for(var i = 0; i < Obj.v.length; ++i)\n"
15796
" {\n"
15797
" FunctionsInstrumented.push(Obj.v[i][0]);\n"
15798
" FunctionsInstrumentedModule.push(Obj.v[i][1]);\n"
15799
" FunctionsInstrumentedUnmangled.push(Obj.v[i][2]);\n"
15800
"\n"
15801
" }\n"
15802
" }\n"
15803
" else if(k == MSG_INSTRUMENT_ERROR)\n"
15804
" {\n"
15805
" var D = Obj.v.data;\n"
15806
" var F = Obj.v.functions;\n"
15807
" var ASM_SERVER = \"http://microprofileasm.zapto.org\";\n"
15808
" var url = ASM_SERVER + \"/add/\" + Obj.v.version + \"/\";\n"
15809
" console.log(JSON.stringify(D));\n"
15810
" console.log(JSON.stringify(F));\n"
15811
" for(var i = 0; i < D.length; ++i)\n"
15812
" {\n"
15813
" url = url + D[i].code + \"/\";\n"
15814
" }\n"
15815
" var s = \"Failed to instrument the following functions:\\n\";\n"
15816
"\n"
15817
" for(var i = 0; i < F.length; ++i)\n"
15818
" {\n"
15819
" s = s + F[i] + \"\\n\";\n"
15820
" }\n"
15821
" s = s + \"\\n\\nPlease click \\\"OK\\\"to report the failed code segments\\n\"\n"
15822
" s = s + \"this will open the following url in a hidden frame\\n\"\n"
15823
" s = s + url;\n"
15824
" s = s + \"\\n-No additional data will be sent\\n-No symbol names will be sent\";\n"
15825
" s = s + \"\\n[this popup can be auto-denied or auto-accepted from the settings menu]\";\n"
15826
" if(Cookie.CodeReportMode != 2)\n"
15827
" {\n"
15828
" if(Cookie.CodeReportMode == 1 || confirm(s))\n"
15829
" {\n"
15830
" var iframe = document.createElement(\"iframe\");\n"
15831
" iframe.onload = function(){document.body.removeChild(iframe); console.log(\"removed iframe\");};\n"
15832
" console.log(\"opening url \" + url);\n"
15833
" iframe.setAttribute(\"src\", url);\n"
15834
" iframe.style.width = \"100x\";\n"
15835
" iframe.style.height = \"100px\";\n"
15836
" document.body.appendChild(iframe);\n"
15837
" }\n"
15838
" }\n"
15839
" console.log(\"got error \"+ JSON.stringify(Obj.v));\n"
15840
" }else if(k == MSG_QUERY_INDEX)\n"
15841
" {\n"
15842
" if(parseInt(Obj.qp))\n"
15843
" {\n"
15844
" FunctionQueryLastRequest = parseInt(Obj.qp);\n"
15845
" FunctionQueryReceived = FunctionQueryLastRequest;\n"
15846
" console.log(\"SET QUERY COUNTER \" + FunctionQueryLastRequest);\n"
15847
" }\n"
15848
" }\n"
15849
" else\n"
15850
" {\n"
15851
" console.log(\'hest!\');\n"
15852
" }\n"
15853
"\n"
15854
"}\n"
15855
"function WSError(event)\n"
15856
"{\n"
15857
" console.log(\'WSError\');\n"
15858
"}\n"
15859
"function WSClose(event)\n"
15860
"{\n"
15861
" console.log(\'WSClose\');\n"
15862
" let WSLocal = WS;\n"
15863
" WS = null;\n"
15864
" if(WSLocal)\n"
15865
" {\n"
15866
" WSIsOpen = 0;\n"
15867
" WSLocal.close();\n"
15868
" window.document.title = \"MicroProfile Live\";\n"
15869
" FilterInputDiv.style[\'display\'] = \'none\';\n"
15870
" }\n"
15871
"\n"
15872
"}\n"
15873
"function WSSendMessage(msgid)\n"
15874
"{\n"
15875
" if(WSIsOpen)\n"
15876
" {\n"
15877
" var str = \'\' + msgid;\n"
15878
" WSSend++;\n"
15879
" WSSendBytes += str.length;\n"
15880
" WS.send(str);\n"
15881
" }\n"
15882
" else\n"
15883
" {\n"
15884
" if(msgid[0] == \'c\')\n"
15885
" {\n"
15886
" console.log(\'failing to send \' + msgid);\n"
15887
" }\n"
15888
" }\n"
15889
"}\n"
15890
"\n"
15891
"\n"
15892
"function Connect()\n"
15893
"{\n"
15894
" WSSeconds = 0;\n"
15895
" if(WSOpenTime)\n"
15896
" WSSeconds = new Date() - WSOpenTime;\n"
15897
" let DidTimeout = WSSeconds > 5000;\n"
15898
"\n"
15899
" if(WS && (WS.readyState == 1 || WS.readyState == 0))\n"
15900
" {\n"
15901
" WSConnected = WS.readyState == 1;\n"
15902
" WSFail = 0;\n"
15903
" WSSeconds = 0;\n"
15904
" WSReadyState = WS.readyState;\n"
15905
" }\n"
15906
" else\n"
15907
" {\n"
15908
" WSConnected = 0;\n"
15909
" }\n"
15910
" if(!WS || (DidTimeout && !WSConnected))\n"
15911
" {\n"
15912
" WSReadyState = 999;\n"
15913
" if(WS)\n"
15914
" {\n"
15915
" WSFail++;\n"
15916
" WS.onopen = null;\n"
15917
" WS.onclose = null;\n"
15918
" WS.onmessage = null;\n"
15919
" WS.onerror = null;\n"
15920
" WS.close();\n"
15921
" WS = null;\n"
15922
" }\n"
15923
" WSOpenTime = new Date();\n"
15924
" WSPath = \"ws://\" + WSHost + \":\" + WSPort + \"/ws\";\n"
15925
" SetMessage(\'Connecting to \' + WSPath, 5 * 1000, 1);\n"
15926
" console.log(\"Open WebSocket \" + WSPath);\n"
15927
" WS = new WebSocket(WSPath);\n"
15928
" WS.onopen = WSOpen;\n"
15929
" WS.onmessage = WSMessage;\n"
15930
" WS.onerror = WSError;\n"
15931
" WS.onclose = WSClose;\n"
15932
" WSFail = 0;\n"
15933
" }\n"
15934
"\n"
15935
"\n"
15936
"\n"
15937
" RequestDraw();\n"
15938
"}\n"
15939
"\n"
15940
"\n"
15941
"function MouseDragPan()\n"
15942
"{\n"
15943
" return MouseDragButton == 1 || MouseDragKeyShift;\n"
15944
"}\n"
15945
"function MouseDragSelectRange()\n"
15946
"{\n"
15947
" return MouseDragState == MouseDragMove && (MouseDragButton == 3 || (MouseDragKeyShift&&MouseDragKeyCtrl));\n"
15948
"}\n"
15949
"\n"
15950
"function MouseHandleDrag()\n"
15951
"{\n"
15952
" if(MouseDragTarget == CanvasDetailedView)\n"
15953
" {\n"
15954
" if(SubMenuActive == -1)\n"
15955
" {\n"
15956
" if(MouseDragSelectRange() && SubMenuActive == -1)\n"
15957
" {\n"
15958
" var xStart = MouseDragXStart;\n"
15959
" var xEnd = MouseDragX;\n"
15960
" if(xStart > xEnd)\n"
15961
" {\n"
15962
" var Temp = xStart;\n"
15963
" xStart = xEnd;\n"
15964
" xEnd = Temp;\n"
15965
" }\n"
15966
" if(xEnd - xStart > 1)\n"
15967
" {\n"
15968
" MouseDragActiveXStart = xStart;\n"
15969
" MouseDragActiveXEnd = xEnd;\n"
15970
" }\n"
15971
" }\n"
15972
" else if(MouseDragPan())\n"
15973
" {\n"
15974
" var X = MouseDragX - MouseDragXLast;\n"
15975
" var Y = MouseDragY - MouseDragYLast;\n"
15976
" if(X && MouseDragActiveXStart < MouseDragActiveXEnd)\n"
15977
" {\n"
15978
" MouseDragActiveXStart += X;\n"
15979
" MouseDragActiveXEnd += X;\n"
15980
" }\n"
15981
" }\n"
15982
" if(Settings.ViewActive == VIEW_BAR)\n"
15983
" {\n"
15984
" if(MouseDragKeyShift || MouseDragButton == 1)\n"
15985
" {\n"
15986
" var X = MouseDragX - MouseDragXLast;\n"
15987
" var Y = MouseDragY - MouseDragYLast;\n"
15988
" nOffsetBarsY -= Y;\n"
15989
" nOffsetBarsX -= X;\n"
15990
" if(nOffsetBarsY < 0)\n"
15991
" {\n"
15992
" nOffsetBarsY = 0;\n"
15993
" }\n"
15994
" if(nOffsetBarsX < 0)\n"
15995
" {\n"
15996
" nOffsetBarsX = 0;\n"
15997
" }\n"
15998
" }\n"
15999
" }\n"
16000
" if(Settings.ViewActive == VIEW_COUNTERS)\n"
16001
" {\n"
16002
" if(MouseDragKeyShift || MouseDragButton == 1)\n"
16003
" {\n"
16004
" var Y = MouseDragY - MouseDragYLast;\n"
16005
" nOffsetCountersY -= Y;\n"
16006
" if(nOffsetCountersY < 0)\n"
16007
" {\n"
16008
" nOffsetCountersY = 0;\n"
16009
" }\n"
16010
" }\n"
16011
" }\n"
16012
" }\n"
16013
" else if(SubMenuActive == SubMenuTimers || SubMenuActive == SubMenuGroup || SubMenuActive == SubMenuCounters || SubMenuActive == SubMenuFunctions)\n"
16014
" {\n"
16015
" if(MouseDragKeyShift || MouseDragButton == 1)\n"
16016
" {\n"
16017
" var Y = MouseDragY - MouseDragYLast;\n"
16018
" if(SubMenuActive == SubMenuTimers)\n"
16019
" {\n"
16020
" nOffsetMenuTimers -= Y;\n"
16021
" if(nOffsetMenuTimers < 0)\n"
16022
" {\n"
16023
" nOffsetMenuTimers = 0;\n"
16024
" }\n"
16025
" }\n"
16026
" else if(SubMenuActive == SubMenuFunctions)\n"
16027
" {\n"
16028
" nOffsetMenuFunctions -= Y;\n"
16029
" if(nOffsetMenuFunctions < 0)\n"
16030
" {\n"
16031
" nOffsetMenuFunctions = 0;\n"
16032
" }\n"
16033
" }\n"
16034
" else if(SubMenuActive == SubMenuGroup)\n"
16035
" {\n"
16036
" nOffsetMenuGroup -= Y;\n"
16037
" if(nOffsetMenuGroup < 0)\n"
16038
" {\n"
16039
" nOffsetMenuGroup = 0;\n"
16040
" }\n"
16041
" }\n"
16042
" else if(SubMenuActive == SubMenuCounters)\n"
16043
" {\n"
16044
" nOffsetMenuCounters -= Y;\n"
16045
" if(nOffsetMenuCounters < 0)\n"
16046
" {\n"
16047
" nOffsetMenuCounters = 0;\n"
16048
" }\n"
16049
" }\n"
16050
" }\n"
16051
" }\n"
16052
" }\n"
16053
" MouseDragXLast = MouseDragX;\n"
16054
" MouseDragYLast = MouseDragY;\n"
16055
"}\n"
16056
"function MouseHandleDragEnd()\n"
16057
"{\n"
16058
" if(MouseDragTarget == CanvasDetailedView)\n"
16059
" {\n"
16060
"\n"
16061
" }\n"
16062
"}\n"
16063
"\n"
16064
"function MouseHandleDragClick()\n"
16065
"{\n"
16066
" if(SubMenuActive == -1)\n"
16067
" {\n"
16068
" if(nHoverCounter != -1)\n"
16069
" {\n"
16070
" if(TimerArray[nHoverCounter].firstchild != -1)\n"
16071
" {\n"
16072
" TimerArray[nHoverCounter].closed = !TimerArray[nHoverCounter].closed;\n"
16073
" }\n"
16074
" else\n"
16075
" {\n"
16076
" TimerArray[nHoverCounter].Expanded = !TimerArray[nHoverCounter].Expanded;\n"
16077
" }\n"
16078
" Draw(1);\n"
16079
" }\n"
16080
" }\n"
16081
" if(MouseInCaptureButton)\n"
16082
" {\n"
16083
" TriggerCapture();\n"
16084
" }\n"
16085
"}\n"
16086
"\n"
16087
"function MapMouseButton(event)\n"
16088
"{\n"
16089
" if(event.button == 1 || event.which == 1)\n"
16090
" {\n"
16091
" return 1;\n"
16092
" }\n"
16093
" else if(event.button == 3 || event.which == 3)\n"
16094
" {\n"
16095
" return 3;\n"
16096
" }\n"
16097
" else\n"
16098
" {\n"
16099
" return 0;\n"
16100
" }\n"
16101
"}\n"
16102
"\n"
16103
"function MouseDragReset()\n"
16104
"{\n"
16105
" MouseDragState = MouseDragOff;\n"
16106
" MouseDragTarget = 0;\n"
16107
" MouseDragKeyShift = 0;\n"
16108
" MouseDragKeyCtrl = 0;\n"
16109
" MouseDragButton = 0;\n"
16110
"}\n"
16111
"function MouseDragKeyUp()\n"
16112
"{\n"
16113
" if((MouseDragKeyShift && !KeyShiftDown) || (MouseDragKeyCtrl && !KeyCtrlDown))\n"
16114
" {\n"
16115
" MouseHandleDragEnd();\n"
16116
" MouseDragReset();\n"
16117
" }\n"
16118
"}\n"
16119
"function MouseDrag(Source, Event)\n"
16120
"{\n"
16121
" if(Source == MouseDragOff || (MouseDragTarget && MouseDragTarget != Event.target))\n"
16122
" {\n"
16123
" MouseDragReset();\n"
16124
" return;\n"
16125
" }\n"
16126
"\n"
16127
" var LocalRect = Event.target.getBoundingClientRect();\n"
16128
" MouseDragX = Event.clientX - LocalRect.left;\n"
16129
" MouseDragY = Event.clientY - LocalRect.top;\n"
16130
" if(MouseDragState == MouseDragMove)\n"
16131
" {\n"
16132
" var dx = Math.abs(MouseDragX - MouseDragXStart);\n"
16133
" var dy = Math.abs(MouseDragY - MouseDragYStart);\n"
16134
" if((Source == MouseDragUp && MapMouseButton(Event) == MouseDragButton) ||\n"
16135
" (MouseDragKeyCtrl && !KeyCtrlDown) ||\n"
16136
" (MouseDragKeyShift && !KeyShiftDown))\n"
16137
" {\n"
16138
" MouseHandleDragEnd();\n"
16139
" MouseDragReset();\n"
16140
" return;\n"
16141
" }\n"
16142
" else\n"
16143
" {\n"
16144
" MouseHandleDrag();\n"
16145
" }\n"
16146
" }\n"
16147
" else if(MouseDragState == MouseDragOff)\n"
16148
" {\n"
16149
" if(Source == MouseDragDown || KeyShiftDown || KeyCtrlDown)\n"
16150
" {\n"
16151
" MouseDragTarget = Event.target;\n"
16152
" MouseDragButton = MapMouseButton(Event);\n"
16153
" MouseDragState = MouseDragDown;\n"
16154
" MouseDragXStart = MouseDragX;\n"
16155
" MouseDragYStart = MouseDragY;\n"
16156
" MouseDragKeyCtrl = 0;\n"
16157
" MouseDragKeyShift = 0;\n"
16158
"\n"
16159
" if(KeyShiftDown || KeyCtrlDown)\n"
16160
" {\n"
16161
" MouseDragKeyShift = KeyShiftDown;\n"
16162
" MouseDragKeyCtrl = KeyCtrlDown;\n"
16163
" MouseDragState = MouseDragMove;\n"
16164
" }\n"
16165
" }\n"
16166
" }\n"
16167
" else if(MouseDragState == MouseDragDown)\n"
16168
" {\n"
16169
" if(Source == MouseDragUp)\n"
16170
" {\n"
16171
" MouseHandleDragClick();\n"
16172
" MouseDragReset();\n"
16173
" }\n"
16174
" else if(Source == MouseDragMove)\n"
16175
" {\n"
16176
" var dx = Math.abs(MouseDragX - MouseDragXStart);\n"
16177
" var dy = Math.abs(MouseDragY - MouseDragYStart);\n"
16178
" if(dx+dy>1)\n"
16179
" {\n"
16180
" MouseDragState = MouseDragMove;\n"
16181
" }\n"
16182
" }\n"
16183
" }\n"
16184
" MouseDragXLast = MouseDragX;\n"
16185
" MouseDragYLast = MouseDragY;\n"
16186
"}\n"
16187
"\n"
16188
"\n"
16189
"function MouseMove(evt)\n"
16190
"{\n"
16191
" evt.preventDefault();\n"
16192
" var rect = evt.target.getBoundingClientRect();\n"
16193
" var x = evt.clientX - rect.left;\n"
16194
" var y = evt.clientY - rect.top;\n"
16195
" MouseX = x;\n"
16196
" MouseY = y;\n"
16197
" MouseMoveTime = new Date();\n"
16198
" MouseDrag(MouseDragMove, evt);\n"
16199
" RequestDraw();\n"
16200
"}\n"
16201
"\n"
16202
"\n"
16203
"function MouseSortClick()\n"
16204
"{\n"
16205
" if(SubMenuActive == -1)\n"
16206
" {\n"
16207
" if(SortColumnMouseOverNext)\n"
16208
" {\n"
16209
" if(SortColumnMouseOverNext == Settings.SortColumnName)\n"
16210
" {\n"
16211
" Settings.SortColumnOrderFlip = 1 - Settings.SortColumnOrderFlip;\n"
16212
" }\n"
16213
" else\n"
16214
" {\n"
16215
" Settings.SortColumnOrderFlip = 0;\n"
16216
" }\n"
16217
"\n"
16218
" Settings.SortColumnName = SortColumnMouseOverNext;\n"
16219
" SortColumnMouseOverNext = null;\n"
16220
" }\n"
16221
" }\n"
16222
"}\n"
16223
"\n"
16224
"\n"
16225
"function MouseButton(bPressed, evt)\n"
16226
"{\n"
16227
" evt.preventDefault();\n"
16228
" MouseReleased = !bPressed;\n"
16229
" MouseDrag(bPressed ? MouseDragDown : MouseDragUp, evt);\n"
16230
" if(!bPressed)\n"
16231
" MouseSortClick();\n"
16232
" RequestDraw();\n"
16233
"}\n"
16234
"\n"
16235
"function MouseOut(evt)\n"
16236
"{\n"
16237
" MouseDrag(MouseDragOff, evt);\n"
16238
" KeyCtrlDown = 0;\n"
16239
" KeyShiftDown = 0;\n"
16240
"}\n"
16241
"\n"
16242
"function MouseWheel(e)\n"
16243
"{\n"
16244
"}\n"
16245
"\n"
16246
"function KeyUp(evt)\n"
16247
"{\n"
16248
" let k = evt.keyCode;\n"
16249
" let InputActive = SubMenuActive == SubMenuTimers || SubMenuActive == SubMenuGroup || SubMenuActive == SubMenuCounters || SubMenuActive == SubMenuFunctions || SubMenuActive == SubMenuPatched || SubMenuActive == SubMenuModules;\n"
16250
" if(IsPromptActive())\n"
16251
" return;\n"
16252
" if(!InputActive)\n"
16253
" {\n"
16254
" if(k == 220)\n"
16255
" {\n"
16256
" ProfileMode = !ProfileMode;\n"
16257
" }\n"
16258
" if(k == 191)\n"
16259
" {\n"
16260
" WSPort++;\n"
16261
" if(WSPort > 1338+2)\n"
16262
" {\n"
16263
" WSPort = 1338;\n"
16264
" }\n"
16265
" if(WS)\n"
16266
" {\n"
16267
" WS.close();\n"
16268
" WS = null;\n"
16269
" }\n"
16270
" }\n"
16271
" if(k == 32)\n"
16272
" {\n"
16273
" if(0) //for debugging.\n"
16274
" {\n"
16275
" console.log(\"FrameData =\");\n"
16276
" console.log(JSON.stringify(FrameData));\n"
16277
" console.log(\"TimerArray =\");\n"
16278
" console.log(JSON.stringify(TimerArray));\n"
16279
" }\n"
16280
" if(KeyCtrlDown)\n"
16281
" {\n"
16282
" ToggleCompressedView();\n"
16283
" }\n"
16284
" else\n"
16285
" { \n"
16286
" WSSendMessage(\"f\");\n"
16287
" }\n"
16288
" }\n"
16289
" if(k == 88)\n"
16290
" {\n"
16291
" ToggleView();\n"
16292
" }\n"
16293
" if(k == 13)\n"
16294
" {\n"
16295
" TriggerCapture();\n"
16296
" }\n"
16297
" if(k == 72)\n"
16298
" {\n"
16299
" ShowHelp(0, 1);\n"
16300
" }\n"
16301
"\n"
16302
"\n"
16303
" }\n"
16304
" if(k == 27)\n"
16305
" {\n"
16306
" if(FilterInput.value.trim() != \"\")\n"
16307
" {\n"
16308
" FilterInput.value = \"\";\n"
16309
" }\n"
16310
" else\n"
16311
" {\n"
16312
" EnableMenu(-1);\n"
16313
" }\n"
16314
"\n"
16315
" MouseDragActiveXStart = MouseDragActiveXEnd = -1;\n"
16316
" Settings.SortColumnName = \"\";\n"
16317
" ShowHelp(0);\n"
16318
" }\n"
16319
"\n"
16320
" if(evt.keyCode == 17)\n"
16321
" {\n"
16322
" KeyCtrlDown = 0;\n"
16323
" MouseDragKeyUp();\n"
16324
" }\n"
16325
" if(evt.keyCode == 16)\n"
16326
" {\n"
16327
" KeyShiftDown = 0;\n"
16328
" MouseDragKeyUp();\n"
16329
" }\n"
16330
"}\n"
16331
"\n"
16332
"function KeyDown(evt)\n"
16333
"{\n"
16334
" if(IsPromptActive())\n"
16335
" return;\n"
16336
"\n"
16337
" // console.log(\"keydow \", k);\n"
16338
" if(evt.keyCode == 17)\n"
16339
" {\n"
16340
" KeyCtrlDown = 1;\n"
16341
" MouseDragKeyUp();\n"
16342
" }\n"
16343
" if(evt.keyCode == 16)\n"
16344
" {\n"
16345
" KeyShiftDown = 1;\n"
16346
" MouseDragKeyUp();\n"
16347
" }\n"
16348
"}\n"
16349
"\n"
16350
"\n"
16351
"function SetupEvents()\n"
16352
"{\n"
16353
" var mousewheelevt = (/Firefox/i.test(navigator.userAgent)) ? \"DOMMouseScroll\" : \"mousewheel\"; //FF doesn\'t recognize mousewheel as of\n"
16354
" CanvasDetailedView.addEventListener(\'mousemove\', MouseMove, false);\n"
16355
" CanvasDetailedView.addEventListener(\'mousedown\', function(evt) { MouseButton(true, evt); });\n"
16356
" CanvasDetailedView.addEventListener(\'mouseup\', function(evt) { MouseButton(false, evt); } );\n"
16357
" CanvasDetailedView.addEventListener(\'mouseout\', MouseOut);\n"
16358
" CanvasDetailedView.addEventListener(\"contextmenu\", function (e) { e.preventDefault(); }, false);\n"
16359
" CanvasDetailedView.addEventListener(mousewheelevt, MouseWheel, false);\n"
16360
" window.addEventListener(\'keydown\', KeyDown);\n"
16361
" window.addEventListener(\'keyup\', KeyUp);\n"
16362
" window.addEventListener(\'resize\', ResizeCanvas, false);\n"
16363
"}\n"
16364
"\n"
16365
"function DrawToolTip(StringArray, Canvas, x, y)\n"
16366
"{\n"
16367
" if(!ShowMenu())\n"
16368
" {\n"
16369
" return;\n"
16370
" }\n"
16371
" let colors;\n"
16372
" let a = StringArray;\n"
16373
" if(StringArray.c)\n"
16374
" {\n"
16375
" a = StringArray.a;\n"
16376
" colors = StringArray.c;\n"
16377
" }\n"
16378
" var context = Canvas.getContext(\'2d\');\n"
16379
" context.font = Font;\n"
16380
" var WidthArray = Array(a.length);\n"
16381
" var nMaxWidth = 0;\n"
16382
" var nHeight = 0;\n"
16383
" for(var i = 0; i < a.length; i += 2)\n"
16384
" {\n"
16385
" var nWidth0 = context.measureText(a[i]).width;\n"
16386
" var nWidth1 = context.measureText(a[i+1]).width;\n"
16387
" var nSum = nWidth0 + nWidth1;\n"
16388
" WidthArray[i] = nWidth0;\n"
16389
" WidthArray[i+1] = nWidth1;\n"
16390
" if(nSum > nMaxWidth)\n"
16391
" {\n"
16392
" nMaxWidth = nSum;\n"
16393
" }\n"
16394
" nHeight += BoxHeight;\n"
16395
" }\n"
16396
" nMaxWidth += 15;\n"
16397
" //bounds check.\n"
16398
" x = Math.max(0, x - 10 - nMaxWidth);\n"
16399
" var CanvasRect = Canvas.getBoundingClientRect();\n"
16400
" if(y + nHeight > CanvasRect.height)\n"
16401
" {\n"
16402
" y = CanvasRect.height - nHeight;\n"
16403
" x += 20;\n"
16404
" }\n"
16405
" if(x + nMaxWidth > CanvasRect.width)\n"
16406
" {\n"
16407
" x = CanvasRect.width - nMaxWidth;\n"
16408
" }\n"
16409
"\n"
16410
" context.fillStyle = \'black\';\n"
16411
" context.fillRect(x-1, y, nMaxWidth+2, nHeight);\n"
16412
" context.fillStyle = \'white\';\n"
16413
"\n"
16414
" var XPos = x;\n"
16415
" var XPosRight = x + nMaxWidth;\n"
16416
" var YPos = y + BoxHeight-2;\n"
16417
" context.fillStyle = \'white\';\n"
16418
" for(i = 0; i < a.length; i += 2)\n"
16419
" {\n"
16420
" if(colors)\n"
16421
" context.fillStyle = colors[i];\n"
16422
" context.fillText(a[i], XPos, YPos);\n"
16423
" if(colors)\n"
16424
" context.fillStyle = colors[i+1];\n"
16425
" context.fillText(a[i+1], XPosRight - WidthArray[i+1], YPos);\n"
16426
" YPos += BoxHeight;\n"
16427
" }\n"
16428
" context.fillStyle = \'white\';\n"
16429
"}\n"
16430
"\n"
16431
"function DrawPlotf(Canvas)\n"
16432
"{\n"
16433
" return;\n"
16434
" var context = Canvas.getContext(\'2d\');\n"
16435
" context.font = Font;\n"
16436
" var WidthArray = Array(PlotfArray.length);\n"
16437
" var nMaxWidth = 0;\n"
16438
" var nHeight = 0;\n"
16439
"\n"
16440
" context.font = Font;\n"
16441
" for(i = 0; i < PlotfArray.length; i++)\n"
16442
" {\n"
16443
" var nWidth = context.measureText(PlotfArray[i]).width;\n"
16444
" WidthArray[i] = nWidth;\n"
16445
" if(nWidth > nMaxWidth)\n"
16446
" {\n"
16447
" nMaxWidth = nWidth;\n"
16448
" }\n"
16449
" nHeight += BoxHeight;\n"
16450
" }\n"
16451
" nMaxWidth += 15;\n"
16452
" var x = 0;\n"
16453
" var y = 0;\n"
16454
"\n"
16455
" context.fillStyle = \'black\';\n"
16456
" context.fillRect(x-1, y, nMaxWidth+2, nHeight);\n"
16457
" context.fillStyle = \'white\';\n"
16458
"\n"
16459
" var XPos = x;\n"
16460
" var XPosRight = x + nMaxWidth;\n"
16461
" var YPos = y + BoxHeight-2;\n"
16462
" for(i = 0; i < PlotfArray.length; i++)\n"
16463
" {\n"
16464
" context.fillText(PlotfArray[i], XPos, YPos);\n"
16465
" YPos += BoxHeight;\n"
16466
" }\n"
16467
"}\n"
16468
"\n"
16469
"\n"
16470
"function ShiftRight10(v)\n"
16471
"{\n"
16472
" if(v > 1024)\n"
16473
" {\n"
16474
" return v / 1024.0;\n"
16475
" }\n"
16476
" else\n"
16477
" {\n"
16478
" return v >> 10;\n"
16479
" }\n"
16480
"}\n"
16481
"\n"
16482
"function FormatCounter(Format, Counter)\n"
16483
"{\n"
16484
" if(!Counter)\n"
16485
" {\n"
16486
" return \'0\';\n"
16487
" }\n"
16488
" var Negative = 0;\n"
16489
" if(Counter < 0)\n"
16490
" {\n"
16491
" Counter = -Counter;\n"
16492
" Negative = 1;\n"
16493
" if(Counter < 0) // handle INT_MIN\n"
16494
" {\n"
16495
" Counter = -(Counter+1);\n"
16496
" if(Counter < 0)\n"
16497
" {\n"
16498
" return \'?\';\n"
16499
" }\n"
16500
" }\n"
16501
" }\n"
16502
" var str = Negative ? \'-\' :\'\' ;\n"
16503
" if(Format == FormatCounterDefault)\n"
16504
" {\n"
16505
" var Seperate = 0;\n"
16506
" var result = \'\';\n"
16507
" while (Counter)\n"
16508
" {\n"
16509
" if (Seperate)\n"
16510
" {\n"
16511
" result += \'.\';\n"
16512
" }\n"
16513
" Seperate = 1;\n"
16514
" for (var i = 0; Counter && i < 3; ++i)\n"
16515
" {\n"
16516
" var Digit = Math.floor(Counter % 10);\n"
16517
" Counter = Math.floor(Counter / 10);\n"
16518
" result += \'\' + Digit;\n"
16519
" }\n"
16520
" }\n"
16521
"\n"
16522
" for(var i = 0; i < result.length; ++i)\n"
16523
" {\n"
16524
" str += result[result.length-1-i];\n"
16525
" }\n"
16526
" return str;\n"
16527
" }\n"
16528
" else if(Format == FormatCounterBytes)\n"
16529
" {\n"
16530
" var Shift = 0;\n"
16531
" var Divisor = 1;\n"
16532
" var CountShifted = ShiftRight10(Counter);\n"
16533
" while(CountShifted)\n"
16534
" {\n"
16535
" Divisor <<= 10;\n"
16536
" CountShifted = ShiftRight10(CountShifted);\n"
16537
" Shift++;\n"
16538
" }\n"
16539
" if(Shift)\n"
16540
" {\n"
16541
" return str + (Counter / Divisor).toFixed(2) + \'\' + FormatCounterBytesExt[Shift];\n"
16542
" }\n"
16543
" else\n"
16544
" {\n"
16545
" return str + Counter.toFixed(2) + \'\' + FormatCounterBytesExt[0];\n"
16546
" }\n"
16547
" }\n"
16548
" return \'?\';\n"
16549
"}\n"
16550
"function DrawCounterView(View, LocalMouseX, LocalMouseY, SubIndex)\n"
16551
"{\n"
16552
" var TimerMap = FrameData.TimerMap;\n"
16553
" if(!TimerMap)\n"
16554
" return;\n"
16555
"\n"
16556
"\n"
16557
" ProfileEnter(\"DrawCounterView\");\n"
16558
"\n"
16559
" var Canvas = View.Canvas[View.BackBuffer];\n"
16560
" var context = Canvas.getContext(\'2d\');\n"
16561
" context.clearRect(0, 0, View.w, View.h);\n"
16562
"\n"
16563
"\n"
16564
"\n"
16565
" var Height = BoxHeight;\n"
16566
" var Width = nWidth;\n"
16567
" var nTotalRows = CounterArray.length;\n"
16568
" var nTotalRowPixels = nTotalRows * Height;\n"
16569
" var nFrameRows = nHeight - BoxHeight;\n"
16570
" if(nOffsetCountersY + nFrameRows > nTotalRowPixels && nTotalRowPixels > nFrameRows)\n"
16571
" {\n"
16572
" nOffsetCountersY = nTotalRowPixels - nFrameRows;\n"
16573
" }\n"
16574
" var CounterWidth = 150;\n"
16575
" var Y = -nOffsetCountersY + BoxHeight;\n"
16576
" var X = 0;\n"
16577
" var nColorIndex = 0;\n"
16578
" context.fillStyle = \'white\';\n"
16579
" context.font = Font;\n"
16580
" var bMouseIn = 0;\n"
16581
" function DrawHeaderSplitSingle(Header, Width)\n"
16582
" {\n"
16583
" context.fillStyle = \'white\';\n"
16584
" context.fillText(Header, X, Height-FontAscent);\n"
16585
" X += Width;\n"
16586
" context.fillStyle = nBackColorOffset;\n"
16587
" context.fillRect(X-3, 0, 1, nHeight);\n"
16588
" }\n"
16589
" function DrawHeaderSplitSingleRight(Header, Width)\n"
16590
" {\n"
16591
" X += Width;\n"
16592
" context.fillStyle = \'white\';\n"
16593
" context.textAlign = \'right\';\n"
16594
" context.fillText(Header, X - FontWidth, Height-FontAscent);\n"
16595
" context.fillStyle = nBackColorOffset;\n"
16596
" context.fillRect(X, 0, 1, nHeight);\n"
16597
" context.textAlign = \'left\';\n"
16598
" }\n"
16599
" var TimerLen = 6;\n"
16600
" var TimerWidth = TimerLen * FontWidth;\n"
16601
" nHoverCounter = -1;\n"
16602
" function CounterIndent(Level)\n"
16603
" {\n"
16604
" return Level * 4 * FontWidth;\n"
16605
" }\n"
16606
" function Max(a, b)\n"
16607
" {\n"
16608
" return a > b ? a : b;\n"
16609
" }\n"
16610
"\n"
16611
" function DrawCounterRecursive(Index)\n"
16612
" {\n"
16613
" var Counter = TimerArray[Index];\n"
16614
" if(Counter.idtype == TYPE_COUNTER)\n"
16615
" {\n"
16616
" var Indent = CounterIndent(Counter.depth-1);\n"
16617
" var X = 0;\n"
16618
" nColorIndex = 1-nColorIndex;\n"
16619
" var HeightExpanded = Counter.Expanded ? Height * 5 : Height;\n"
16620
"\n"
16621
" bMouseIn = LocalMouseY >= Y && LocalMouseY < Y + HeightExpanded;\n"
16622
" if(bMouseIn)\n"
16623
" {\n"
16624
" nHoverCounter = Index;\n"
16625
" }\n"
16626
" var bgcolor = bMouseIn ? nBackColorOffset : nBackColors[nColorIndex];\n"
16627
" context.fillStyle = bgcolor;\n"
16628
" context.fillRect(0, Y, Width, HeightExpanded);\n"
16629
" context.fillStyle = \'white\';\n"
16630
" var c = Counter.closed ? \'*\' : \' \';\n"
16631
" context.fillText(c + Counter.name, Indent, Y+Height-FontAscent);\n"
16632
" X += CounterNameWidth;\n"
16633
" X += CounterValueWidth - FontWidth;\n"
16634
" context.textAlign = \'right\';\n"
16635
" context.fillText(Counter.formatted, X, Y+Height-FontAscent);\n"
16636
" context.textAlign = \'left\';\n"
16637
" X += FontWidth * 4;\n"
16638
" var Y0 = Y + 1;\n"
16639
" if(Counter.limit != 0)\n"
16640
" {\n"
16641
" context.fillText(Counter.formattedlimit, X, Y+Height-FontAscent);\n"
16642
" X += CounterLimitWidth;\n"
16643
" var X0 = X + 1;\n"
16644
" context.fillStyle = \'white\';\n"
16645
" context.fillRect(X0, Y0, Counter.boxprc * (CounterWidth-2), Height-2);\n"
16646
" context.fillStyle = bgcolor;\n"
16647
" context.fillRect(X0+1, Y0+1, Counter.boxprc * (CounterWidth-4), Height-4);\n"
16648
" context.fillStyle = \'cyan\';\n"
16649
" context.fillRect(X0+1, Y0+1, Counter.counterprc * (CounterWidth-4), Height-4);\n"
16650
" X += CounterWidth + 10;\n"
16651
" }\n"
16652
" else\n"
16653
" {\n"
16654
" X += CounterLimitWidth;\n"
16655
" X += CounterWidth + 10;\n"
16656
" }\n"
16657
"\n"
16658
" if(Counter.minvalue != Counter.maxvalue)\n"
16659
" {\n"
16660
" var CounterHistory = Counter.counterhistory;\n"
16661
" var Prc = CounterHistory.prc;\n"
16662
" context.fillStyle = \'cyan\';\n"
16663
" context.strokeStyle = \'cyan\';\n"
16664
" context.globalAlpha = 0.5;\n"
16665
" context.beginPath();\n"
16666
" var x = X;\n"
16667
" var YBase = Y0 + HeightExpanded-1;\n"
16668
" var YOffset = -(HeightExpanded-2);\n"
16669
"\n"
16670
" context.moveTo(X, Y0);\n"
16671
" for(var i = 0; i < Prc.length; ++i)\n"
16672
" {\n"
16673
" context.moveTo(x, YBase);\n"
16674
" context.lineTo(x, YBase + Prc[i] * YOffset);\n"
16675
" x += 1;\n"
16676
" }\n"
16677
" context.stroke();\n"
16678
"\n"
16679
" x = X;\n"
16680
" context.globalAlpha = 1.0;\n"
16681
" context.beginPath();\n"
16682
" context.moveTo(X, YBase);\n"
16683
"\n"
16684
" for(var i = 0; i < Prc.length; ++i)\n"
16685
" {\n"
16686
" context.lineTo(x, YBase + Prc[i] * YOffset);\n"
16687
" x += 1;\n"
16688
" }\n"
16689
" context.stroke();\n"
16690
" if(bMouseIn)\n"
16691
" {\n"
16692
" var MouseGraphX = Math.floor(LocalMouseX - X);\n"
16693
" if(MouseGraphX >= 0 && MouseGraphX < CounterHistory.history.length)\n"
16694
" {\n"
16695
" context.fillStyle = \'white\';\n"
16696
" var Formatted = FormatCounter(Counter.format, CounterHistory.history[MouseGraphX]);\n"
16697
" context.fillText(Formatted, X, Y+Height-FontAscent);\n"
16698
" }\n"
16699
" context.strokeStyle = \'orange\';\n"
16700
" context.beginPath();\n"
16701
" var CrossX = X + MouseGraphX;\n"
16702
" var CrossY = YBase + Prc[MouseGraphX] * YOffset;\n"
16703
" context.moveTo(CrossX-2, CrossY-2);\n"
16704
" context.lineTo(CrossX+2, CrossY+2);\n"
16705
" context.moveTo(CrossX+2, CrossY-2);\n"
16706
" context.lineTo(CrossX-2, CrossY+2);\n"
16707
" context.stroke();\n"
16708
"\n"
16709
" }\n"
16710
" X += Prc.length + 5;\n"
16711
" context.fillStyle = \'white\';\n"
16712
" context.fillText( FormatCounter(Counter.format, Counter.minvalue), X, Y + Height - FontAscent);\n"
16713
" X += CounterWidth + 5;\n"
16714
" context.fillText( FormatCounter(Counter.format, Counter.maxvalue), X, Y + Height - FontAscent);\n"
16715
" X += CounterWidth + 5;\n"
16716
" }\n"
16717
" Y += HeightExpanded;\n"
16718
" }\n"
16719
"\n"
16720
" if(Index == 0 || (!Counter.closed && Counter.idtype == TYPE_COUNTER))\n"
16721
" {\n"
16722
" var ChildIndex = Counter.firstchild;\n"
16723
" while(ChildIndex != -1)\n"
16724
" {\n"
16725
" DrawCounterRecursive(ChildIndex);\n"
16726
" ChildIndex = TimerArray[ChildIndex].sibling;\n"
16727
" }\n"
16728
" }\n"
16729
" }\n"
16730
"\n"
16731
" DrawCounterRecursive(0);\n"
16732
"\n"
16733
" X = 0;\n"
16734
" context.fillStyle = nBackColorOffset;\n"
16735
" context.fillRect(0, 0, Width, Height);\n"
16736
" context.fillStyle = \'white\';\n"
16737
" DrawHeaderSplitSingle(\'Name\', CounterNameWidth);\n"
16738
" DrawHeaderSplitSingleRight(\'Value\', CounterValueWidth + (FontWidth+1));\n"
16739
" DrawHeaderSplitSingle(\'Limit\', CounterLimitWidth + CounterWidth + 3 * (FontWidth+1));\n"
16740
" ProfileLeave();\n"
16741
"}\n"
16742
"\n"
16743
"function ShowHelp(Show, Toggle)\n"
16744
"{\n"
16745
" var HelpWindow = document.getElementById(\'helpwindow\');\n"
16746
" if(Toggle)\n"
16747
" {\n"
16748
" if(HelpWindow.style[\'display\'] == \'block\')\n"
16749
" {\n"
16750
" HelpWindow.style[\'display\'] = \'none\';\n"
16751
" }\n"
16752
" else\n"
16753
" {\n"
16754
" HelpWindow.style[\'display\'] = \'block\';\n"
16755
" }\n"
16756
" }\n"
16757
" else\n"
16758
" {\n"
16759
" if(Show)\n"
16760
" {\n"
16761
" HelpWindow.style[\'display\'] = \'block\';\n"
16762
" }\n"
16763
" else\n"
16764
" {\n"
16765
" HelpWindow.style[\'display\'] = \'none\';\n"
16766
" }\n"
16767
" }\n"
16768
"}\n"
16769
"\n"
16770
"function ParseUrl()\n"
16771
"{\n"
16772
" var path = window.location.pathname;\n"
16773
" var idx = path.indexOf(\'/\');\n"
16774
" if(idx < 0)\n"
16775
" return;\n"
16776
" var StrCommand = path.substring(idx+1);\n"
16777
" idx = StrCommand.indexOf(\'/\');\n"
16778
" if(idx < 0)\n"
16779
" return;\n"
16780
" var StrSettings = StrCommand.substring(idx+1);\n"
16781
" PresetToLoad = StrSettings;\n"
16782
" PresetToLoadRO = StrCommand[0] == \'b\';\n"
16783
"}\n"
16784
"\n"
16785
"\n"
16786
"function GetCookie()\n"
16787
"{\n"
16788
" var result = document.cookie.match(/fisk=([^;]+)/);\n"
16789
" if(result && result.length > 0)\n"
16790
" {\n"
16791
" var Obj = JSON.parse(result[1]);\n"
16792
" if(!Obj.offline)\n"
16793
" {\n"
16794
" var C = {};\n"
16795
" C.offline = Obj;\n"
16796
" Obj = C;\n"
16797
" }\n"
16798
" return Obj;\n"
16799
" }\n"
16800
" else\n"
16801
" {\n"
16802
" return {offline:{},live:{}};\n"
16803
" }\n"
16804
"}\n"
16805
"\n"
16806
"function ReadCookie()\n"
16807
"{\n"
16808
" var C = GetCookie().live;\n"
16809
" for(var i in C)\n"
16810
" {\n"
16811
" Cookie[i] = C[i];\n"
16812
" }\n"
16813
"}\n"
16814
"function WriteCookie()\n"
16815
"{\n"
16816
" var C = GetCookie();\n"
16817
" C.live = {};\n"
16818
" for(var i in Cookie)\n"
16819
" {\n"
16820
" C.live[i] = Cookie[i];\n"
16821
" }\n"
16822
"\n"
16823
" var date = new Date();\n"
16824
" date.setFullYear(2099);\n"
16825
" var cookie = \'fisk=\' + JSON.stringify(C) + \';expires=\' + date;\n"
16826
" document.cookie = cookie;\n"
16827
"}\n"
16828
"\n"
16829
"let CSVSets = {};\n"
16830
"let CSVIndex = 0;\n"
16831
"function CreateCSVSetFile(Set, Filename)\n"
16832
"{\n"
16833
" let File = {};\n"
16834
" File.Name = Filename;\n"
16835
" File.DataSorted = [];\n"
16836
" File.Data = [];\n"
16837
" File.ColumnToIndex = {};\n"
16838
" File.ColumnsSorted = {};\n"
16839
" File.Columns = {};\n"
16840
" return File;\n"
16841
"\n"
16842
"}\n"
16843
"function CreateCSVSet()\n"
16844
"{\n"
16845
" let Index = ++CSVIndex;\n"
16846
" let Name = \"Drop_\" + Index;\n"
16847
" let Set = {};\n"
16848
" Set.Name = Name;\n"
16849
" Set.Files = {};\n"
16850
" Set.Columns = {};\n"
16851
" Set.ColumnNames = {};\n"
16852
" Set.ColumnIndex = 0;\n"
16853
" Set.PendingCount = 0;\n"
16854
" Set.FinishedCount = 0;\n"
16855
" return Set;\n"
16856
"}\n"
16857
"function ParseCSVCheckFinished(Name)\n"
16858
"{\n"
16859
" let Set = CSVSets[Name];\n"
16860
" console.log(\"Finished parsing \", Set.FinishedCount, \":\", Set.PendingCount);\n"
16861
" if(Set.FinishedCount == Set.PendingCount)\n"
16862
" {\n"
16863
" if(Set.FinishedCount == 0)\n"
16864
" {\n"
16865
" console.error(\"No CSV files were parsable\");\n"
16866
" CSVSets[Name] = null;\n"
16867
" }\n"
16868
" else\n"
16869
" {\n"
16870
" for(let CName in Set.ColumnNames)\n"
16871
" {\n"
16872
" let aggr = {};\n"
16873
" let MaxCount = 0;\n"
16874
" console.log(\"aggr for \", CName);\n"
16875
" for(let F in Set.Files)\n"
16876
" {\n"
16877
" let File = Set.Files[F];\n"
16878
" if(File.Columns[CName])\n"
16879
" MaxCount = Math.max(MaxCount, File.Columns[CName].length);\n"
16880
" }\n"
16881
" let count = new Array(MaxCount);\n"
16882
" let sum = new Array(MaxCount);\n"
16883
" let min = new Array(MaxCount);\n"
16884
" let max = new Array(MaxCount);\n"
16885
" let avg = new Array(MaxCount);\n"
16886
" for(let i = 0; i < MaxCount; ++i)\n"
16887
" {\n"
16888
" count[i] = 0;\n"
16889
" sum[i] = 0;\n"
16890
" min[i] = 1e28;\n"
16891
" max[i] = -1e28;\n"
16892
" }\n"
16893
" for(let F in Set.Files)\n"
16894
" {\n"
16895
" let File = Set.Files[F];\n"
16896
" if(File.Columns[CName])\n"
16897
" {\n"
16898
" let c = File.Columns[CName];\n"
16899
" for(let i = 0; i < c.length; ++i)\n"
16900
" {\n"
16901
" count[i]++;\n"
16902
" sum[i] += c[i];\n"
16903
" min[i] = Math.min(c[i], min[i]);\n"
16904
" max[i] = Math.max(c[i], max[i]);\n"
16905
"\n"
16906
" }\n"
16907
" }\n"
16908
" }\n"
16909
" for(let i = 0; i < MaxCount; ++i)\n"
16910
" {\n"
16911
" if(count[i])\n"
16912
" {\n"
16913
" avg[i] = sum[i] / count[i];\n"
16914
" console.log(\".. \", avg[i], \" min \", min[i]);\n"
16915
" }\n"
16916
" else\n"
16917
" {\n"
16918
" min[i] = 0;\n"
16919
" max[i] = 0;\n"
16920
" }\n"
16921
" }\n"
16922
" }\n"
16923
" }\n"
16924
" }\n"
16925
"}\n"
16926
"function ParseCSVLine(Line)\n"
16927
"{\n"
16928
" let Pos = 0;\n"
16929
" let Start = 0;\n"
16930
" let Len = Line.length;\n"
16931
" let InBrackets = 0;\n"
16932
" let Out = new Array();\n"
16933
" let BracketStart = -1;\n"
16934
" let BracketEnd = -1;\n"
16935
" let push = function()\n"
16936
" {\n"
16937
" if(BracketStart >= 0)\n"
16938
" {\n"
16939
" console.assert(BracketEnd >= 0);\n"
16940
" Out.push(Line.slice(BracketStart+1, BracketEnd));\n"
16941
" }\n"
16942
" else\n"
16943
" {\n"
16944
" Out.push(Line.slice(Start, Pos).trim());\n"
16945
"\n"
16946
" }\n"
16947
" Start = Pos+1;\n"
16948
" InBrackets = 0;\n"
16949
" BracketStart = -1;\n"
16950
" BracketEnd = -1;\n"
16951
" };\n"
16952
" while(Pos != Len)\n"
16953
" {\n"
16954
" let Char = Line[Pos];\n"
16955
" if(InBrackets)\n"
16956
" {\n"
16957
" if(Char == \"\\\"\")\n"
16958
" {\n"
16959
" BracketEnd = Pos;\n"
16960
" InBrackets = 0;\n"
16961
" }\n"
16962
" }\n"
16963
" else\n"
16964
" {\n"
16965
" if(Char == \"\\\"\")\n"
16966
" {\n"
16967
" BracketStart = Pos;\n"
16968
" InBrackets = 1;\n"
16969
" }\n"
16970
" else if(Char == \",\")\n"
16971
" {\n"
16972
" push();\n"
16973
" }\n"
16974
" }\n"
16975
" Pos++;\n"
16976
" }\n"
16977
" push();\n"
16978
" return Out;\n"
16979
"\n"
16980
"}\n"
16981
"\n"
16982
"function ParseCSVFile(Set, Result, Name)\n"
16983
"{\n"
16984
" let File = CreateCSVSetFile(Set, Name);\n"
16985
" let Lines = Result.split(/\\r?\\n/);\n"
16986
" let Headers, Data, DataSorted;\n"
16987
" let Columns = 0;\n"
16988
" for(let i = 0; i < Lines.length; ++i)\n"
16989
" {\n"
16990
" let LineData = ParseCSVLine(Lines[i]);\n"
16991
" if(i == 0)\n"
16992
" {\n"
16993
" Headers = LineData;\n"
16994
" Columns = Headers.length;\n"
16995
"\n"
16996
" Data = new Array(Columns);\n"
16997
" DataSorted = new Array(Columns);\n"
16998
" File.Data = Data;\n"
16999
" File.DataSorted = DataSorted;\n"
17000
" for(let j = 0; j < Columns; ++j)\n"
17001
" {\n"
17002
" Data[j] = new Array();\n"
17003
" DataSorted[j] = new Array();\n"
17004
"\n"
17005
" let ColumnName = Headers[j];\n"
17006
" File.ColumnToIndex[Headers[j]] = j;\n"
17007
" File.Columns[ColumnName] = Data[j];\n"
17008
" File.ColumnsSorted[ColumnName] = DataSorted[j];\n"
17009
" Set.ColumnNames[ColumnName] = 1;\n"
17010
" }\n"
17011
" }\n"
17012
" else\n"
17013
" {\n"
17014
" if(LineData.length != Columns)\n"
17015
" {\n"
17016
" console.error(\"Failed to parse csv file \", Name);\n"
17017
" Set.PendingCount--;\n"
17018
" Set.FinishedCount--;\n"
17019
" ParseCSVCheckFinished(Set.Name);\n"
17020
" debugger;\n"
17021
"\n"
17022
" }\n"
17023
" for(let j = 0; j < Columns; ++j)\n"
17024
" {\n"
17025
" Data[j].push(parseFloat(LineData[j]));\n"
17026
" DataSorted[j].push(parseFloat(LineData[j]));\n"
17027
" }\n"
17028
" }\n"
17029
" }\n"
17030
" for(let j = 0; j < Columns; ++j)\n"
17031
" {\n"
17032
" DataSorted[j].sort();\n"
17033
"\n"
17034
" }\n"
17035
" Set.Files[Name] = File;\n"
17036
" Set.FinishedCount++;\n"
17037
" ParseCSVCheckFinished(Set.Name);\n"
17038
"\n"
17039
"}\n"
17040
"\n"
17041
"function ReadCSVFile(Set, File)\n"
17042
"{\n"
17043
" if(!File)\n"
17044
" return;\n"
17045
" let Reader = new FileReader();\n"
17046
" Reader.onload = function(e) {\n"
17047
" ParseCSVFile(Set, e.target.result, File.name);\n"
17048
" };\n"
17049
" Reader.onprogress = function(e)\n"
17050
" {\n"
17051
" var m = e.loaded + \":\" + e.total + \" :: \" + e.lengthComputable;\n"
17052
" console.log(m);\n"
17053
" };\n"
17054
" Set.PendingCount++;\n"
17055
" Reader.readAsText(File);\n"
17056
"\n"
17057
"}\n"
17058
"\n"
17059
"// magic from stack-overflow somewhere..\n"
17060
"function WindowDragEnter(e)\n"
17061
"{\n"
17062
" LastDropTarget = e.target;\n"
17063
" document.querySelector(\".dropzone\").style.visibility = \"\";\n"
17064
" document.querySelector(\".dropzone\").style.opacity = 1;\n"
17065
"};\n"
17066
"\n"
17067
"function WindowDragLeave(e)\n"
17068
"{\n"
17069
" if(e.target === LastDropTarget || e.target === document)\n"
17070
" {\n"
17071
" document.querySelector(\".dropzone\").style.visibility = \"hidden\";\n"
17072
" document.querySelector(\".dropzone\").style.opacity = 0;\n"
17073
" }\n"
17074
"};\n"
17075
"function DropHandler(ev)\n"
17076
"{\n"
17077
" document.querySelector(\".dropzone\").style.visibility = \"hidden\";\n"
17078
" document.querySelector(\".dropzone\").style.opacity = 0;\n"
17079
" LastDropTarget = null;\n"
17080
"\n"
17081
" let Set = CreateCSVSet();\n"
17082
" Set.PendingCount++;\n"
17083
" CSVSets[Set.Name] = Set;\n"
17084
" for(let i = 0; i < ev.dataTransfer.files.length; ++i)\n"
17085
" {\n"
17086
" let File = ev.dataTransfer.files[i];\n"
17087
" let Name = File.name;\n"
17088
" let ExtMatch = Name.match(/\\.[0-9a-zA-Z]+$/);\n"
17089
" let Ext = ExtMatch ? ExtMatch[0] : \"\";\n"
17090
" if(Ext.toLowerCase() == \".csv\")\n"
17091
" {\n"
17092
" ReadCSVFile(Set, File);\n"
17093
" }\n"
17094
" else\n"
17095
" {\n"
17096
" console.log(\"Not a .csv file!\\n\" + Name);\n"
17097
" }\n"
17098
" }\n"
17099
" if(0 == Set.PendingCount)\n"
17100
" {\n"
17101
" window.alert(\"No dropped CSV files. Please drop one or more csv files to use csv viewer\");\n"
17102
" }\n"
17103
" Set.FinishedCount++;\n"
17104
" ParseCSVCheckFinished(Set.Name);\n"
17105
" ev.preventDefault();\n"
17106
"}\n"
17107
"\n"
17108
"function DragOverHandler(ev)\n"
17109
"{\n"
17110
" ev.preventDefault();\n"
17111
"}\n"
17112
"\n"
17113
"if (\"serviceWorker\" in navigator) {\n"
17114
" navigator.serviceWorker.register(\"service-worker.js\")\n"
17115
" .then(() => console.log(\"Service Worker registered\"))\n"
17116
" .catch(err => console.error(\"SW registration failed\", err));\n"
17117
"}\n"
17118
"\n"
17119
"ReadCookie();\n"
17120
"ParseUrl();\n"
17121
"ResizeCanvas();\n"
17122
"SetupEvents();\n"
17123
"InitMenu();\n"
17124
"window.addEventListener(\"dragenter\", WindowDragEnter);\n"
17125
"window.addEventListener(\"dragleave\", WindowDragLeave);\n"
17126
"setInterval(Connect, 100);\n"
17127
"RequestDraw();\n"
17128
"\n"
17129
"\n"
17130
"</script>\n"
17131
"</body>\n"
17132
"</html>\n"
17133
"";
17134
17135
const size_t g_MicroProfileHtmlLive_begin_5_size = sizeof(g_MicroProfileHtmlLive_begin_5);
17136
const char* g_MicroProfileHtmlLive_begin[] = {
17137
&g_MicroProfileHtmlLive_begin_0[0],
17138
&g_MicroProfileHtmlLive_begin_1[0],
17139
&g_MicroProfileHtmlLive_begin_2[0],
17140
&g_MicroProfileHtmlLive_begin_3[0],
17141
&g_MicroProfileHtmlLive_begin_4[0],
17142
&g_MicroProfileHtmlLive_begin_5[0],
17143
};
17144
size_t g_MicroProfileHtmlLive_begin_sizes[] = {
17145
sizeof(g_MicroProfileHtmlLive_begin_0),
17146
sizeof(g_MicroProfileHtmlLive_begin_1),
17147
sizeof(g_MicroProfileHtmlLive_begin_2),
17148
sizeof(g_MicroProfileHtmlLive_begin_3),
17149
sizeof(g_MicroProfileHtmlLive_begin_4),
17150
sizeof(g_MicroProfileHtmlLive_begin_5),
17151
};
17152
size_t g_MicroProfileHtmlLive_begin_count = 6;
17153
const char* g_MicroProfileHtmlLive_end[] = {
17154
""};
17155
size_t g_MicroProfileHtmlLive_end_sizes[] = {
17156
0};
17157
size_t g_MicroProfileHtmlLive_end_count = 0;
17158
#endif //MICROPROFILE_EMBED_HTML
17159
17160
///end file generated from microprofilelive.html
17161
17162