processing-1.2.0.1: Web graphic applications with processing.js.

Safe HaskellNone

Graphics.Web.Processing.Optimize

Contents

Description

Code optimization module.

Synopsis

Substitution Optimization

Algorithm

optimizeBySubstitution :: ProcScript -> ProcScriptSource

Optimization by substitution. It looks for commonly repeated operations and create variables for them so they are only calculated once.

This optimization is applied automatically when using execScriptM.

Look at the generated to code to see which substitutions have been made. They are delimited by comments, with title Substitution Optimization settings. If this is not present, no substitution has been made.

Properties

prop_optimizeBySubstitution_projection :: ProcScript -> BoolSource

Optimizations are projections. In particular:

 let f = optimizeBySubstitution
 in  f x == f (f x)

This function checks that this equality holds for a given x. Apply it to your own script to check that the property is true. Tests has been applied to randomly generated scripts, but for them, fid.