Author Topic: Performance and "liking" question  (Read 1900 times)

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Performance and "liking" question
« on: January 26, 2009, 06:17:47 AM »
At the moment (well, looooong moment) I'm working at some "not really usefull - just for fun" Functions for QBA.
(just finished a Tholian Web approach, yeah).
However, I can make all these Functions into several Scripts ( each at a length comparable to USS Frontiers Chain Reaction Pulsar)
Or I can Write most of them into One HUGE script which re-uses a lot of Subfuncs like Menu creation, Vector Calculation and such.
At the Moment I tend to Make a single Script, however I like to know what you think would be better.
Just in case I upload it sometime (that can take a while)

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Performance and "liking" question
« Reply #1 on: January 26, 2009, 01:37:11 PM »
I suppose it largely depends on how you introduce it into the system.

For example FoundationTech has it's bulk in scripts/FoundationTech.py the script that loads FoundationTech in scripts/Custom/Autoload/ and it's standard techs in scripts/ftb/Techs and second party techs (techs not created for FTB, but while development of FoundationTech), and any other tech, in scripts/Custom/Techs/

Creating a little library module with your common functions is fine, and all your specific scripts would then use that library. Modularity is also improved here, so if someone says they only want scripts A, B and C from your mod, but not D, E and F, then with the proper modularity they could just copy the common part, and scripts A, B and C.

You mentioned QBA, in the QBautostart directory there is a lib directory, put your common scripts in there (or in a subdirectory, don't forget the __init__.py file!).
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: Performance and "liking" question
« Reply #2 on: January 26, 2009, 01:45:44 PM »
Yeah, a little lib would do also, not a bad Idea. Performancewise would that also do, I think (OK, cought - I have no Idea on that  :) )
The Tholian Web is, the way I did it , very "recource unfriendly", so . That kib is really a good Idea. Thanks

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Performance and "liking" question
« Reply #3 on: January 26, 2009, 01:59:30 PM »
Well, a module more or less won't matter, modules are what Python is built on, so it will be heavily optimized.

For most of the time, everything is "fast enough", unless you are really experiencing lag of course.
I should say "Don't worry about performance untill you have profiled it".

For example, worrying about module performance is useless, you could only shave microseconds of that.

What we can improve is the resource hungry-ness of the code you have written.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: Performance and "liking" question
« Reply #4 on: January 26, 2009, 03:47:01 PM »
Quote
What we can improve is the resource hungry-ness of the code you have written.

Before I go for that I first have to finish the Script(s) so they do what I want :lol:

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Performance and "liking" question
« Reply #5 on: January 26, 2009, 04:53:38 PM »
But you already know that the Tholian Web is resource intensive?
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: Performance and "liking" question
« Reply #6 on: January 27, 2009, 07:27:04 AM »
But you already know that the Tholian Web is resource intensive?

Thats because it spawns some hundret Ships nearly at the same time. (I try to get at least a bit of the Web - look by spawning lines between the Ships involved.) So BC "freezes" for some time until the all the Ships are spawned and then continues normal (if it did handle creating all the ships, thats it), but that not really Code relatet.
I was just asking because there is quite a long list of things I want to get into the game, so there are really many scripts (some of them maybe really extensive for my taste) to come together using all the same functions,

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Performance and "liking" question
« Reply #7 on: January 27, 2009, 01:51:49 PM »
I think it would be a good idea to experiment with the CloneModel function of App.g_kModelManager

I think it accepts a TGAnimNode which you can retrieve through GetAnimNode
I also suspect you don't need any ship based functions, so just can just load the 1 ship and then use the CloneModel to duplicate it.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: Performance and "liking" question
« Reply #8 on: February 01, 2009, 09:09:51 AM »
Seems like i'm too stupid to use it atm, all I get is a CTD.
my code looks like that atm.
Code: [Select]
FirstStick = Stickn.GetAnimNode()Were FirstStick is a already spawned Ship.

Code: [Select]
while ( MissionLib.GetShip(StickName) != None):
# If its exists try another name (1+)
itemp = i + k
#Maybe I should prevent the Web from becomming too large so...
if itemp > Settings.GetMaxSticks():
print "The Web is getting too large"
return
else:
StickName = "Stick " + str(itemp)
k = k + 1
# Create the Stick
Stickn = App.g_kModelManager.CloneModel(FirstStick)

#Set Collisions off with the two ends of the Line
Stickn.EnableCollisionsWith(GoToCoor, 0)
Stickn.EnableCollisionsWith(GoFromCoor, 0)

#this part is from Sneakers Core Eject
kPoint1 = App.TGPoint3()
kPoint1.Set(PointToPlace)
Stickn.SetTranslate(kPoint1)
Stickn.AlignToVectors(VectorNorm, vUp)
Stickn.UpdateNodeOnly()

That Code is based on Defiants AbandonShip.

So, as long as i don't figure out what's wrong myself, do you have an example of some kind of how to use that function? I already searched the SP scripts but didn't find it.
Thanks for your Help

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Performance and "liking" question
« Reply #9 on: February 01, 2009, 12:54:47 PM »
I fear it might be the case that these functions aren't properly implemented by TG. That is, if you really are getting a CTD that is at the invocation of CloneModel.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.