Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llListReplaceList Performance Test

Olmy Seraph
Valued Member
Join date: 1 Nov 2004
Posts: 502
04-06-2005 16:54
I was curious about the new llListReplaceList call in 1.6, so I wrote a little performance test to see how it compared to doing things manually. I've never done any performance testing in SL or LSL, so I may have fracked things up majorly, but as the numbers make sense I don't think so.

Results:

As you might expect, it's about a 2 to 1 speedup. This makes sense, as you are replacing 2 API calls with 1.

The code:

CODE

// lrlPerfTest.lsl

default
{

touch_start(integer num_detected)
{
llSay(0, "Start timing run...");

integer i;
integer j;
float loopTime;
float lrlTime;
float listOpTime;
list dest = [];
list src1 = [1];
list src5 = [1, 2, 3, 4, 5];
list src10 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
list result;

for ( i = 0; i < 100; i++ )
{
dest += i;
}

// get loop baseline

llSay(0, "Base...");
llResetTime();
for ( i = 10; i < 90; i++ )
{
result = dest;
result = dest;
result = dest;
result = dest;
result = dest;
result = dest;
result = dest;
result = dest;
result = dest;
result = dest;
result = dest;
result = dest;
result = dest;
result = dest;
result = dest;
}
loopTime = llGetTime();
llSay(0, "Base Time: " + (string)loopTime);

// get llListReplaceList time

llSay(0, "LRL...");
llResetTime();
for ( i = 10; i < 90; i++ )
{
result = llListReplaceList(dest, src1, i, i);
result = llListReplaceList(dest, src1, i - 5, i + 4);
result = llListReplaceList(dest, src1, i - 10, i + 9);
result = llListReplaceList(dest, src1, 0, i);
result = llListReplaceList(dest, src1, i, -1);
result = llListReplaceList(dest, src5, i, i);
result = llListReplaceList(dest, src5, i - 5, i + 4);
result = llListReplaceList(dest, src5, i - 10, i + 9);
result = llListReplaceList(dest, src5, 0, i);
result = llListReplaceList(dest, src5, i, -1);
result = llListReplaceList(dest, src10, i, i);
result = llListReplaceList(dest, src10, i - 5, i + 4);
result = llListReplaceList(dest, src10, i - 10, i + 9);
result = llListReplaceList(dest, src10, 0, i);
result = llListReplaceList(dest, src10, i, -1);
}
lrlTime = llGetTime();
llSay(0, "LRL Time: " + (string)lrlTime);

// get multi-op time

llSay(0, "Multi-op...");
llResetTime();
for ( i = 10; i < 90; i++ )
{
result = llListInsertList(llDeleteSubList(dest, i, i), src1, i);
result = llListInsertList(llDeleteSubList(dest, i - 5, i + 4), src1, i - 5);
result = llListInsertList(llDeleteSubList(dest, i - 10, i + 9), src1, i - 10);
result = llListInsertList(llDeleteSubList(dest, 0, i), src1, 0);
result = llListInsertList(llDeleteSubList(dest, i, -1), src1, i);
result = llListInsertList(llDeleteSubList(dest, i, i), src5, i);
result = llListInsertList(llDeleteSubList(dest, i - 5, i + 4), src5, i - 5);
result = llListInsertList(llDeleteSubList(dest, i - 10, i + 9), src5, i - 10);
result = llListInsertList(llDeleteSubList(dest, 0, i), src5, 0);
result = llListInsertList(llDeleteSubList(dest, i, -1), src5, i);
result = llListInsertList(llDeleteSubList(dest, i, i), src10, i);
result = llListInsertList(llDeleteSubList(dest, i - 5, i + 4), src10, i - 5);
result = llListInsertList(llDeleteSubList(dest, i - 10, i + 9), src10, i - 10);
result = llListInsertList(llDeleteSubList(dest, 0, i), src10, 0);
result = llListInsertList(llDeleteSubList(dest, i, -1), src10, i);
}
listOpTime = llGetTime();
llSay(0, "OP Time: " + (string)listOpTime);
}
}


The numbers:

I ran the test 3 times in Zoe this afternoon when the sim performance was nearly ideal with no lag.

Base Time: 2.250489
LRL Time: 110.697929
OP Time: 212.998962

Base Time: 2.400459
LRL Time: 111.900650
OP Time: 216.300720

Base Time: 2.250859
LRL Time: 110.450157
OP Time: 213.216507
_____________________
Some people are like Slinkies... not really good for anything, but they sure bring a smile to your face when you push them down the stairs.
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
04-07-2005 11:05
Nice work. Do you think this can be extended to test memory usage in some way? I know that's one big reason I replaced my home-brewed function that used Insert/Delete, because otherwise I'd have to keep around more copies of the same list when passing it to a function. I'd be interested to see if my theories are right, and htat llListReplaceList() uses less memory.
Olmy Seraph
Valued Member
Join date: 1 Nov 2004
Posts: 502
04-07-2005 11:30
From: Lex Neva
Nice work. Do you think this can be extended to test memory usage in some way? I know that's one big reason I replaced my home-brewed function that used Insert/Delete, because otherwise I'd have to keep around more copies of the same list when passing it to a function. I'd be interested to see if my theories are right, and htat llListReplaceList() uses less memory.


Thanks! Probably could use this approach for memory testing. I haven't done any memory testing in LSL, so you prob would know bettern than I. The wiki says llGetFreeMemory now returns free size based on the high water mark of used memory, instead of actual free memory. You could break this into separate scripts for the different cases and test free memory after each run - that would probably work ok.
_____________________
Some people are like Slinkies... not really good for anything, but they sure bring a smile to your face when you push them down the stairs.