Optimization of "list_metrics" function