{"action":"created","comment":{"url":"https://api.github.com/repos/OpenTTD/OpenTTD/pulls/comments/360705208","pull_request_review_id":335649974,"id":360705208,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDM2MDcwNTIwOA==","diff_hunk":"@@ -0,0 +1,97 @@\n+/*\n+ * This file is part of OpenTTD.\n+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.\n+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.\n+ */\n+\n+ /** @file newgrf_profiling.cpp Profiling of NewGRF action 2 handling. */\n+\n+#include \"newgrf_profiling.h\"\n+#include \"date_func.h\"\n+#include \"fileio_func.h\"\n+#include \"string_func.h\"\n+#include \"console_func.h\"\n+\n+#include <chrono>\n+#include <time.h>\n+\n+\n+NewGRFProfiler *_newgrf_profiler;\n+\n+\n+/**\n+ * Create profiler object and begin profiling session.\n+ * @param grffile   The GRF file to collect profiling data on\n+ * @param end_date  Game date to end profiling on\n+ */\n+NewGRFProfiler::NewGRFProfiler(const GRFFile *grffile, Date end_date) : grffile(grffile), profile_end_date(end_date)\n+{\n+\tIConsolePrintF(TC_LIGHT_BROWN, \"Beginning profile of NewGRF %s\", grffile->filename);\n+}\n+\n+/**\n+ * Complete profiling session and write data to file\n+ */\n+NewGRFProfiler::~NewGRFProfiler()\n+{\n+\tstd::string filename = this->GetOutputFilename();\n+\tIConsolePrintF(TC_LIGHT_BROWN, \"Finished profile of NewGRF, writing %u events to %s\", (uint)this->calls.size(), filename.c_str());\n+\n+\tFILE *f = FioFOpenFile(filename.c_str(), \"wt\", Subdirectory::NO_DIRECTORY);\n+\tFileCloser fcloser(f);\n+\n+\tfputs(\"Tick,Sprite,CallbackID,Microseconds,Subs\\n\", f);","path":"src/newgrf_profiling.cpp","position":null,"original_position":44,"commit_id":"faca91ef96e6ccfead0510599e0660ae357eeb9d","original_commit_id":"ffbdba9e6ef88fd5d72678ac64a4db9d0486f32c","user":{"login":"nielsmh","id":1062071,"node_id":"MDQ6VXNlcjEwNjIwNzE=","avatar_url":"https://avatars0.githubusercontent.com/u/1062071?v=4","gravatar_id":"","url":"https://api.github.com/users/nielsmh","html_url":"https://github.com/nielsmh","followers_url":"https://api.github.com/users/nielsmh/followers","following_url":"https://api.github.com/users/nielsmh/following{/other_user}","gists_url":"https://api.github.com/users/nielsmh/gists{/gist_id}","starred_url":"https://api.github.com/users/nielsmh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nielsmh/subscriptions","organizations_url":"https://api.github.com/users/nielsmh/orgs","repos_url":"https://api.github.com/users/nielsmh/repos","events_url":"https://api.github.com/users/nielsmh/events{/privacy}","received_events_url":"https://api.github.com/users/nielsmh/received_events","type":"User","site_admin":false},"body":"Started adding this, just not for all the various resolvers yet.","created_at":"2019-12-22T13:20:55Z","updated_at":"2019-12-22T13:20:55Z","html_url":"https://github.com/OpenTTD/OpenTTD/pull/7868#discussion_r360705208","pull_request_url":"https://api.github.com/repos/OpenTTD/OpenTTD/pulls/7868","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/OpenTTD/OpenTTD/pulls/comments/360705208"},"html":{"href":"https://github.com/OpenTTD/OpenTTD/pull/7868#discussion_r360705208"},"pull_request":{"href":"https://api.github.com/repos/OpenTTD/OpenTTD/pulls/7868"}},"in_reply_to_id":360702649},"pull_request":{"url":"https://api.github.com/repos/OpenTTD/OpenTTD/pulls/7868","id":356050407,"node_id":"MDExOlB1bGxSZXF1ZXN0MzU2MDUwNDA3","html_url":"https://github.com/OpenTTD/OpenTTD/pull/7868","diff_url":"https://github.com/OpenTTD/OpenTTD/pull/7868.diff","patch_url":"https://github.com/OpenTTD/OpenTTD/pull/7868.patch","issue_url":"https://api.github.com/repos/OpenTTD/OpenTTD/issues/7868","number":7868,"state":"open","locked":false,"title":"Feature: NewGRF callback profiling","user":{"login":"nielsmh","id":1062071,"node_id":"MDQ6VXNlcjEwNjIwNzE=","avatar_url":"https://avatars0.githubusercontent.com/u/1062071?v=4","gravatar_id":"","url":"https://api.github.com/users/nielsmh","html_url":"https://github.com/nielsmh","followers_url":"https://api.github.com/users/nielsmh/followers","following_url":"https://api.github.com/users/nielsmh/following{/other_user}","gists_url":"https://api.github.com/users/nielsmh/gists{/gist_id}","starred_url":"https://api.github.com/users/nielsmh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nielsmh/subscriptions","organizations_url":"https://api.github.com/users/nielsmh/orgs","repos_url":"https://api.github.com/users/nielsmh/repos","events_url":"https://api.github.com/users/nielsmh/events{/privacy}","received_events_url":"https://api.github.com/users/nielsmh/received_events","type":"User","site_admin":false},"body":"Adds a console command `newgrf_profile` to collect some profiling data about NewGRF action 2 callbacks and produce a CSV file.\r\n\r\nI'm not entirely sure if this is useful or not, hopefully someone can try it out and decide. It should have almost no impact on performance when not in use. The console command requires developer tools to be enabled.\r\n\r\nCareful, the CSV files can get very large very fast :) One small-ish test game with (a beta of) Iron Horse being profiled made a CSV file of 8 MB with more than 460k events recorded across 7 in-game days.","created_at":"2019-12-22T03:00:57Z","updated_at":"2019-12-22T13:20:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a8393670d6cf2d5ecabccb7308c1fe29f42a220f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/OpenTTD/OpenTTD/pulls/7868/commits","review_comments_url":"https://api.github.com/repos/OpenTTD/OpenTTD/pulls/7868/comments","review_comment_url":"https://api.github.com/repos/OpenTTD/OpenTTD/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OpenTTD/OpenTTD/issues/7868/comments","statuses_url":"https://api.github.com/repos/OpenTTD/OpenTTD/statuses/faca91ef96e6ccfead0510599e0660ae357eeb9d","head":{"label":"nielsmh:newgrf-perf","ref":"newgrf-perf","sha":"faca91ef96e6ccfead0510599e0660ae357eeb9d","user":{"login":"nielsmh","id":1062071,"node_id":"MDQ6VXNlcjEwNjIwNzE=","avatar_url":"https://avatars0.githubusercontent.com/u/1062071?v=4","gravatar_id":"","url":"https://api.github.com/users/nielsmh","html_url":"https://github.com/nielsmh","followers_url":"https://api.github.com/users/nielsmh/followers","following_url":"https://api.github.com/users/nielsmh/following{/other_user}","gists_url":"https://api.github.com/users/nielsmh/gists{/gist_id}","starred_url":"https://api.github.com/users/nielsmh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nielsmh/subscriptions","organizations_url":"https://api.github.com/users/nielsmh/orgs","repos_url":"https://api.github.com/users/nielsmh/repos","events_url":"https://api.github.com/users/nielsmh/events{/privacy}","received_events_url":"https://api.github.com/users/nielsmh/received_events","type":"User","site_admin":false},"repo":{"id":131171793,"node_id":"MDEwOlJlcG9zaXRvcnkxMzExNzE3OTM=","name":"OpenTTD","full_name":"nielsmh/OpenTTD","private":false,"owner":{"login":"nielsmh","id":1062071,"node_id":"MDQ6VXNlcjEwNjIwNzE=","avatar_url":"https://avatars0.githubusercontent.com/u/1062071?v=4","gravatar_id":"","url":"https://api.github.com/users/nielsmh","html_url":"https://github.com/nielsmh","followers_url":"https://api.github.com/users/nielsmh/followers","following_url":"https://api.github.com/users/nielsmh/following{/other_user}","gists_url":"https://api.github.com/users/nielsmh/gists{/gist_id}","starred_url":"https://api.github.com/users/nielsmh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nielsmh/subscriptions","organizations_url":"https://api.github.com/users/nielsmh/orgs","repos_url":"https://api.github.com/users/nielsmh/repos","events_url":"https://api.github.com/users/nielsmh/events{/privacy}","received_events_url":"https://api.github.com/users/nielsmh/received_events","type":"User","site_admin":false},"html_url":"https://github.com/nielsmh/OpenTTD","description":"OpenTTD is an open source simulation game based upon Transport Tycoon Deluxe","fork":true,"url":"https://api.github.com/repos/nielsmh/OpenTTD","forks_url":"https://api.github.com/repos/nielsmh/OpenTTD/forks","keys_url":"https://api.github.com/repos/nielsmh/OpenTTD/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nielsmh/OpenTTD/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nielsmh/OpenTTD/teams","hooks_url":"https://api.github.com/repos/nielsmh/OpenTTD/hooks","issue_events_url":"https://api.github.com/repos/nielsmh/OpenTTD/issues/events{/number}","events_url":"https://api.github.com/repos/nielsmh/OpenTTD/events","assignees_url":"https://api.github.com/repos/nielsmh/OpenTTD/assignees{/user}","branches_url":"https://api.github.com/repos/nielsmh/OpenTTD/branches{/branch}","tags_url":"https://api.github.com/repos/nielsmh/OpenTTD/tags","blobs_url":"https://api.github.com/repos/nielsmh/OpenTTD/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nielsmh/OpenTTD/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nielsmh/OpenTTD/git/refs{/sha}","trees_url":"https://api.github.com/repos/nielsmh/OpenTTD/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nielsmh/OpenTTD/statuses/{sha}","languages_url":"https://api.github.com/repos/nielsmh/OpenTTD/languages","stargazers_url":"https://api.github.com/repos/nielsmh/OpenTTD/stargazers","contributors_url":"https://api.github.com/repos/nielsmh/OpenTTD/contributors","subscribers_url":"https://api.github.com/repos/nielsmh/OpenTTD/subscribers","subscription_url":"https://api.github.com/repos/nielsmh/OpenTTD/subscription","commits_url":"https://api.github.com/repos/nielsmh/OpenTTD/commits{/sha}","git_commits_url":"https://api.github.com/repos/nielsmh/OpenTTD/git/commits{/sha}","comments_url":"https://api.github.com/repos/nielsmh/OpenTTD/comments{/number}","issue_comment_url":"https://api.github.com/repos/nielsmh/OpenTTD/issues/comments{/number}","contents_url":"https://api.github.com/repos/nielsmh/OpenTTD/contents/{+path}","compare_url":"https://api.github.com/repos/nielsmh/OpenTTD/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nielsmh/OpenTTD/merges","archive_url":"https://api.github.com/repos/nielsmh/OpenTTD/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nielsmh/OpenTTD/downloads","issues_url":"https://api.github.com/repos/nielsmh/OpenTTD/issues{/number}","pulls_url":"https://api.github.com/repos/nielsmh/OpenTTD/pulls{/number}","milestones_url":"https://api.github.com/repos/nielsmh/OpenTTD/milestones{/number}","notifications_url":"https://api.github.com/repos/nielsmh/OpenTTD/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nielsmh/OpenTTD/labels{/name}","releases_url":"https://api.github.com/repos/nielsmh/OpenTTD/releases{/id}","deployments_url":"https://api.github.com/repos/nielsmh/OpenTTD/deployments","created_at":"2018-04-26T14:57:27Z","updated_at":"2019-03-11T08:10:58Z","pushed_at":"2019-12-22T13:19:23Z","git_url":"git://github.com/nielsmh/OpenTTD.git","ssh_url":"git@github.com:nielsmh/OpenTTD.git","clone_url":"https://github.com/nielsmh/OpenTTD.git","svn_url":"https://github.com/nielsmh/OpenTTD","homepage":"https://www.openttd.org/","size":137931,"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,"disabled":false,"open_issues_count":0,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"OpenTTD:master","ref":"master","sha":"faaec445d669a222718c2634eb059c44c00a43b7","user":{"login":"OpenTTD","id":5037546,"node_id":"MDEyOk9yZ2FuaXphdGlvbjUwMzc1NDY=","avatar_url":"https://avatars0.githubusercontent.com/u/5037546?v=4","gravatar_id":"","url":"https://api.github.com/users/OpenTTD","html_url":"https://github.com/OpenTTD","followers_url":"https://api.github.com/users/OpenTTD/followers","following_url":"https://api.github.com/users/OpenTTD/following{/other_user}","gists_url":"https://api.github.com/users/OpenTTD/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenTTD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenTTD/subscriptions","organizations_url":"https://api.github.com/users/OpenTTD/orgs","repos_url":"https://api.github.com/users/OpenTTD/repos","events_url":"https://api.github.com/users/OpenTTD/events{/privacy}","received_events_url":"https://api.github.com/users/OpenTTD/received_events","type":"Organization","site_admin":false},"repo":{"id":128430621,"node_id":"MDEwOlJlcG9zaXRvcnkxMjg0MzA2MjE=","name":"OpenTTD","full_name":"OpenTTD/OpenTTD","private":false,"owner":{"login":"OpenTTD","id":5037546,"node_id":"MDEyOk9yZ2FuaXphdGlvbjUwMzc1NDY=","avatar_url":"https://avatars0.githubusercontent.com/u/5037546?v=4","gravatar_id":"","url":"https://api.github.com/users/OpenTTD","html_url":"https://github.com/OpenTTD","followers_url":"https://api.github.com/users/OpenTTD/followers","following_url":"https://api.github.com/users/OpenTTD/following{/other_user}","gists_url":"https://api.github.com/users/OpenTTD/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenTTD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenTTD/subscriptions","organizations_url":"https://api.github.com/users/OpenTTD/orgs","repos_url":"https://api.github.com/users/OpenTTD/repos","events_url":"https://api.github.com/users/OpenTTD/events{/privacy}","received_events_url":"https://api.github.com/users/OpenTTD/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/OpenTTD/OpenTTD","description":"OpenTTD is an open source simulation game based upon Transport Tycoon Deluxe","fork":false,"url":"https://api.github.com/repos/OpenTTD/OpenTTD","forks_url":"https://api.github.com/repos/OpenTTD/OpenTTD/forks","keys_url":"https://api.github.com/repos/OpenTTD/OpenTTD/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenTTD/OpenTTD/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenTTD/OpenTTD/teams","hooks_url":"https://api.github.com/repos/OpenTTD/OpenTTD/hooks","issue_events_url":"https://api.github.com/repos/OpenTTD/OpenTTD/issues/events{/number}","events_url":"https://api.github.com/repos/OpenTTD/OpenTTD/events","assignees_url":"https://api.github.com/repos/OpenTTD/OpenTTD/assignees{/user}","branches_url":"https://api.github.com/repos/OpenTTD/OpenTTD/branches{/branch}","tags_url":"https://api.github.com/repos/OpenTTD/OpenTTD/tags","blobs_url":"https://api.github.com/repos/OpenTTD/OpenTTD/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenTTD/OpenTTD/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenTTD/OpenTTD/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenTTD/OpenTTD/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenTTD/OpenTTD/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenTTD/OpenTTD/languages","stargazers_url":"https://api.github.com/repos/OpenTTD/OpenTTD/stargazers","contributors_url":"https://api.github.com/repos/OpenTTD/OpenTTD/contributors","subscribers_url":"https://api.github.com/repos/OpenTTD/OpenTTD/subscribers","subscription_url":"https://api.github.com/repos/OpenTTD/OpenTTD/subscription","commits_url":"https://api.github.com/repos/OpenTTD/OpenTTD/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenTTD/OpenTTD/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenTTD/OpenTTD/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenTTD/OpenTTD/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpenTTD/OpenTTD/contents/{+path}","compare_url":"https://api.github.com/repos/OpenTTD/OpenTTD/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenTTD/OpenTTD/merges","archive_url":"https://api.github.com/repos/OpenTTD/OpenTTD/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenTTD/OpenTTD/downloads","issues_url":"https://api.github.com/repos/OpenTTD/OpenTTD/issues{/number}","pulls_url":"https://api.github.com/repos/OpenTTD/OpenTTD/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenTTD/OpenTTD/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenTTD/OpenTTD/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenTTD/OpenTTD/labels{/name}","releases_url":"https://api.github.com/repos/OpenTTD/OpenTTD/releases{/id}","deployments_url":"https://api.github.com/repos/OpenTTD/OpenTTD/deployments","created_at":"2018-04-06T18:06:22Z","updated_at":"2019-12-21T19:13:33Z","pushed_at":"2019-12-22T13:19:25Z","git_url":"git://github.com/OpenTTD/OpenTTD.git","ssh_url":"git@github.com:OpenTTD/OpenTTD.git","clone_url":"https://github.com/OpenTTD/OpenTTD.git","svn_url":"https://github.com/OpenTTD/OpenTTD","homepage":"https://www.openttd.org/","size":139405,"stargazers_count":2112,"watchers_count":2112,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":295,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":134,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":295,"open_issues":134,"watchers":2112,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OpenTTD/OpenTTD/pulls/7868"},"html":{"href":"https://github.com/OpenTTD/OpenTTD/pull/7868"},"issue":{"href":"https://api.github.com/repos/OpenTTD/OpenTTD/issues/7868"},"comments":{"href":"https://api.github.com/repos/OpenTTD/OpenTTD/issues/7868/comments"},"review_comments":{"href":"https://api.github.com/repos/OpenTTD/OpenTTD/pulls/7868/comments"},"review_comment":{"href":"https://api.github.com/repos/OpenTTD/OpenTTD/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OpenTTD/OpenTTD/pulls/7868/commits"},"statuses":{"href":"https://api.github.com/repos/OpenTTD/OpenTTD/statuses/faca91ef96e6ccfead0510599e0660ae357eeb9d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"nielsmh"}}