Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explosives - Optimize interactEH function #6406

Merged
merged 2 commits into from
Jul 13, 2018

Conversation

mharis001
Copy link
Member

@mharis001 mharis001 commented Jun 24, 2018

When merged this pull request will:

  • Optimize explosives interactEH function (various minor improvements but mainly createVehicleLocal [0, 0, 0])

Performance results for ace_explosives_interactEH_counter:

Test Old New
count allMines = 30 (somewhat close) 0.09198s / 43 = 2.13907ms 0.0169678s / 35 = 0.484794ms
count allMines = 42 (nearby) 0.0439453s / 24 = 1.83105ms 0.0249634s / 28 = 0.891549ms
count allMines = 47 (far away) 0.00402832s / 31 = 0.129946ms 0.00604248s / 59 = 0.102415ms
count allMines = 159 (nearby) 0.685913s / 106 = 6.47088ms 0.248962s / 123 = 2.02408ms

@jonpas jonpas added the kind/optimization Release Notes: **IMPROVED:** label Jun 24, 2018
@jonpas jonpas added this to the 3.13.0 milestone Jun 24, 2018
@mharis001 mharis001 changed the title Explosives- Optimize interactEH function Explosives - Optimize interactEH function Jun 24, 2018
Copy link
Contributor

@dedmen dedmen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a perf improvement you might aswell go crazy overkill :D

} else {
// Prevent Rare Error when ending mission with interact key down:
if (isNull ace_player) exitWith {};
if (isNull ACE_player) exitWith {};
private _player = ACE_player;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accessing global variable is slower than local. So swap the order of the isNull and _player and reuse _player maybe.

//If player moved >5 meters from last pos, then rescan
if (((getPosASL ace_player) distance _setPosition) > 5) then {
// Rescan if player has moved more than 5 meters from last position
if (_playerPos distance _setPosition > 5) then {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

distanceSqr? But I don't think that makes enough difference

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might as well 😃

Copy link
Contributor

@thojkooi thojkooi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks sensible. The change from Public to Private in the function header seems like it should not be part of this PR, but I think it makes sense for this function.

I'd leave this to @jonpas or @commy2 to merge.

@mharis001
Copy link
Member Author

I changed it from public Yes to No, because I don't see any reason why this function would be a public function.

@PabstMirror PabstMirror modified the milestones: 3.13.0, 3.12.3 Jul 13, 2018
@PabstMirror PabstMirror merged commit a84daca into acemod:master Jul 13, 2018
@mharis001 mharis001 deleted the explosives-interactEH branch August 29, 2018 23:27
BaerMitUmlaut pushed a commit that referenced this pull request Aug 5, 2019
* Optimize explosives interactEH

* Use local player variable and distanceSqr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/optimization Release Notes: **IMPROVED:**
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants