Difference between revisions of "Talk:Code Sizer"

From Second Life Wiki
Jump to navigation Jump to search
(add one section to guess how the plus four instrument, add one section to blog the design rationale behind the Code Sizer instrument)
 
m (This page intentionally left mostly blank.)
Line 1: Line 1:
= The Plus Four Instrument =
This page intentionally left mostly blank.
 
Part of the inspiration for beginning to teach new people how to measure byte code size was the following fragment from [[Talk:Hex]]
 
::[... snipped ...]
 
::My steps are below:
::# Compile and execute <code>default{state_entry(){llOwnerSay((string)llGetFreeMemory());}}</code> to establish a baseline
::# Paste an implementation at the top of script from #1, compile and run.
::# Subtract the result from #2 from the result of #1; you now have the bytecode cost.
::# Repeat steps #2 & #3 for each implementation.
 
:[... snipped ...]
 
I call that the "plus four" instrument, since so far as I know, quoting from the [[Code Sizer]] article:
 
:Note: Take care to avoid falling into the easy error of printing llGetFreeMemory() before and after you delete the last function of the script. Adding the first function to the script costs an extra 4 bytes. Only people who understand LSO know why, and they haven't yet published that explanation anywhere near here.
 
= Why The [[Code Sizer]] Article Exists =
 
The [[LSL Script Efficiency]] article says "Efficiency is how much resource a particular script uses to accomplish a goal".
 
Yes exactly.
 
We should measure not only [[LSL Script Efficiency#How_Fast_Does_That_Code_Run]] but also how small is that code, as is conventional in academic and commercial computer science. When we rewrite code to produce equivalent results more efficiently, we trade brevity and clarity and conventionality and space and time off against one another. LSL can only measure space and time. We should show exactly how to measure both of those, in order to invite more people to make such measurements, to build a consensus science of how to write small and fast LSL code.
 
LSL gives us [[llGetFreeMemory]] to measure how small is that code, just as LSL gives us [[llGetTimestamp]] to measure how fast does that code run. We the LSL wiki authors have written the [[Code Racer]] and [[Efficiency Tester]] articles to show how to call llGetTimestamp to measure how fast does that code run. Now likewise we should write an article to show how to call llGetFreeMemory to measure how small is that code.
 
I guess we should publish that article separately. Here it is now.

Revision as of 15:54, 24 October 2007

This page intentionally left mostly blank.