Skip to content

Feature: Dynamic Metric Filtering for Visualizations #6

Description

@vigsun19

Feature: Dynamic Metric Filtering for Visualizations

Description

Enhance the plot_profiling_stats function in visualizer.py to allow dynamic filtering of metrics (e.g., show only execution_time above a threshold, or exclude zero-value metrics). Add options to customize the visualization (e.g., bar colors, plot styles, logarithmic scales).

Why This is Needed

The current visualization in SmartProfiler shows all metrics, which can be cluttered if some metrics are zero or irrelevant. Users need the ability to focus on specific metrics (e.g., filter out zero values, show only metrics above a threshold) and customize the visual appearance (e.g., change bar colors, use logarithmic scales for large values). This will make visualizations more practical and user-friendly.

Proposed Implementation

  • Add optional parameters to plot_profiling_stats:
    • metric_threshold (dict): Filter metrics based on thresholds (e.g., {"execution_time": 0.1} to show only execution_time > 0.1).
    • exclude_zero (bool): Exclude metrics with zero values.
    • bar_colors (list): List of colors for bars (e.g., ["blue", "green", "red"]).
    • use_log_scale (bool): Use a logarithmic scale for the y-axis.
  • Update the visualization logic to apply these filters before plotting.
  • Add unit tests for the new parameters.
  • Update examples_visualization.py to demonstrate the new options.

Acceptance Criteria

  • Users can filter metrics with metric_threshold (e.g., plot_profiling_stats(..., metric_threshold={"execution_time": 0.1})).
  • Users can exclude zero-value metrics with exclude_zero=True.
  • Users can customize bar colors with bar_colors=["blue", "green", ...].
  • Users can use a logarithmic scale with use_log_scale=True.
  • Visualizations render correctly with all new options.
  • Unit tests pass for the new visualization features.
  • Update README.md with examples of the new visualization options.

Complexity

Medium (requires updating visualization logic and adding new parameters).

User Value

High (enhances usability of visualizations, a key feature).

Related Issues

  • None

Additional Notes

  • Consider adding more customization options in future releases (e.g., plot titles, legend styles).
  • Ensure backwards compatibility with existing plot_profiling_stats usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions