MCPcopy Create free account
hub / github.com/LucaCanali/PyLatencyMap / _print_heat_map

Method _print_heat_map

LatencyMap.py:390–486  ·  view source on GitHub ↗
(self, chart_type: str)

Source from the content-addressed store, hash-verified

388 print(f"Label: {last.label}")
389
390 def _print_heat_map(self, chart_type: str) -> None:
391 assert chart_type in ('Frequency', 'Intensity')
392 if chart_type == 'Frequency':
393 params_maxval = g_params.frequency_maxval
394 palette = 'blue'
395 chart_maxval = max(r.max_frequency for r in self.data)
396 title = 'Frequency Heatmap: events per sec'
397 unit = '(N#/sec)'
398 else:
399 params_maxval = g_params.intensity_maxval
400 palette = 'red'
401 chart_maxval = max(r.max_intensity for r in self.data)
402 title = 'Intensity Heatmap: time waited per sec'
403 unit = f"({g_params.latency_unit}/sec)"
404
405 # Header line
406 left_axis_title = "Latency bucket"
407 line = left_axis_title.ljust(max(16, g_params.num_latency_records // 2 - 10))
408 line += title
409 line = line.ljust(g_params.num_latency_records + 2)
410 line += "Latest values"
411 if g_params.print_legend:
412 line += " Legend"
413 print(line)
414
415 line = "(millisec)".ljust(max(16, g_params.num_latency_records - len(unit) + 14))
416 line += unit
417 print(line)
418
419 # Determine color scale
420 max_val = chart_maxval if params_maxval == -1 else params_maxval
421
422 # Main map
423 row_idx = -1
424 for bucket in range(g_params.max_latency_bkt, g_params.min_latency_bkt - 1, -1):
425 row_idx += 1
426
427 # Left axis label
428 if bucket == g_params.max_latency_bkt:
429 label = ">" + self._bucket_ms_label(bucket - 1)
430 elif bucket == g_params.min_latency_bkt:
431 label = "<" + self._bucket_ms_label(bucket)
432 else:
433 label = self._bucket_ms_label(bucket)
434 line = label.rjust(6, ' ') + ' '
435
436 # Heat row: oldest→newest (left→right). Newest column is the RIGHT-most.
437 data_point = 0.0
438 for record in self.data:
439 if chart_type == 'Frequency':
440 data_point = record.frequency_histogram[bucket]
441 else:
442 data_point = record.intensity_histogram[bucket]
443
444 if data_point == 0:
445 token = 0
446 elif data_point >= max_val:
447 token = 6

Callers 1

renderMethod · 0.95

Calls 3

_bucket_ms_labelMethod · 0.95
_bg_colorMethod · 0.95
_fmt_valueMethod · 0.95

Tested by

no test coverage detected