{"action":"created","comment":{"url":"https://api.github.com/repos/acemod/ACE3/pulls/comments/35199743","id":35199743,"diff_hunk":"@@ -13,38 +13,44 @@\n  *\n  * Public: No\n  */\n+// #define ENABLE_PERFORMANCE_COUNTERS\n #include \"script_component.hpp\"\n \n [{\n-    private [\"_args\", \"_bullet\", \"_airFriction\", \"_time\", \"_deltaT\", \"_bulletVelocity\", \"_bulletSpeed\", \"_trueVelocity\", \"_trueSpeed\", \"_dragRef\", \"_drag\", \"_accelRef\", \"_accel\"];\n-\n-    _args = _this select 0;\n-    _bullet = _args select 0;\n-    _airFriction = _args select 1;\n-    _time = _args select 2;\n-    \n-    _bulletVelocity = velocity _bullet;\n-    _bulletSpeed = vectorMagnitude _bulletVelocity;\n-    \n-    if (!alive _bullet || ((_bullet isKindOf \"BulletBase\") && _bulletSpeed < 100)) exitwith {\n-        [_this select 1] call cba_fnc_removePerFrameHandler;\n-    };\n-    \n-    _deltaT = ACE_time - _time;\n-    _args set[2, ACE_time];\n-    \n-    if (vectorMagnitude ACE_wind > 0) then {\n-        _trueVelocity = _bulletVelocity vectorDiff ACE_wind;\n-        _trueSpeed = vectorMagnitude _trueVelocity;\n-\n-        _dragRef = _deltaT * _airFriction * _bulletSpeed * _bulletSpeed;\n-        _accelRef = (vectorNormalized _bulletVelocity) vectorMultiply (_dragRef);\n-        _bulletVelocity = _bulletVelocity vectorDiff _accelRef;\n-\n-        _drag = _deltaT * _airFriction * _trueSpeed;\n-        _accel = _trueVelocity vectorMultiply (_drag);\n-        _bulletVelocity = _bulletVelocity vectorAdd _accel;\n-    };\n-    _bullet setVelocity _bulletVelocity;\n-    \n-}, GVAR(simulationInterval), [_this select 0, _this select 1, ACE_time]] call CBA_fnc_addPerFrameHandler;\n\\ No newline at end of file\n+    // BEGIN_COUNTER(pfeh);\n+    private[\"_accel\", \"_accelRef\", \"_bulletSpeed\", \"_bulletVelocity\", \"_deleted\", \"_deltaT\", \"_drag\", \"_dragRef\", \"_isWind\", \"_lastTime\", \"_trueSpeed\", \"_trueVelocity\"];\n+\n+    _lastTime = (_this select 0) select 0;\n+    _deltaT = ACE_time - _lastTime;\n+    (_this select 0) set [0, ACE_time];\n+    _deleted = 0;\n+    _isWind = (vectorMagnitude ACE_wind > 0);\n+\n+    {\n+        _x params [\"_bullet\", \"_airFriction\"];\n+\n+        _bulletVelocity = velocity _bullet;\n+        _bulletSpeed = vectorMagnitude _bulletVelocity;\n+\n+        if ((!alive _bullet) || {(_bullet isKindOf \"BulletBase\") && {_bulletSpeed < 100}}) then {","path":"addons/winddeflection/functions/fnc_updateTrajectoryPFH.sqf","position":56,"original_position":56,"commit_id":"4d7a2888eb12436e9270aa5ee1c0796f5f8b70ea","original_commit_id":"4d7a2888eb12436e9270aa5ee1c0796f5f8b70ea","user":{"login":"Glowbal","id":5007509,"avatar_url":"https://avatars.githubusercontent.com/u/5007509?v=3","gravatar_id":"","url":"https://api.github.com/users/Glowbal","html_url":"https://github.com/Glowbal","followers_url":"https://api.github.com/users/Glowbal/followers","following_url":"https://api.github.com/users/Glowbal/following{/other_user}","gists_url":"https://api.github.com/users/Glowbal/gists{/gist_id}","starred_url":"https://api.github.com/users/Glowbal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Glowbal/subscriptions","organizations_url":"https://api.github.com/users/Glowbal/orgs","repos_url":"https://api.github.com/users/Glowbal/repos","events_url":"https://api.github.com/users/Glowbal/events{/privacy}","received_events_url":"https://api.github.com/users/Glowbal/received_events","type":"User","site_admin":false},"body":"`(_bullet isKindOf \"BulletBase\")`\r\nWe are checking this when we add the bullets to the array. Is it necessary to check it again here?","created_at":"2015-07-22T10:33:04Z","updated_at":"2015-07-22T10:33:04Z","html_url":"https://github.com/acemod/ACE3/pull/1886#discussion_r35199743","pull_request_url":"https://api.github.com/repos/acemod/ACE3/pulls/1886","_links":{"self":{"href":"https://api.github.com/repos/acemod/ACE3/pulls/comments/35199743"},"html":{"href":"https://github.com/acemod/ACE3/pull/1886#discussion_r35199743"},"pull_request":{"href":"https://api.github.com/repos/acemod/ACE3/pulls/1886"}}},"pull_request":{"url":"https://api.github.com/repos/acemod/ACE3/pulls/1886","id":40542765,"html_url":"https://github.com/acemod/ACE3/pull/1886","diff_url":"https://github.com/acemod/ACE3/pull/1886.diff","patch_url":"https://github.com/acemod/ACE3/pull/1886.patch","issue_url":"https://api.github.com/repos/acemod/ACE3/issues/1886","number":1886,"state":"open","locked":false,"title":"Wind deflection single pfeh","user":{"login":"PabstMirror","id":9376747,"avatar_url":"https://avatars.githubusercontent.com/u/9376747?v=3","gravatar_id":"","url":"https://api.github.com/users/PabstMirror","html_url":"https://github.com/PabstMirror","followers_url":"https://api.github.com/users/PabstMirror/followers","following_url":"https://api.github.com/users/PabstMirror/following{/other_user}","gists_url":"https://api.github.com/users/PabstMirror/gists{/gist_id}","starred_url":"https://api.github.com/users/PabstMirror/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PabstMirror/subscriptions","organizations_url":"https://api.github.com/users/PabstMirror/orgs","repos_url":"https://api.github.com/users/PabstMirror/repos","events_url":"https://api.github.com/users/PabstMirror/events{/privacy}","received_events_url":"https://api.github.com/users/PabstMirror/received_events","type":"User","site_admin":false},"body":"Switches fnc_updateTrajectoryPFH to be a master PFEH, bullets get added to an internal array instead of creating/deleting a new cba PFEH each time.\r\n\r\nI believe this solves a big performance problem where the `count cba_common_perFrameHandlerArray` can grow too large.\r\n\r\nIn actual session I saw it hit >2000.  Most entries are nil, but it sill takes time to process them, which happens each frame.  (2000 is about 5.5ms each frame),\r\n\r\nIn a stress test mission with about 50 ai + disabling the isPlayer check in handleFired so all AI bullets are tracked.  Unscientific results because AI are unpredictable, but I get a huge performance difference:\r\n\r\n![image](https://cloud.githubusercontent.com/assets/9376747/8821397/eb5048d8-3022-11e5-84c1-4426b061f353.png)\r\nVS\r\n![image](https://cloud.githubusercontent.com/assets/9376747/8821408/ff87d276-3022-11e5-926f-b0caa4083642.png)\r\n\r\nWith PFEH debug enabled:\r\n```\r\nace_windDeflection_pfeh_counter: Average: 0.812859s / 2257 = 0.36015ms\r\n```","created_at":"2015-07-22T08:50:37Z","updated_at":"2015-07-22T10:33:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4eda7272362101eade70a0b4a3889f27b030c412","assignee":null,"milestone":{"url":"https://api.github.com/repos/acemod/ACE3/milestones/4","html_url":"https://github.com/acemod/ACE3/milestones/Ongoing","labels_url":"https://api.github.com/repos/acemod/ACE3/milestones/4/labels","id":1074589,"number":4,"title":"Ongoing","description":"Tasks that do not have a specific due date and are ongoing as circumstances change. Different from backlog, which are tasks that have a specific end point, but no due date.","creator":{"login":"NouberNou","id":9345914,"avatar_url":"https://avatars.githubusercontent.com/u/9345914?v=3","gravatar_id":"","url":"https://api.github.com/users/NouberNou","html_url":"https://github.com/NouberNou","followers_url":"https://api.github.com/users/NouberNou/followers","following_url":"https://api.github.com/users/NouberNou/following{/other_user}","gists_url":"https://api.github.com/users/NouberNou/gists{/gist_id}","starred_url":"https://api.github.com/users/NouberNou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NouberNou/subscriptions","organizations_url":"https://api.github.com/users/NouberNou/orgs","repos_url":"https://api.github.com/users/NouberNou/repos","events_url":"https://api.github.com/users/NouberNou/events{/privacy}","received_events_url":"https://api.github.com/users/NouberNou/received_events","type":"User","site_admin":false},"open_issues":23,"closed_issues":13,"state":"open","created_at":"2015-04-20T06:31:17Z","updated_at":"2015-07-22T08:50:37Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/acemod/ACE3/pulls/1886/commits","review_comments_url":"https://api.github.com/repos/acemod/ACE3/pulls/1886/comments","review_comment_url":"https://api.github.com/repos/acemod/ACE3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/acemod/ACE3/issues/1886/comments","statuses_url":"https://api.github.com/repos/acemod/ACE3/statuses/4d7a2888eb12436e9270aa5ee1c0796f5f8b70ea","head":{"label":"acemod:windDeflectionSinglePFEH","ref":"windDeflectionSinglePFEH","sha":"4d7a2888eb12436e9270aa5ee1c0796f5f8b70ea","user":{"login":"acemod","id":11369030,"avatar_url":"https://avatars.githubusercontent.com/u/11369030?v=3","gravatar_id":"","url":"https://api.github.com/users/acemod","html_url":"https://github.com/acemod","followers_url":"https://api.github.com/users/acemod/followers","following_url":"https://api.github.com/users/acemod/following{/other_user}","gists_url":"https://api.github.com/users/acemod/gists{/gist_id}","starred_url":"https://api.github.com/users/acemod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acemod/subscriptions","organizations_url":"https://api.github.com/users/acemod/orgs","repos_url":"https://api.github.com/users/acemod/repos","events_url":"https://api.github.com/users/acemod/events{/privacy}","received_events_url":"https://api.github.com/users/acemod/received_events","type":"Organization","site_admin":false},"repo":{"id":29069174,"name":"ACE3","full_name":"acemod/ACE3","owner":{"login":"acemod","id":11369030,"avatar_url":"https://avatars.githubusercontent.com/u/11369030?v=3","gravatar_id":"","url":"https://api.github.com/users/acemod","html_url":"https://github.com/acemod","followers_url":"https://api.github.com/users/acemod/followers","following_url":"https://api.github.com/users/acemod/following{/other_user}","gists_url":"https://api.github.com/users/acemod/gists{/gist_id}","starred_url":"https://api.github.com/users/acemod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acemod/subscriptions","organizations_url":"https://api.github.com/users/acemod/orgs","repos_url":"https://api.github.com/users/acemod/repos","events_url":"https://api.github.com/users/acemod/events{/privacy}","received_events_url":"https://api.github.com/users/acemod/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/acemod/ACE3","description":"Open-source realism mod for Arma 3","fork":false,"url":"https://api.github.com/repos/acemod/ACE3","forks_url":"https://api.github.com/repos/acemod/ACE3/forks","keys_url":"https://api.github.com/repos/acemod/ACE3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/acemod/ACE3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/acemod/ACE3/teams","hooks_url":"https://api.github.com/repos/acemod/ACE3/hooks","issue_events_url":"https://api.github.com/repos/acemod/ACE3/issues/events{/number}","events_url":"https://api.github.com/repos/acemod/ACE3/events","assignees_url":"https://api.github.com/repos/acemod/ACE3/assignees{/user}","branches_url":"https://api.github.com/repos/acemod/ACE3/branches{/branch}","tags_url":"https://api.github.com/repos/acemod/ACE3/tags","blobs_url":"https://api.github.com/repos/acemod/ACE3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/acemod/ACE3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/acemod/ACE3/git/refs{/sha}","trees_url":"https://api.github.com/repos/acemod/ACE3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/acemod/ACE3/statuses/{sha}","languages_url":"https://api.github.com/repos/acemod/ACE3/languages","stargazers_url":"https://api.github.com/repos/acemod/ACE3/stargazers","contributors_url":"https://api.github.com/repos/acemod/ACE3/contributors","subscribers_url":"https://api.github.com/repos/acemod/ACE3/subscribers","subscription_url":"https://api.github.com/repos/acemod/ACE3/subscription","commits_url":"https://api.github.com/repos/acemod/ACE3/commits{/sha}","git_commits_url":"https://api.github.com/repos/acemod/ACE3/git/commits{/sha}","comments_url":"https://api.github.com/repos/acemod/ACE3/comments{/number}","issue_comment_url":"https://api.github.com/repos/acemod/ACE3/issues/comments{/number}","contents_url":"https://api.github.com/repos/acemod/ACE3/contents/{+path}","compare_url":"https://api.github.com/repos/acemod/ACE3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/acemod/ACE3/merges","archive_url":"https://api.github.com/repos/acemod/ACE3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/acemod/ACE3/downloads","issues_url":"https://api.github.com/repos/acemod/ACE3/issues{/number}","pulls_url":"https://api.github.com/repos/acemod/ACE3/pulls{/number}","milestones_url":"https://api.github.com/repos/acemod/ACE3/milestones{/number}","notifications_url":"https://api.github.com/repos/acemod/ACE3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/acemod/ACE3/labels{/name}","releases_url":"https://api.github.com/repos/acemod/ACE3/releases{/id}","created_at":"2015-01-10T19:59:12Z","updated_at":"2015-07-21T23:20:51Z","pushed_at":"2015-07-22T08:50:37Z","git_url":"git://github.com/acemod/ACE3.git","ssh_url":"git@github.com:acemod/ACE3.git","clone_url":"https://github.com/acemod/ACE3.git","svn_url":"https://github.com/acemod/ACE3","homepage":"http://ace3mod.com/","size":339712,"stargazers_count":277,"watchers_count":277,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":206,"mirror_url":null,"open_issues_count":249,"forks":206,"open_issues":249,"watchers":277,"default_branch":"master"}},"base":{"label":"acemod:master","ref":"master","sha":"3e420b6bf683d51e8918ff7ea404a64238fcda50","user":{"login":"acemod","id":11369030,"avatar_url":"https://avatars.githubusercontent.com/u/11369030?v=3","gravatar_id":"","url":"https://api.github.com/users/acemod","html_url":"https://github.com/acemod","followers_url":"https://api.github.com/users/acemod/followers","following_url":"https://api.github.com/users/acemod/following{/other_user}","gists_url":"https://api.github.com/users/acemod/gists{/gist_id}","starred_url":"https://api.github.com/users/acemod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acemod/subscriptions","organizations_url":"https://api.github.com/users/acemod/orgs","repos_url":"https://api.github.com/users/acemod/repos","events_url":"https://api.github.com/users/acemod/events{/privacy}","received_events_url":"https://api.github.com/users/acemod/received_events","type":"Organization","site_admin":false},"repo":{"id":29069174,"name":"ACE3","full_name":"acemod/ACE3","owner":{"login":"acemod","id":11369030,"avatar_url":"https://avatars.githubusercontent.com/u/11369030?v=3","gravatar_id":"","url":"https://api.github.com/users/acemod","html_url":"https://github.com/acemod","followers_url":"https://api.github.com/users/acemod/followers","following_url":"https://api.github.com/users/acemod/following{/other_user}","gists_url":"https://api.github.com/users/acemod/gists{/gist_id}","starred_url":"https://api.github.com/users/acemod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acemod/subscriptions","organizations_url":"https://api.github.com/users/acemod/orgs","repos_url":"https://api.github.com/users/acemod/repos","events_url":"https://api.github.com/users/acemod/events{/privacy}","received_events_url":"https://api.github.com/users/acemod/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/acemod/ACE3","description":"Open-source realism mod for Arma 3","fork":false,"url":"https://api.github.com/repos/acemod/ACE3","forks_url":"https://api.github.com/repos/acemod/ACE3/forks","keys_url":"https://api.github.com/repos/acemod/ACE3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/acemod/ACE3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/acemod/ACE3/teams","hooks_url":"https://api.github.com/repos/acemod/ACE3/hooks","issue_events_url":"https://api.github.com/repos/acemod/ACE3/issues/events{/number}","events_url":"https://api.github.com/repos/acemod/ACE3/events","assignees_url":"https://api.github.com/repos/acemod/ACE3/assignees{/user}","branches_url":"https://api.github.com/repos/acemod/ACE3/branches{/branch}","tags_url":"https://api.github.com/repos/acemod/ACE3/tags","blobs_url":"https://api.github.com/repos/acemod/ACE3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/acemod/ACE3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/acemod/ACE3/git/refs{/sha}","trees_url":"https://api.github.com/repos/acemod/ACE3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/acemod/ACE3/statuses/{sha}","languages_url":"https://api.github.com/repos/acemod/ACE3/languages","stargazers_url":"https://api.github.com/repos/acemod/ACE3/stargazers","contributors_url":"https://api.github.com/repos/acemod/ACE3/contributors","subscribers_url":"https://api.github.com/repos/acemod/ACE3/subscribers","subscription_url":"https://api.github.com/repos/acemod/ACE3/subscription","commits_url":"https://api.github.com/repos/acemod/ACE3/commits{/sha}","git_commits_url":"https://api.github.com/repos/acemod/ACE3/git/commits{/sha}","comments_url":"https://api.github.com/repos/acemod/ACE3/comments{/number}","issue_comment_url":"https://api.github.com/repos/acemod/ACE3/issues/comments{/number}","contents_url":"https://api.github.com/repos/acemod/ACE3/contents/{+path}","compare_url":"https://api.github.com/repos/acemod/ACE3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/acemod/ACE3/merges","archive_url":"https://api.github.com/repos/acemod/ACE3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/acemod/ACE3/downloads","issues_url":"https://api.github.com/repos/acemod/ACE3/issues{/number}","pulls_url":"https://api.github.com/repos/acemod/ACE3/pulls{/number}","milestones_url":"https://api.github.com/repos/acemod/ACE3/milestones{/number}","notifications_url":"https://api.github.com/repos/acemod/ACE3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/acemod/ACE3/labels{/name}","releases_url":"https://api.github.com/repos/acemod/ACE3/releases{/id}","created_at":"2015-01-10T19:59:12Z","updated_at":"2015-07-21T23:20:51Z","pushed_at":"2015-07-22T08:50:37Z","git_url":"git://github.com/acemod/ACE3.git","ssh_url":"git@github.com:acemod/ACE3.git","clone_url":"https://github.com/acemod/ACE3.git","svn_url":"https://github.com/acemod/ACE3","homepage":"http://ace3mod.com/","size":339712,"stargazers_count":277,"watchers_count":277,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":206,"mirror_url":null,"open_issues_count":249,"forks":206,"open_issues":249,"watchers":277,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/acemod/ACE3/pulls/1886"},"html":{"href":"https://github.com/acemod/ACE3/pull/1886"},"issue":{"href":"https://api.github.com/repos/acemod/ACE3/issues/1886"},"comments":{"href":"https://api.github.com/repos/acemod/ACE3/issues/1886/comments"},"review_comments":{"href":"https://api.github.com/repos/acemod/ACE3/pulls/1886/comments"},"review_comment":{"href":"https://api.github.com/repos/acemod/ACE3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/acemod/ACE3/pulls/1886/commits"},"statuses":{"href":"https://api.github.com/repos/acemod/ACE3/statuses/4d7a2888eb12436e9270aa5ee1c0796f5f8b70ea"}}}}