-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmetrics.html
More file actions
609 lines (553 loc) · 16.5 KB
/
metrics.html
File metadata and controls
609 lines (553 loc) · 16.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
<!doctype html>
<html lang="en">
<head>
<title>SynFlow metrics dashboard</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="stylesheet" href="metrics.css" />
</head>
<body>
<div class="dashboard-shell">
<header class="topbar">
<div>
<p class="eyebrow">SynFlow analytics</p>
<h1>Rendering performance</h1>
</div>
<div class="topbar-actions">
<button class="btn btn-secondary" onclick="downloadCSV()">
Export CSV
</button>
<button class="btn btn-primary" onclick="updateCharts()">
Refresh
</button>
</div>
</header>
<section class="filters-panel">
<div class="filter-card filter-card-wide">
<label class="filter-label" for="modeFilter">Input mode</label>
<select id="modeFilter" class="field">
<option value="">All</option>
<option value="existing">Existing</option>
</select>
</div>
<div class="filter-card">
<div class="filter-head">
<label class="filter-label" for="genomesMin">Genomes</label>
<span class="filter-value"><span id="genomesMinVal">1</span> -
<span id="genomesMaxVal">20</span></span>
</div>
<div class="range-group">
<input type="range" id="genomesMin" min="1" max="20" value="1" />
<input type="range" id="genomesMax" min="1" max="20" value="20" />
</div>
</div>
<div class="filter-card">
<div class="filter-head">
<label class="filter-label" for="chromMax">Chromosomes</label>
<span class="filter-value" id="chromMaxVal">50</span>
</div>
<input type="range" id="chromMax" min="1" max="50" value="50" />
</div>
<div class="filter-card">
<div class="filter-head">
<label class="filter-label" for="bandsMax">Bands</label>
<span class="filter-value" id="bandsMaxVal">10000</span>
</div>
<input type="range" id="bandsMax" min="100" max="10000" value="10000" />
</div>
<div class="filter-card">
<div class="filter-head">
<label class="filter-label" for="coresMin">CPU cores</label>
<span class="filter-value"><span id="coresMinVal">1</span> -
<span id="coresMaxVal">16</span></span>
</div>
<div class="range-group">
<input type="range" id="coresMin" min="1" max="16" value="1" />
<input type="range" id="coresMax" min="1" max="16" value="16" />
</div>
</div>
<div class="filter-card filter-card-wide">
<label class="filter-label" for="ramFilter">Memory</label>
<select id="ramFilter" class="field">
<option value="">All</option>
<option value="4">≤4 GB</option>
<option value="8">8 GB</option>
<option value="16">≥16 GB</option>
</select>
</div>
</section>
<section class="charts-grid">
<article class="chart-card chart-card-large">
<div class="chart-card-head">
<h2>Duration vs bands</h2>
<p>Rendering time based on band count.</p>
</div>
<div class="chart-wrap">
<canvas id="chartDurationVsBands"></canvas>
</div>
</article>
<article class="chart-card chart-card-large">
<div class="chart-card-head">
<h2>Mean duration by bands</h2>
<p>Average rendering time based on band count.</p>
</div>
<div class="chart-wrap">
<canvas id="chartMeanStdPerBand"></canvas>
</div>
</article>
<article class="chart-card chart-card-large">
<div class="chart-card-head">
<h2>Duration vs chromosomes</h2>
<p>Rendering time based on chromosome count.</p>
</div>
<div class="chart-wrap">
<canvas id="chartDurationVsChromosomes"></canvas>
</div>
</article>
<article class="chart-card chart-card-large">
<div class="chart-card-head">
<h2>Duration vs genomes</h2>
<p>Rendering time based on genome count.</p>
</div>
<div class="chart-wrap">
<canvas id="chartDurationVsGenomes"></canvas>
</div>
</article>
<article class="chart-card chart-card-large">
<div class="chart-card-head">
<h2>Duration vs CPU cores</h2>
<p>Rendering time based on CPU core count.</p>
</div>
<div class="chart-wrap">
<canvas id="chartDurationVsCores"></canvas>
</div>
</article>
<article class="chart-card chart-card-large">
<div class="chart-card-head">
<h2>Duration vs memory</h2>
<p>Rendering time based on RAM capacity.</p>
</div>
<div class="chart-wrap">
<canvas id="chartDurationVsRam"></canvas>
</div>
</article>
</section>
</div>
<div class="chart-container">
<canvas id="chartDurationVsBands"></canvas>
</div>
<div class="chart-container">
<canvas id="chartDurationVsGenomes"></canvas>
</div>
<div class="chart-container">
<canvas id="chartDurationVsChromosomes"></canvas>
</div>
<div class="chart-container">
<canvas id="chartDurationVsCores"></canvas>
</div>
<div class="chart-container">
<canvas id="chartDurationVsRam"></canvas>
</div>
<div class="chart-container">
<canvas id="chartMeanStdPerBand"></canvas>
</div>
<script>
let allData = [];
let charts = {};
const pointHoverRadius = 3;
const pointRadius = 2;
const chartColors = {
green: {
fill: "rgb(16, 111, 104, 0.20)",
fillStrong: "rgb(16, 111, 104, 0.35)",
stroke: "rgb(16, 111, 104, 0.75)",
strokeStrong: "rgb(16, 111, 104, 0.95)",
hover: "rgb(16, 111, 104, 1)"
},
};
// 1. Charge et parse metrics.log (JSONL)
async function loadMetrics() {
try {
const response = await fetch(
"https://synflow.southgreen.fr/tmp/toolkit_run/metrics.log",
);
const text = await response.text();
allData = text
.trim()
.split("\n")
.map((line) => JSON.parse(line))
// AJOUT DE nbGenomes manquant
.map((d) => {
const ctx = d.context || d; // Ancien format = direct root
const env = d.env || {};
return {
ts: d.ts,
durationMs: d.durationMs,
nbGenomes: ctx.selectedGenomes ? ctx.selectedGenomes : 0,
nbChromosomes: ctx.nbChromosomes || 0,
nbBandes: ctx.nbBandes || 0,
mode: ctx.mode || "",
cores: env.cores || 0,
deviceMemory: env.deviceMemory || 0,
userAgent: env.userAgent || "",
browser: env.userAgent ? env.userAgent.split(" ")[0] : "", // Chrome, Firefox...
};
});
console.log(`${allData.length} mesures chargées`, allData[0]);
updateSlidersRange(); //NOUVEAU : adapte les sliders
updateCharts();
} catch (e) {
console.error("Erreur:", e);
}
}
// 2. Calcule stats et met à jour graphiques
function updateCharts() {
const filteredData = filterData();
console.log("Données filtrées:", filteredData.length);
updateChart(
"Render time vs number of chromosomes",
filteredData,
"chartDurationVsChromosomes",
"scatter",
"nbChromosomes",
"durationMs",
"Chromosomes",
"Time (ms)",
);
updateChart(
"Render time vs number of bands",
filteredData,
"chartDurationVsBands",
"scatter",
"nbBandes",
"durationMs",
"Bandes",
"Time (ms)",
);
updateChart(
"Render time vs number of genomes",
filteredData,
"chartDurationVsGenomes",
"scatter",
"nbGenomes",
"durationMs",
"Genomes",
"Time (ms)",
);
updateChart(
"Render time vs CPU Cores",
filteredData,
"chartDurationVsCores",
"scatter",
"cores",
"durationMs",
"CPU Cores",
"Time (ms)",
);
updateChart(
"Render time vs RAM",
filteredData,
"chartDurationVsRam",
"scatter",
"deviceMemory",
"durationMs",
"RAM (GB)",
"Time (ms)",
);
updateMeanStdPerBandChart(filteredData);
}
// 3. Filtre CORRIGÉ (par défaut tout accepte)
function filterData() {
const mode = document.getElementById("modeFilter").value;
const minGenomes =
Number.parseInt(document.getElementById("genomesMin").value) || 1;
const maxGenomes =
Number.parseInt(document.getElementById("genomesMax").value) ||
Infinity;
const maxChrom =
Number.parseInt(document.getElementById("chromMax").value) ||
Infinity;
const maxBands =
Number.parseInt(document.getElementById("bandsMax").value) ||
Infinity;
// NOUVEAUX FILTRES MACHINE
const minCores =
Number.parseInt(document.getElementById("coresMin").value) || 1;
const maxCores =
Number.parseInt(document.getElementById("coresMax").value) ||
Infinity;
const ramFilter = document.getElementById("ramFilter").value;
return allData.filter((d) => {
const baseOk =
d.nbGenomes >= minGenomes &&
d.nbGenomes <= maxGenomes &&
(d.nbChromosomes || 0) <= maxChrom &&
(d.nbBandes || 0) <= maxBands &&
(!mode || d.mode === mode);
const coresOk = d.cores >= minCores && d.cores <= maxCores;
const ramOk =
!ramFilter ||
(ramFilter === "4" && d.deviceMemory <= 4) ||
(ramFilter === "8" && d.deviceMemory === 8) ||
(ramFilter === "16" && d.deviceMemory >= 16);
return baseOk && coresOk && ramOk;
});
}
function groupByBandsBins(data, binSize = 100) {
const bins = new Map();
data.forEach((d) => {
const bands = d.nbBandes || 0;
const binIndex = Math.floor(bands / binSize);
const start = binIndex === 0 ? 0 : binIndex * binSize + 1;
const end = (binIndex + 1) * binSize;
const key = `${start}-${end}`;
if (!bins.has(key)) {
bins.set(key, {
start,
end,
values: [],
});
}
bins.get(key).values.push(d.durationMs);
});
const sortedBins = Array.from(bins.values()).sort((a, b) => a.start - b.start);
return {
labels: sortedBins.map((bin) => `${bin.end}`),
means: sortedBins.map((bin) => {
const n = bin.values.length;
return n ? bin.values.reduce((sum, v) => sum + v, 0) / n : 0;
}),
stds: sortedBins.map((bin) => {
const n = bin.values.length;
if (!n) return 0;
const mean = bin.values.reduce((sum, v) => sum + v, 0) / n;
const variance =
bin.values.reduce((sum, v) => sum + Math.pow(v - mean, 2), 0) / n;
return Math.sqrt(variance);
}),
};
}
function updateMeanStdPerBandChart(data) {
const ctx = document
.getElementById("chartMeanStdPerBand")
.getContext("2d");
if (charts["chartMeanStdPerBand"])
charts["chartMeanStdPerBand"].destroy();
const stats = groupByBandsBins(data, 100);
if (stats.labels.length === 0) return;
const errorBarData = stats.labels.map((bands, i) => {
const mean = stats.means[i];
const std = stats.stds[i];
return {
x: bands,
y: mean,
yMin: mean - std,
yMax: mean + std,
};
});
const color = chartColors.green;
charts["chartMeanStdPerBand"] = new Chart(ctx, {
type: "bar",
data: {
labels: stats.labels,
datasets: [
{
label: "Mean time",
data: errorBarData,
backgroundColor: color.fillStrong,
borderColor: color.stroke,
borderWidth: 1,
hoverBackgroundColor: color.hover,
},
],
},
options: {
responsive: true,
maintainAspectRatio: false,
animation: false,
plugins: {
tooltip: {
callbacks: {
label: (ctx) => {
const d = ctx.raw;
const mean = d.y.toFixed(1);
const std = (d.yMax - d.y).toFixed(1);
return `~${mean} ms`;
},
},
},
},
scales: {
x: {
title: { display: true, text: "Number of bands" },
},
y: {
title: { display: true, text: "Time (ms)" },
beginAtZero: true,
},
},
},
});
}
// 4. Graphique scatter avec ÉCHELLES DYNAMIQUES
function updateChart(
title,
data,
canvasId,
type,
xKey,
yKey,
xLabel,
yLabel,
) {
const ctx = document.getElementById(canvasId).getContext("2d");
if (charts[canvasId]) charts[canvasId].destroy();
const points = data.map((d) => ({
x: d[xKey] || 0,
y: d[yKey] || 0,
}));
const avgTime =
data.reduce((sum, d) => sum + (d[yKey] || 0), 0) / data.length;
const dynamicScales = getDynamicScales(data, xKey, yKey);
const color = chartColors.green;
charts[canvasId] = new Chart(ctx, {
type: "scatter",
data: {
datasets: [
{
label: `${title}`,
data: points,
backgroundColor: color.fill,
borderColor: color.stroke,
borderWidth: 1,
pointRadius: pointRadius,
pointHoverRadius: pointHoverRadius,
},
],
},
options: {
responsive: true,
maintainAspectRatio: false,
animation: false,
plugins: {
legend: { display: true },
},
scales: {
x: {
type: "linear",
position: "bottom",
title: { display: true, text: xLabel },
min: dynamicScales.x.min,
max: dynamicScales.x.max,
},
y: {
title: { display: true, text: yLabel },
min: dynamicScales.y.min,
max: dynamicScales.y.max,
},
},
interaction: {
intersect: false,
mode: "point",
},
},
});
}
// 7. Export CSV
function downloadCSV() {
const data = filterData();
let csv =
"ts,durationMs,action,mode,nbGenomes,nbChromosomes,nbBandes\n";
data.forEach((d) => {
csv += `${d.ts},${Math.round(d.durationMs)},${d.action},${d.mode},${d.nbGenomes},${d.nbChromosomes},${d.nbBandes}\n`;
});
const blob = new Blob([csv], { type: "text/csv" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = `metrics-${new Date().toISOString().slice(0, 10)}.csv`;
a.click();
}
// 8. Écouteurs + AUTO-UPDATE
document.addEventListener("DOMContentLoaded", function () {
// TOUS les écouteurs
document.getElementById("genomesMin").oninput = function () {
document.getElementById("genomesMinVal").textContent = this.value;
updateCharts();
};
document.getElementById("genomesMax").oninput = function () {
document.getElementById("genomesMaxVal").textContent = this.value;
updateCharts();
};
document.getElementById("coresMin").oninput = function () {
document.getElementById("coresMinVal").textContent = this.value;
updateCharts();
};
document.getElementById("coresMax").oninput = function () {
document.getElementById("coresMaxVal").textContent = this.value;
updateCharts();
};
document.getElementById("chromMax").oninput = function () {
document.getElementById("chromMaxVal").textContent = this.value;
updateCharts();
};
document.getElementById("bandsMax").oninput = function () {
document.getElementById("bandsMaxVal").textContent = this.value;
updateCharts();
};
document.getElementById("modeFilter").onchange = updateCharts;
document.getElementById("ramFilter").onchange = updateCharts;
loadMetrics();
});
// 9. ADAPTATION AUTOMATIQUE DES SLIDERS
function updateSlidersRange() {
if (allData.length === 0) return;
const maxGenomes = Math.max(...allData.map((d) => d.nbGenomes));
const maxChromosomes = Math.max(
...allData.map((d) => d.nbChromosomes || 0),
);
const maxBands = Math.max(...allData.map((d) => d.nbBandes || 0));
const maxCores = Math.max(...allData.map((d) => d.cores || 0));
// Génomes
document.getElementById("genomesMin").max = maxGenomes;
document.getElementById("genomesMax").max = maxGenomes;
document.getElementById("genomesMin").value = 1;
document.getElementById("genomesMax").value = maxGenomes;
document.getElementById("genomesMinVal").textContent = 1;
document.getElementById("genomesMaxVal").textContent = maxGenomes;
// Chromosomes
document.getElementById("chromMax").max = maxChromosomes;
document.getElementById("chromMax").value = maxChromosomes;
document.getElementById("chromMaxVal").textContent = maxChromosomes;
// Bandes
document.getElementById("bandsMax").max = maxBands;
document.getElementById("bandsMax").value = maxBands;
document.getElementById("bandsMaxVal").textContent = maxBands;
// Cores
document.getElementById("coresMin").max = maxCores;
document.getElementById("coresMax").max = maxCores;
document.getElementById("coresMin").value = 1;
document.getElementById("coresMax").value = maxCores;
document.getElementById("coresMinVal").textContent = 1;
document.getElementById("coresMaxVal").textContent = maxCores;
console.log(
`🎛️ Sliders OK: G${maxGenomes} C${maxChromosomes} B${maxBands} CPU${maxCores}`,
);
}
// 10. Échelles dynamiques pour les graphiques
function getDynamicScales(data, xKey, yKey) {
const xValues = data.map((d) => d[xKey] || 0);
const yValues = data.map((d) => d[yKey] || 0);
return {
x: {
min: Math.min(...xValues) * 0.95,
max: Math.max(...xValues) * 1.05,
},
y: {
min: 0,
max: Math.max(...yValues) * 1.1,
},
};
}
</script>
</body>
</html>