I thought I'd run some numbers to see what size variable scopes appear
in typical applications. Currently, for heap-based scoping, we optimize
up to 4 local variables in fields, and anything larger we only use an
array structure to contain. Here's the breakdown for a few apps/scripts:
Version-number updating script, during our build:
{0=481, 1=141, 2=116, 3=38, 4=21, 5=11, 6=10, 7=5, 8=4, 9=2, 10=3, 11=2,
14=1}
gem install rake, with rdoc/ri generation:
{0=3720, 1=1372, 2=781, 3=282, 4=135, 5=91, 6=53, 7=26, 8=21, 9=16,
10=11, 11=8, 12=5, 47=1, 13=2, 14=1, 17=1, 18=1, 21=1, 20=1, 23=1}
rails appname:
{0=2902, 1=1593, 2=652, 3=270, 4=122, 5=65, 6=31, 7=24, 8=16, 9=10,
10=5, 11=5, 12=1, 13=3, 14=1, 23=1, 25=2}
run rails in dev mode, request index, request info:
{0=8561, 1=3706, 2=2254, 3=789, 4=323, 5=168, 6=97, 7=51, 8=28, 9=24,
10=7, 11=9, 12=3, 13=6, 14=3, 15=5, 19=1, 20=1, 23=1, 22=1, 25=2, 28=1}
The numbers aren't particularly surprising. Optimizing only scopes up to
4 variables is pretty pragmatic and covers the vast majority, obviously.
But it's interesting to see that there are still substantial numbers of
scopes with more than four variables.
- Charlie
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email