Function speed
|
Alphazero Sugar
Noob Tube
Join date: 24 Mar 2005
Posts: 60
|
03-28-2005 17:13
Howdy neighbors.
Does anyone have a sense if calling many functions within a script is significantly slower than doing the same amount of work in one large function in LSL?
I have a script that's doing maybe five hundred additions and subtractions per iteration along with (perhaps the real culprit) list lookups and alterations, and it is much slower than I had hoped, but maybe that's just how it is.
Thanks, Alphazero
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
03-28-2005 17:30
Working with lists is slow because everything in LSL is pass by value. Math functions usualy aren't the culpret but doing 500 of them will cause a noticable script hit. I would expect 500 to take around 1->8 seconds.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
03-29-2005 00:01
From: Alphazero Sugar Does anyone have a sense if calling many functions within a script is significantly slower than doing the same amount of work in one large function in LSL? It depends on exactly how many, though I wouldn't sacrifice code clarity for speed. ==Chris
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
03-29-2005 03:11
It depends on how you have the script broken up. One way to get stuff to go faster, as I'm sure Xylor would tell you, is when you have several calculations you want to do simultaneously you can just branch calculations into different script buffers (that is, different scripts). This form of multithreading can really come in handy, especially if you have a lot of stuff to do. Of course, the catch is it's a little harder to code. Try link messages to do this.
_____________________
---
|
Tiger Crossing
The Prim Maker
Join date: 18 Aug 2003
Posts: 1,560
|
03-29-2005 05:58
Parallel processing is fun. I had a test that involved 500 nodes each randomly connected to up to six other nodes in one-way relationships. A parallel script would find a path through the system to any of the nodes in just a second or so. It took longer to update the display of the result than it did to do the pathfinding. Of course, the sim FPS took a noticable hit for that one second... 
_____________________
~ Tiger Crossing ~ (Nonsanity)
|
Alphazero Sugar
Noob Tube
Join date: 24 Mar 2005
Posts: 60
|
03-29-2005 12:14
From: Tiger Crossing Parallel processing is fun. I had a test that involved 500 nodes each randomly connected to up to six other nodes in one-way relationships. That is way cool. I have nodes connected to eight neighbors, and I was using very, very simple math to find and check the neighboring nodes. So, upper left would take the current position, subtract one from the column, add one to the row, and then check for boundary conditions. For only 25 nodes it seems unreasonably slow. I think reorganizing it like yours would do the trick... although I wouldn't want to totally destroy the sim speed. Hmmm. -- Alphazero
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
03-29-2005 14:31
From: Alphazero Sugar I think reorganizing it like yours would do the trick... although I wouldn't want to totally destroy the sim speed. Hmmm. In general, you REALLY have to hammer a sim with calculations to see a noticable hit. I wouldn't worry about it with eight... eight-hundred, on the other hand... 
_____________________
---
|
Alphazero Sugar
Noob Tube
Join date: 24 Mar 2005
Posts: 60
|
03-29-2005 17:12
From: Jeffrey Gomez In general, you REALLY have to hammer a sim with calculations to see a noticable hit. I wouldn't worry about it with eight... eight-hundred, on the other hand...  Hmmmm. How about 800 link messages with one addition each per iteration in 100 parallel scripts.... I shall soon find out! Kaboom! Thanks for the pointers, all. Very slick idea, this parallelism. I'm thinking about master clock script telling each child script when to update, then to redraw, etc. Like a CPU. Neat. -- Alphazero
|