REBOL
Downloads Products Documents Community

Measuring Script Sizes (LMF and LMFC)

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

Contents

Purpose
Concepts
Notations
Examples
Single files
Multiple files

Purpose

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.

Concepts

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.

Notations

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:

Examples

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 [
    %funcs.r
    %cgi.r
    %emit-html.r
    %scan-doc.r
    %scan-titles.r
    %valid-user.r
    %build-docs.r
][
    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 | Support | Privacy | LicenseREBOL Technologies 2017