This repo compares the performance of different linear-algebra/vector implementations.
Use an ADT
if you want to do vector math for everything other than WebGL in Elm!
It is more descriptive and has the best performance.
This Package uses elm-explorations/linear-algebra and FFIs the webgl-mjs library.
However, for plain vector operations, this is the slowest implementation.
type Vec2
= Vec2 Float Float
type alias Vec2 =
{ x : Float
, y : Float
}
type alias Vec2 =
( Float, Float )
nix-shell -p elmPackages.elm
elm reactor
- Go to
http://localhost:8000/benchmarks/Suite.elm
Although in firefox the performance is ~25% slower for the ADT compared to tuples, they still have significant more advantages.
Browser | Implementation | Runs / second | Goodness of fit | Winner |
---|---|---|---|---|
Firefox | Vec | 3,483,184 | 99.45% | |
Firefox | VecADT | 28,548,490 | 99.35% | |
Firefox | VecRecord | 20,194,153 | 99.05% | |
Firefox | VecTuple | 40,845,616 | 98.97% | * |
Chrome | Vec | 3,421,129 | 99.79% | |
Chrome | VecADT | 184,913,847 | 99.84% | * |
Chrome | VecRecord | 17,422,017 | 99.87% | |
Chrome | VecTuple | 185,103,925 | 99.79% | * |
Safari | Vec | 3,482,573 | 98.69% | |
Safari | VecADT | 12,057,775 | 98.82% | * |
Safari | VecRecord | 8,059,167 | 99.05% | |
Safari | VecTuple | 12,414,330 | 99.26% | * |
Browser | Implementation | Runs / second | Goodness of fit | Winner |
---|---|---|---|---|
Firefox | Vec | 2,091,805 | 99.86% | |
Firefox | VecADT | 18,715,485 | 99.48% | |
Firefox | VecRecord | 10,560,354 | 99.59% | |
Firefox | VecTuple | 25,889,075 | 99.81% | * |