Message 1 of 2
Using a predefined Array vs Objects on the fly

Not applicable
09-12-2012
04:34 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
How in the world working on a pre-defined array is 100 times slower than collecting it on the fly?
The following script will create a biped and re-apply on each bone its position transform from frame 1 to 100. On the first try I used a pre-defined array and on the second i am collecting on the fly.
The result:
Pre-Defined array took: 1520 miliseconds
Collecting on the fly: 3 miliseconds
here is the code:
The following script will create a biped and re-apply on each bone its position transform from frame 1 to 100. On the first try I used a pre-defined array and on the second i am collecting on the fly.
The result:
Pre-Defined array took: 1520 miliseconds
Collecting on the fly: 3 miliseconds
here is the code:
(
local newBip = biped.createnew 100 0
local boneList = for i in objects where (classof i) == biped_object collect i
local timeStart = undefined
timeStart = timestamp()
for i = 1 to 100 do
(
for b in bonelist do at time i biped.settransform b #pos (biped.gettransform b #pos) true
)
format "Operation took: % miliseconds \n" ((timestamp()) - timeStart)
timeStart = timestamp()
for i = 1 to 100 do
(
for b in objects where (classof i) == biped_object do at time i biped.settransform b #pos (biped.gettransform b #pos) true
)
format "Operation took: % miliseconds \n" ((timestamp()) - timeStart)
)