Script efficiency: GetEquipped vs. IsWeaponInList

Post » Sat Mar 20, 2010 3:11 am

I wonder which of these functions makes the game work less hard: GetEquipped vs. IsWeaponInList.
User avatar
Gavin Roberts
 
Posts: 3335
Joined: Fri Jun 08, 2007 8:14 pm

Post » Fri Mar 19, 2010 10:21 pm

Unless your formlist has thousands of entries, there really wouldnt be a noticable difference.
User avatar
Astargoth Rockin' Design
 
Posts: 3450
Joined: Mon Apr 02, 2007 2:51 pm

Post » Fri Mar 19, 2010 7:20 pm

As such, it would depend on the implementation details. It seems form lists are linked lists, so the price of IsWeaponInList would be linear with the number of elements in the list. I'm unsure how GetEquipped is implemented, but if it searches a list of equipped objects, the complexity is the same, though the upper bound on the number of equipped objects is likely much smaller than for a form list. You could ask in the FOSE thread - they must know.
User avatar
Julia Schwalbe
 
Posts: 3557
Joined: Wed Apr 11, 2007 3:02 pm

Post » Fri Mar 19, 2010 9:44 pm

The tinyest differences in the handling can be measured. I need to ask Cipscis for whatever script he wrote that measures this. Or, maybe he writes the stuff on the fly. heeh.
User avatar
Myles
 
Posts: 3341
Joined: Sun Oct 21, 2007 12:52 pm

Post » Sat Mar 20, 2010 12:53 am

Each time I post a result of an efficiency test in the http://www.gamesas.com/index.php?showtopic=987561 thread, at least recently, I've posted the variation of the script that I've used. If you'd like, I could upload the plugin template that I've used to Fallout 3 Nexus.

Given that http://geck.gamesas.com/index.php/GetEquipped has to compare each item in a list with each biped slot on an actor, whereas http://geck.gamesas.com/index.php/IsWeaponInList presumably extracts a pointer to the weapon and compares only that with each item in the list, I'd expect http://geck.gamesas.com/index.php/IsWeaponInList to be more efficient. There's also the fact that, if http://geck.gamesas.com/index.php/GetEquipped is more efficient than http://geck.gamesas.com/index.php/IsWeaponInList, then there'd be very little use for http://geck.gamesas.com/index.php/IsWeaponInList, depending on how your form lists have been set up.

Cipscis
User avatar
Katey Meyer
 
Posts: 3464
Joined: Sat Dec 30, 2006 10:14 pm

Post » Sat Mar 20, 2010 8:26 am

Just uploaded a template for comparing code:
CodeComparison 1.0 by Cipscis @ Fallout 3 Nexus: http://www.fallout3nexus.com/downloads/file.php?id=11239

Cipscis
User avatar
Code Affinity
 
Posts: 3325
Joined: Wed Jun 13, 2007 11:11 am

Post » Fri Mar 19, 2010 11:03 pm

If anyone's wondering what happened to this, Tarrant has posted his results http://www.gamesas.com/index.php?act=findpost&pid=15655681. For the purposes of checking if an actor's weapon is in a form list, http://geck.gamesas.com/index.php/IsWeaponInList is considerably more efficient than http://geck.gamesas.com/index.php/GetEquipped.

Cipscis
User avatar
Euan
 
Posts: 3376
Joined: Mon May 14, 2007 3:34 pm

Post » Fri Mar 19, 2010 4:59 pm

Hey Cipcsis,

I am going through my code and maybe you will know something that I don't, on this one. I'm checking the GECK WIKI and I don't see anything so far.

I have a block of code whose sole purpose is to isolate which exact weapon a follower is holding in his hands. Procedurally, it's already been narrowed down via a formlist check. Each code block is specific to the type of weapon, basically.

But look what function I have been using...

if getequipped WeapMissileLauncher	PhalanxMalcolmStorageREF.additemhealthpercent WeapMissileLauncher 1 WeapHealthFloat	removeitem WeapMissileLauncher 1elseif getequipped WeapMinigun	PhalanxMalcolmStorageREF.additemhealthpercent WeapMinigun 1 WeapHealthFloat	removeitem WeapMinigun 1elseif ...


... Is there a function that you know of that more resembles isweaponinlist that can be applied against a single equipped weapon? I mean... if I test, and it proves to be 50% more efficient to make a formlist containing just one entry for each weapon, I'll probably do it. But, christ? That svcks? Thats an assload of formlists!
User avatar
Rik Douglas
 
Posts: 3385
Joined: Sat Jul 07, 2007 1:40 pm


Return to Fallout 3