{"action":"created","comment":{"url":"https://api.github.com/repos/amzn/hawktracer/pulls/comments/190410452","pull_request_review_id":122765497,"id":190410452,"diff_hunk":"@@ -0,0 +1,107 @@\n+#include \"call_graph.hpp\"\n+\n+#include <algorithm>\n+\n+namespace HawkTracer\n+{\n+namespace client\n+{\n+\n+std::vector<std::pair<std::shared_ptr<CallGraph::TreeNode>, int>> \n+    CallGraph::make(std::vector<NodeData>& events)\n+{\n+    std::sort(events.begin(), events.end(), \n+            [](const NodeData& e1, const NodeData& e2){\n+                return e1.start_ts < e2.start_ts;\n+            });\n+    for (const auto& event : events)\n+    {\n+        _add_event(event);\n+    }\n+\n+    return _root_calls;\n+}\n+\n+void CallGraph::_add_new_calltree(NodeData& node_data)\n+{\n+    std::string label = node_data.label;\n+    auto call = std::find_if(_root_calls.begin(), _root_calls.end(),\n+            [&label](const std::pair<std::shared_ptr<TreeNode>, int>& call) {\n+                return call.first.get()->data.label == label;\n+            });\n+    if (call != _root_calls.end())\n+    {\n+        call->first->total_duration += node_data.get_duration();\n+        call->first->data = node_data;\n+        ++call->second;\n+        _current_call = call->first;\n+    }\n+    else\n+    {\n+        _current_call = std::make_shared<TreeNode>(node_data);\n+        _root_calls.emplace_back(_current_call, 1);\n+    }\n+\n+}\n+\n+std::shared_ptr<CallGraph::TreeNode> CallGraph::_add_new_event_call(std::shared_ptr<TreeNode>& caller,\n+                                                                    NodeData& node_data)\n+{\n+    caller->total_children_duration += node_data.get_duration();\n+\n+    std::string label = node_data.label;\n+    auto call = std::find_if(caller->children.begin(), caller->children.end(),\n+            [&label](const std::pair<std::shared_ptr<TreeNode>, int>& child) {\n+                return child.first.get()->data.label == label;","path":"client/call_graph.cpp","position":55,"original_position":55,"commit_id":"c0dc36865897acb0672fdd71adfecfc658aee89a","original_commit_id":"c0dc36865897acb0672fdd71adfecfc658aee89a","user":{"login":"loganek","id":3201489,"avatar_url":"https://avatars2.githubusercontent.com/u/3201489?v=4","gravatar_id":"","url":"https://api.github.com/users/loganek","html_url":"https://github.com/loganek","followers_url":"https://api.github.com/users/loganek/followers","following_url":"https://api.github.com/users/loganek/following{/other_user}","gists_url":"https://api.github.com/users/loganek/gists{/gist_id}","starred_url":"https://api.github.com/users/loganek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loganek/subscriptions","organizations_url":"https://api.github.com/users/loganek/orgs","repos_url":"https://api.github.com/users/loganek/repos","events_url":"https://api.github.com/users/loganek/events{/privacy}","received_events_url":"https://api.github.com/users/loganek/received_events","type":"User","site_admin":false},"body":"I think you don't need `get()` here as `shared_ptr` has `operator->()` defined: [http://en.cppreference.com/w/cpp/memory/shared_ptr/operator*](http://en.cppreference.com/w/cpp/memory/shared_ptr/operator*)","created_at":"2018-05-23T21:51:32Z","updated_at":"2018-05-23T21:56:15Z","html_url":"https://github.com/amzn/hawktracer/pull/23#discussion_r190410452","pull_request_url":"https://api.github.com/repos/amzn/hawktracer/pulls/23","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/amzn/hawktracer/pulls/comments/190410452"},"html":{"href":"https://github.com/amzn/hawktracer/pull/23#discussion_r190410452"},"pull_request":{"href":"https://api.github.com/repos/amzn/hawktracer/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/amzn/hawktracer/pulls/23","id":189684667,"html_url":"https://github.com/amzn/hawktracer/pull/23","diff_url":"https://github.com/amzn/hawktracer/pull/23.diff","patch_url":"https://github.com/amzn/hawktracer/pull/23.patch","issue_url":"https://api.github.com/repos/amzn/hawktracer/issues/23","number":23,"state":"open","locked":false,"title":"Implemented callgrind converter","user":{"login":"mapaaa","id":26182601,"avatar_url":"https://avatars1.githubusercontent.com/u/26182601?v=4","gravatar_id":"","url":"https://api.github.com/users/mapaaa","html_url":"https://github.com/mapaaa","followers_url":"https://api.github.com/users/mapaaa/followers","following_url":"https://api.github.com/users/mapaaa/following{/other_user}","gists_url":"https://api.github.com/users/mapaaa/gists{/gist_id}","starred_url":"https://api.github.com/users/mapaaa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapaaa/subscriptions","organizations_url":"https://api.github.com/users/mapaaa/orgs","repos_url":"https://api.github.com/users/mapaaa/repos","events_url":"https://api.github.com/users/mapaaa/events{/privacy}","received_events_url":"https://api.github.com/users/mapaaa/received_events","type":"User","site_admin":false},"body":"*Issue #, if available:*\r\n\r\n*Description of changes:*\r\nConverter base class is getting an event's label.\r\nCallgrind Converter firstly stores all the events and then starts the actual conversion to callgrind format. It keeps for each thread the roots of all traced calls and it builds the call graph. \r\nI'll add tests for this in a different PR.\r\n\r\n\r\nBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.\r\n","created_at":"2018-05-22T14:33:53Z","updated_at":"2018-05-23T21:56:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b48abead21ce1032b56bd1b34dc02aca47e87670","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/amzn/hawktracer/pulls/23/commits","review_comments_url":"https://api.github.com/repos/amzn/hawktracer/pulls/23/comments","review_comment_url":"https://api.github.com/repos/amzn/hawktracer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/amzn/hawktracer/issues/23/comments","statuses_url":"https://api.github.com/repos/amzn/hawktracer/statuses/c0dc36865897acb0672fdd71adfecfc658aee89a","head":{"label":"mapaaa:master","ref":"master","sha":"c0dc36865897acb0672fdd71adfecfc658aee89a","user":{"login":"mapaaa","id":26182601,"avatar_url":"https://avatars1.githubusercontent.com/u/26182601?v=4","gravatar_id":"","url":"https://api.github.com/users/mapaaa","html_url":"https://github.com/mapaaa","followers_url":"https://api.github.com/users/mapaaa/followers","following_url":"https://api.github.com/users/mapaaa/following{/other_user}","gists_url":"https://api.github.com/users/mapaaa/gists{/gist_id}","starred_url":"https://api.github.com/users/mapaaa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapaaa/subscriptions","organizations_url":"https://api.github.com/users/mapaaa/orgs","repos_url":"https://api.github.com/users/mapaaa/repos","events_url":"https://api.github.com/users/mapaaa/events{/privacy}","received_events_url":"https://api.github.com/users/mapaaa/received_events","type":"User","site_admin":false},"repo":{"id":132777007,"name":"hawktracer","full_name":"mapaaa/hawktracer","owner":{"login":"mapaaa","id":26182601,"avatar_url":"https://avatars1.githubusercontent.com/u/26182601?v=4","gravatar_id":"","url":"https://api.github.com/users/mapaaa","html_url":"https://github.com/mapaaa","followers_url":"https://api.github.com/users/mapaaa/followers","following_url":"https://api.github.com/users/mapaaa/following{/other_user}","gists_url":"https://api.github.com/users/mapaaa/gists{/gist_id}","starred_url":"https://api.github.com/users/mapaaa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapaaa/subscriptions","organizations_url":"https://api.github.com/users/mapaaa/orgs","repos_url":"https://api.github.com/users/mapaaa/repos","events_url":"https://api.github.com/users/mapaaa/events{/privacy}","received_events_url":"https://api.github.com/users/mapaaa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mapaaa/hawktracer","description":"HawkTracer is a highly portable, low-overhead, configurable profiling tool built in Amazon Video for getting performance metrics from low-end devices.","fork":true,"url":"https://api.github.com/repos/mapaaa/hawktracer","forks_url":"https://api.github.com/repos/mapaaa/hawktracer/forks","keys_url":"https://api.github.com/repos/mapaaa/hawktracer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mapaaa/hawktracer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mapaaa/hawktracer/teams","hooks_url":"https://api.github.com/repos/mapaaa/hawktracer/hooks","issue_events_url":"https://api.github.com/repos/mapaaa/hawktracer/issues/events{/number}","events_url":"https://api.github.com/repos/mapaaa/hawktracer/events","assignees_url":"https://api.github.com/repos/mapaaa/hawktracer/assignees{/user}","branches_url":"https://api.github.com/repos/mapaaa/hawktracer/branches{/branch}","tags_url":"https://api.github.com/repos/mapaaa/hawktracer/tags","blobs_url":"https://api.github.com/repos/mapaaa/hawktracer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mapaaa/hawktracer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mapaaa/hawktracer/git/refs{/sha}","trees_url":"https://api.github.com/repos/mapaaa/hawktracer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mapaaa/hawktracer/statuses/{sha}","languages_url":"https://api.github.com/repos/mapaaa/hawktracer/languages","stargazers_url":"https://api.github.com/repos/mapaaa/hawktracer/stargazers","contributors_url":"https://api.github.com/repos/mapaaa/hawktracer/contributors","subscribers_url":"https://api.github.com/repos/mapaaa/hawktracer/subscribers","subscription_url":"https://api.github.com/repos/mapaaa/hawktracer/subscription","commits_url":"https://api.github.com/repos/mapaaa/hawktracer/commits{/sha}","git_commits_url":"https://api.github.com/repos/mapaaa/hawktracer/git/commits{/sha}","comments_url":"https://api.github.com/repos/mapaaa/hawktracer/comments{/number}","issue_comment_url":"https://api.github.com/repos/mapaaa/hawktracer/issues/comments{/number}","contents_url":"https://api.github.com/repos/mapaaa/hawktracer/contents/{+path}","compare_url":"https://api.github.com/repos/mapaaa/hawktracer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mapaaa/hawktracer/merges","archive_url":"https://api.github.com/repos/mapaaa/hawktracer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mapaaa/hawktracer/downloads","issues_url":"https://api.github.com/repos/mapaaa/hawktracer/issues{/number}","pulls_url":"https://api.github.com/repos/mapaaa/hawktracer/pulls{/number}","milestones_url":"https://api.github.com/repos/mapaaa/hawktracer/milestones{/number}","notifications_url":"https://api.github.com/repos/mapaaa/hawktracer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mapaaa/hawktracer/labels{/name}","releases_url":"https://api.github.com/repos/mapaaa/hawktracer/releases{/id}","deployments_url":"https://api.github.com/repos/mapaaa/hawktracer/deployments","created_at":"2018-05-09T15:26:50Z","updated_at":"2018-05-23T18:03:23Z","pushed_at":"2018-05-23T18:03:21Z","git_url":"git://github.com/mapaaa/hawktracer.git","ssh_url":"git@github.com:mapaaa/hawktracer.git","clone_url":"https://github.com/mapaaa/hawktracer.git","svn_url":"https://github.com/mapaaa/hawktracer","homepage":null,"size":570,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"amzn:master","ref":"master","sha":"0286e39bc80404b35527aefc903ca784c175f874","user":{"login":"amzn","id":8594673,"avatar_url":"https://avatars1.githubusercontent.com/u/8594673?v=4","gravatar_id":"","url":"https://api.github.com/users/amzn","html_url":"https://github.com/amzn","followers_url":"https://api.github.com/users/amzn/followers","following_url":"https://api.github.com/users/amzn/following{/other_user}","gists_url":"https://api.github.com/users/amzn/gists{/gist_id}","starred_url":"https://api.github.com/users/amzn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amzn/subscriptions","organizations_url":"https://api.github.com/users/amzn/orgs","repos_url":"https://api.github.com/users/amzn/repos","events_url":"https://api.github.com/users/amzn/events{/privacy}","received_events_url":"https://api.github.com/users/amzn/received_events","type":"Organization","site_admin":false},"repo":{"id":128848910,"name":"hawktracer","full_name":"amzn/hawktracer","owner":{"login":"amzn","id":8594673,"avatar_url":"https://avatars1.githubusercontent.com/u/8594673?v=4","gravatar_id":"","url":"https://api.github.com/users/amzn","html_url":"https://github.com/amzn","followers_url":"https://api.github.com/users/amzn/followers","following_url":"https://api.github.com/users/amzn/following{/other_user}","gists_url":"https://api.github.com/users/amzn/gists{/gist_id}","starred_url":"https://api.github.com/users/amzn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amzn/subscriptions","organizations_url":"https://api.github.com/users/amzn/orgs","repos_url":"https://api.github.com/users/amzn/repos","events_url":"https://api.github.com/users/amzn/events{/privacy}","received_events_url":"https://api.github.com/users/amzn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/amzn/hawktracer","description":"HawkTracer is a highly portable, low-overhead, configurable profiling tool built in Amazon Video for getting performance metrics from low-end devices.","fork":false,"url":"https://api.github.com/repos/amzn/hawktracer","forks_url":"https://api.github.com/repos/amzn/hawktracer/forks","keys_url":"https://api.github.com/repos/amzn/hawktracer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amzn/hawktracer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amzn/hawktracer/teams","hooks_url":"https://api.github.com/repos/amzn/hawktracer/hooks","issue_events_url":"https://api.github.com/repos/amzn/hawktracer/issues/events{/number}","events_url":"https://api.github.com/repos/amzn/hawktracer/events","assignees_url":"https://api.github.com/repos/amzn/hawktracer/assignees{/user}","branches_url":"https://api.github.com/repos/amzn/hawktracer/branches{/branch}","tags_url":"https://api.github.com/repos/amzn/hawktracer/tags","blobs_url":"https://api.github.com/repos/amzn/hawktracer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amzn/hawktracer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amzn/hawktracer/git/refs{/sha}","trees_url":"https://api.github.com/repos/amzn/hawktracer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amzn/hawktracer/statuses/{sha}","languages_url":"https://api.github.com/repos/amzn/hawktracer/languages","stargazers_url":"https://api.github.com/repos/amzn/hawktracer/stargazers","contributors_url":"https://api.github.com/repos/amzn/hawktracer/contributors","subscribers_url":"https://api.github.com/repos/amzn/hawktracer/subscribers","subscription_url":"https://api.github.com/repos/amzn/hawktracer/subscription","commits_url":"https://api.github.com/repos/amzn/hawktracer/commits{/sha}","git_commits_url":"https://api.github.com/repos/amzn/hawktracer/git/commits{/sha}","comments_url":"https://api.github.com/repos/amzn/hawktracer/comments{/number}","issue_comment_url":"https://api.github.com/repos/amzn/hawktracer/issues/comments{/number}","contents_url":"https://api.github.com/repos/amzn/hawktracer/contents/{+path}","compare_url":"https://api.github.com/repos/amzn/hawktracer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amzn/hawktracer/merges","archive_url":"https://api.github.com/repos/amzn/hawktracer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amzn/hawktracer/downloads","issues_url":"https://api.github.com/repos/amzn/hawktracer/issues{/number}","pulls_url":"https://api.github.com/repos/amzn/hawktracer/pulls{/number}","milestones_url":"https://api.github.com/repos/amzn/hawktracer/milestones{/number}","notifications_url":"https://api.github.com/repos/amzn/hawktracer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amzn/hawktracer/labels{/name}","releases_url":"https://api.github.com/repos/amzn/hawktracer/releases{/id}","deployments_url":"https://api.github.com/repos/amzn/hawktracer/deployments","created_at":"2018-04-10T00:17:00Z","updated_at":"2018-05-22T21:58:36Z","pushed_at":"2018-05-23T18:03:23Z","git_url":"git://github.com/amzn/hawktracer.git","ssh_url":"git@github.com:amzn/hawktracer.git","clone_url":"https://github.com/amzn/hawktracer.git","svn_url":"https://github.com/amzn/hawktracer","homepage":null,"size":1107,"stargazers_count":14,"watchers_count":14,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":7,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":7,"open_issues":9,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/amzn/hawktracer/pulls/23"},"html":{"href":"https://github.com/amzn/hawktracer/pull/23"},"issue":{"href":"https://api.github.com/repos/amzn/hawktracer/issues/23"},"comments":{"href":"https://api.github.com/repos/amzn/hawktracer/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/amzn/hawktracer/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/amzn/hawktracer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/amzn/hawktracer/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/amzn/hawktracer/statuses/c0dc36865897acb0672fdd71adfecfc658aee89a"}},"author_association":"NONE"}}
{"actor":{"display_login":"loganek"}}