Docs Blog Get-it

Measuring Script Sizes (LMF and LMFC)

A method of indicating script code and data sizes in REBOL.


Single files
Multiple files


To compare scripts, we wanted to have a simple method of judging the true computational (executional) size of a script, a collection of scripts, or data related files.

It turns out that this is trivial to do from any version of REBOL, so the goal was to standardize the method and the terminology.

In a rough way this also serves as a general method of judging program complexity. For example, a 100KB LMFC program is much more complex than a 10KB LMFC. A 1MB LMFC is extremely complex - typically the work of a large team.


In REBOL, scripts can be loaded, converted from source code (strings) into blocks of values and words, then molded back into source code (strings again). In doing a mold of a load you can see the true size of the code of a program, less its comments and any special whitespace formatting. Furthermore, if If mold/flat is used, then the beginning whitespace is removed from each line as well. This is not a problem because REBOL automatically inserts indentation if that same flat code is load mold again.


We will use notations like 10 KB LM and 5 KB LMFC for indicating code sizes (but it works also for data, although that's not related to complexity.)

Here are what the notations mean:

Notation Description
LM LOAD then MOLD the code or data.
LMF LOAD then MOLD/flat the code or data.
LMFC LOAD, MOLD/flat, then COMPRESS the code or data. As small as it can get and still remain the same content.

A few notes:


Here are a few examples.

Single files

For a single script or data file, the LM size is:

print length? mold load %script.r

The LMF size is:

print length? mold/flat load %script.r

And the LMFC size is:

print length? compress mold/flat load %script.r

Multiple files

Here is a tested example that computes the LM sizes for an application that consists of several files:

REBOL [Title: "Compute LMFC for a set of files."]

block: make block! 100

foreach file [
    append block load file

molded: mold block
mold-flat: mold/flat block

kb?: func [d] [round/to (length? d) / 1024 .1]

print [
    "LM:" kb? molded lf
    "LMF:" kb? mold-flat lf
    "LMFC:" kb? compress mold-flat lf

The results are:

LM: 48.3
LMF: 32.1
LMFC: 11.0
About | Contact | PrivacyREBOL Technologies 2021