Difference between revisions of "User:Pedro Oval/Mono code memory usage"

From Second Life Wiki
Jump to navigation Jump to search
(Saving work in progress)
 
(Finished first pass)
Line 6: Line 6:
|- {{Hl2}}
|- {{Hl2}}
!Construct !! Bytes used !! Comments
!Construct !! Bytes used !! Comments
|- style="text-align:center"
|-
| ;      || 0 ||
| ;      || 0 ||
|- style="text-align:center"
|-
| {}    || 0 ||
| {}    || 0 ||
|- style="text-align:center"
|-
| x      || 2 ||
| return || 1  || Tested in event and without arguments
|- style="text-align:center"
|-
| -x    || 3 ||
| x      || 2  ||
|- style="text-align:center"
|-
| ~x    || 3 ||
| (x)    || 2  ||
|- style="text-align:center"
|-
| !x    || 5 ||
| (integer)x || 2  ||
|- style="text-align:center"
|-
| --x    || 6 || Pre-decrement
| (float)x || 3  ||
|- style="text-align:center"
|-
| ++x    || 6 || Pre-increment
| f     || 2  ||
|- style="text-align:center"
|-
| x--    || 8 || Post-decrement
| (float)f || 2 ||
|- style="text-align:center"
|-
| x++    || 8 || Post-increment
| (integer)f || 7 ||
|- style="text-align:center"
|-
| x=y    || 4 || Assignment
| -x    || 3 ||
|- style="text-align:center"
|-
| x==y  || 5 || Comparison
| ~x    || 3 ||
|- style="text-align:center"
|-
| x+y    || 4 ||
| !x    || 5 ||
|- style="text-align:center"
|-
| x-y    || 8 || !?!?
| --x    || 6 || Pre-decrement (same bytes as x=~-x)
|- style="text-align:center"
|-
| x*y    || 4 ||
| ++x    || 6 || Pre-increment (same bytes as x=-~x)
|- style="text-align:center"
|-
| x/y    || 8 ||
| x--    || 8 || Post-decrement
|- style="text-align:center"
|-
| x&y    || 4 || Bitwise
| x++    || 8 || Post-increment
|- style="text-align:center"
|-
| x&&y  || 4 || Logical
| x=y    || 4 || Assignment
|- style="text-align:center"
|-
| x*y   || 4 ||
| x==y  || 5 || Comparison
|- style="text-align:center"
|-
| x*y   || 4 ||
| f=x    || 5  || Implicit conversion from integer to float
|- style="text-align:center"
|-
| x*y   || 4 ||
| f=(float)x || 5  || Explicit conversion from integer to float
|-
| x!=y  || 8  || Same bytes as !(x==y)
|-
| x*y    || 4  ||
|-
| x/y    || 8  ||
|-
| x%y    || 8  || Modulo
|-
| x+y    || 4 ||
|-
| x-y    || 8 || !?!?
|-
| x+-y  || 5  || Saves 3 bytes vs. a subtraction!
|-
| x*y    || 4 ||
|-
| x/y    || 8 ||
|-
| x&y    || 4 || Bitwise
|-
| x&&y  || 13 || Logical
|-
| x<nowiki>|</nowiki>y    || 4 || Bitwise
|-
| x<nowiki>||</nowiki>y  || 10 || Logical
|-
| x^y    || 4  || Bitwise
|-
| x<<y  || 8  || Bitwise shift left (can be simulated with mult in most cases)
|-
| x>>y  || 8  || Bitwise shift right
|-
| x<y    || 5  ||
|-
| x>y    || 5  ||
|-
| x<=y  || 8  || Same bytes as !(x>y)
|-
| x>=y  || 8  || Same bytes as !(x<y)
|-
| x+=y  || 6  || Same bytes as x=x+y
|-
| x-=y   || 10 || Same bytes as x=x-y
|-
| x+=-y  || 7  || Saves 3 bytes vs x-=y
|-
| x*=y   || || Same as x=x*y
|-
| x/=y  || 10 || Same as x=x/y
|-
| x%=y  || 10 || Same as x=x%y
|-
| if(x); || 6  ||
|-
| if(x); else; || 11 ||
|}
|}
<pre><nowiki>
;;  0.000000
return;  1.000000
x;  2.000000
(x);  2.000000
(integer)x;  2.000000
(float)x;  3.000000
(float)x;  0.000000
f;  2.000000
(float)f;  2.000000
(integer)f;  7.000000
f=x;  5.000000
f=(float)x;  5.000000
!x;  5.000000
-x;  3.000000
~x;  3.000000
++x;  6.000000
--x;  6.000000
x++;  8.000000
x--;  8.000000
x+y;  4.000000
x-y;  8.000000
x*y;  4.000000
x/y;  8.000000
x%y;  8.000000
x+-y;  5.000000
x<<y;  8.000000
x>>y;  8.000000
x<y;  5.000000
x<=y;  8.000000
x>y;  5.000000
x>=y;  8.000000
!(x<y);  8.000000
-x<-y;  7.000000
x==y;  5.000000
x!=y;  8.000000
x&y;  4.000000
x^y;  4.000000
x|y;  4.000000
x&&y;  13.000000
x||y;  10.000000
x=y;  4.000000
x+=y;  6.000000
x-=y;  10.000000
x*=y;  6.000000
x/=y;  10.000000
x%=y;  10.000000
x=x+y;  6.000000
x=x-y;  10.000000
x=x*y;  6.000000
x=x/y;  10.000000
x=x%y;  10.000000
if(x);  6.000000
if (x);else;  11.000000
if (x) x;else y;  15.000000
if (x) x;  8.000000
if (x) x; else;  13.000000
if (x) x; else x;  15.000000
</nowiki></pre>

Revision as of 13:49, 8 February 2013

Here are some memory usage results I've obtained with Mono, for common language constructs. They were obtained by replicating each line to test 512 times and looking at llGetFreeMemory right at the beginning of the script.

Results for local integer variables x, y, and local float variables f, g:

Construct Bytes used Comments
; 0
{} 0
return 1 Tested in event and without arguments
x 2
(x) 2
(integer)x 2
(float)x 3
f 2
(float)f 2
(integer)f 7
-x 3
~x 3
!x 5
--x 6 Pre-decrement (same bytes as x=~-x)
++x 6 Pre-increment (same bytes as x=-~x)
x-- 8 Post-decrement
x++ 8 Post-increment
x=y 4 Assignment
x==y 5 Comparison
f=x 5 Implicit conversion from integer to float
f=(float)x 5 Explicit conversion from integer to float
x!=y 8 Same bytes as !(x==y)
x*y 4
x/y 8
x%y 8 Modulo
x+y 4
x-y 8 !?!?
x+-y 5 Saves 3 bytes vs. a subtraction!
x*y 4
x/y 8
x&y 4 Bitwise
x&&y 13 Logical
x|y 4 Bitwise
x||y 10 Logical
x^y 4 Bitwise
x<<y 8 Bitwise shift left (can be simulated with mult in most cases)
x>>y 8 Bitwise shift right
x<y 5
x>y 5
x<=y 8 Same bytes as !(x>y)
x>=y 8 Same bytes as !(x<y)
x+=y 6 Same bytes as x=x+y
x-=y 10 Same bytes as x=x-y
x+=-y 7 Saves 3 bytes vs x-=y
x*=y 6 Same as x=x*y
x/=y 10 Same as x=x/y
x%=y 10 Same as x=x%y
if(x); 6
if(x); else; 11