Profile-guided decisions
Static analysis can’t always tell how big a collection gets: the size may depend on input or on how often a function is called. Profiling runs your original program once with light instrumentation that records each collection’s final length:
viscosity profile app.js -o profile.jsonviscosity build app.js --profile profile.json -o app.vsc.jsexplain marks measured sizes (measured). A collection measured below
--min-size is left as objects.
The profile is a JSON object mapping collection names to
{ "maxLength": n }. If you write or edit one by hand, each maxLength
must be a non-negative number; otherwise --profile is an error, not
silently ignored (see Errors and validation).
Two limits to know about:
- JavaScript only.
viscosity profileruns the instrumented program with Node, so it profiles.jsprograms (and.tsones with the TypeScript CLI), in both CLIs; Node.js must be on thePATH. It refuses.pyfiles with a clear error; Python profiling isn’t supported yet. If the program fails, there is no profile. - Keyed by variable name. A profile records sizes per collection name, so two collections with the same name in different functions share one entry.