reign
Version:
A persistent, typed-objects implementation.
32 lines (27 loc) • 1 kB
JavaScript
;
var _2 = require('./');
var _3 = _interopRequireDefault(_2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
describe('Float32 Hashes', function () {
it(`should hash integer values`, function () {
Array.from({ length: 4096 }, (_, index) => index).forEach(value => {
const result = (0, _3.default)(value);
result.should.equal(Math.floor(result));
result.should.be.above(-1);
result.should.be.below(Math.pow(2, 32) - 1);
});
});
it('should hash float values', function () {
Array.from({ length: 4096 }, (_, index) => index).forEach(value => {
const result = (0, _3.default)(value * Math.random());
result.should.equal(Math.floor(result));
result.should.be.above(-1);
result.should.be.below(Math.pow(2, 32) - 1);
});
});
benchmark("Default", 1000000, {
float32: function float32() {
return (0, _3.default)(Math.random() * Math.pow(2, 16));
}
});
});