Linear Interpolation
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
// Raw
function linearInterpolation(min, max, k) {
return min + (max - min) * k;
}
// Functional
function linearInterpolationF(min, max) {
var delta = max - min;
return function(k) {
return min + delta * k
};
}
// OOP
function LinearInterpolator(min, max) {
this.min = min;
this.delta = max - min;
}
LinearInterpolator.prototype.interpolate = function(k) {
return this.min + this.delta * k;
};
var interpolations = 100000;
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Raw |
|
pending… |
Functional |
|
pending… |
OOP -> Functional |
|
pending… |
OOP (revised) |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by Andre
- Revision 2: published
- Revision 3: published
- Revision 4: published
- Revision 5: published by Andre
- Revision 6: published by Andre
0 comments