Skip to content

Commit

Permalink
Benchmark for Angle computing methods
Browse files Browse the repository at this point in the history
  • Loading branch information
broadsw0rd committed Mar 31, 2016
1 parent d7c74e9 commit 3ffd028
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ i start benchmark, plase wait a bit...
Distance
√ Vector.distance(one, another) x 48,746,551 ops/sec ±1.34% (87 runs sampled)
√ Vector#distance(vector) x 51,477,832 ops/sec ±1.06% (88 runs sampled)
Angle computing
√ Vector.angleOf(vector) x 10,650,060 ops/sec ±0.55% (90 runs sampled)
√ Vector#angleOf() x 10,789,058 ops/sec ±0.73% (87 runs sampled)
√ Vector.angleTo(one, another) x 8,421,258 ops/sec ±0.64% (87 runs sampled)
√ Vector#angleTo(vector) x 8,619,643 ops/sec ±0.56% (88 runs sampled)
```

Expand Down
38 changes: 38 additions & 0 deletions bench/benchmarks/angle.bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
var Vector = require('../../dist/vectory.js')
var rand = require('../rand.js')

module.exports = {
'Vector.angleOf(vector)': (function () {
var vector = new Vector(rand(0, 100), rand(0, 100))

return function () {
return Vector.angleOf(vector)
}
}()),

'Vector#angleOf()': (function () {
var self = new Vector(rand(0, 100), rand(0, 100))

return function () {
return self.angleOf()
}
}()),

'Vector.angleTo(one, another)': (function () {
var one = new Vector(rand(0, 100), rand(0, 100))
var another = new Vector(rand(0, 100), rand(0, 100))

return function () {
return Vector.angleTo(one, another)
}
}()),

'Vector#angleTo(vector)': (function () {
var self = new Vector(rand(0, 100), rand(0, 100))
var vector = new Vector(rand(0, 100), rand(0, 100))

return function () {
return self.angleTo(vector)
}
}())
}
3 changes: 2 additions & 1 deletion bench/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ var benchmarks = {
'Normalization': require('./benchmarks/normalization.bench.js'),
'Magnitude': require('./benchmarks/magnitude.bench.js'),
'Dot Product': require('./benchmarks/dot-product.bench.js'),
'Distance': require('./benchmarks/distance.bench.js')
'Distance': require('./benchmarks/distance.bench.js'),
'Angle computing': require('./benchmarks/angle.bench.js')
}

var keys = Object.keys(benchmarks)
Expand Down

0 comments on commit 3ffd028

Please sign in to comment.