diff --git a/paddle/platform/profiler.cc b/paddle/platform/profiler.cc index 4283724d28afcbdeaceb36e6eafa3e0e2fd9f1f9..7e2e2d968ef877f6aa8b87ab8f044e89574dffa9 100644 --- a/paddle/platform/profiler.cc +++ b/paddle/platform/profiler.cc @@ -183,35 +183,35 @@ void ParseEvents(std::vector>& events, if (g_profiler_place == "") return; std::string sorted_domain; - std::function sorted_func; + std::function sorted_func; switch (sorted_by) { case EventSortingKey::kCalls: sorted_domain = "number of calls"; - sorted_func = [](EventItem& a, EventItem& b) { + sorted_func = [](const EventItem& a, const EventItem& b) { return a.calls > b.calls; }; break; case EventSortingKey::kTotal: sorted_domain = "total time"; - sorted_func = [](EventItem& a, EventItem& b) { + sorted_func = [](const EventItem& a, const EventItem& b) { return a.total_time > b.total_time; }; break; case EventSortingKey::kMin: sorted_domain = "minimum time"; - sorted_func = [](EventItem& a, EventItem& b) { + sorted_func = [](const EventItem& a, const EventItem& b) { return a.min_time > b.min_time; }; break; case EventSortingKey::kMax: sorted_domain = "maximum time"; - sorted_func = [](EventItem& a, EventItem& b) { + sorted_func = [](const EventItem& a, const EventItem& b) { return a.max_time > b.max_time; }; break; case EventSortingKey::kAve: sorted_domain = "average time"; - sorted_func = [](EventItem& a, EventItem& b) { + sorted_func = [](const EventItem& a, const EventItem& b) { return a.ave_time > b.ave_time; }; break;