MCPcopy Create free account
hub / github.com/IBM/mcp-cli / format_performance

Function format_performance

src/mcp_cli/commands/utils.py:44–70  ·  view source on GitHub ↗

Format performance metrics with color coding. Args: ping_ms: Ping time in milliseconds (None if unavailable) Returns: Tuple of (icon, formatted_text) Example: >>> format_performance(25.5) ('✅', '25.5ms') >>> format_performance(None)

(ping_ms: float | None)

Source from the content-addressed store, hash-verified

42
43
44def format_performance(ping_ms: float | None) -> tuple[str, str]:
45 """
46 Format performance metrics with color coding.
47
48 Args:
49 ping_ms: Ping time in milliseconds (None if unavailable)
50
51 Returns:
52 Tuple of (icon, formatted_text)
53
54 Example:
55 >>> format_performance(25.5)
56 ('✅', '25.5ms')
57 >>> format_performance(None)
58 ('❓', 'Unknown')
59 """
60 if ping_ms is None:
61 return "❓", "Unknown"
62
63 if ping_ms < 10:
64 return "🚀", f"{ping_ms:.1f}ms"
65 elif ping_ms < 50:
66 return "✅", f"{ping_ms:.1f}ms"
67 elif ping_ms < 100:
68 return "⚠️", f"{ping_ms:.1f}ms"
69 else:
70 return "🔴", f"{ping_ms:.1f}ms"
71
72
73def get_server_icon(capabilities: dict[str, Any], tool_count: int) -> str:

Callers 8

test_none_pingMethod · 0.90
test_very_fast_pingMethod · 0.90
test_fast_pingMethod · 0.90
test_moderate_pingMethod · 0.90
test_slow_pingMethod · 0.90
test_edge_case_10msMethod · 0.90
test_edge_case_50msMethod · 0.90
test_edge_case_100msMethod · 0.90

Calls

no outgoing calls

Tested by 8

test_none_pingMethod · 0.72
test_very_fast_pingMethod · 0.72
test_fast_pingMethod · 0.72
test_moderate_pingMethod · 0.72
test_slow_pingMethod · 0.72
test_edge_case_10msMethod · 0.72
test_edge_case_50msMethod · 0.72
test_edge_case_100msMethod · 0.72