# ParseInt vs Trunc vs BestBoi (v6)

## Description

Comparison of assorted point hash functions

## Setup

``````/**
* Pros:
*  - Human Readable hash (But does it really need to be human readable?)
* Cons:
*  - Slow
*  - Not uniform (there are more items in slot 0|0 than any other slot)
*/
function ParseIntHash(x, y) {
x = parseInt(x) - (parseInt(x) % 8);
y = parseInt(y) - (parseInt(y) % 8);
return x + "|" + y;
}
/**
* Pros:
*  - Human Readable hash (But does it really need to be human readable?)
*  - Fast
* Cons:
*  - Non-uniform (there are more items in slot 0|0 than any other slot)
*/
function TruncIntHash(x, y) {
x = Math.trunc(x) - (Math.trunc(x) % 8);
y = Math.trunc(y) - (Math.trunc(y) % 8);
return x + "|" + y;
}
/**
* Pros:
*  - Human Readable hash (But does it really need to be human readable?)
*  - Fast
*  - Uniform (same number of items in every slot)
* Cons:
*/
function BestBoiHash(x, y) {
return (x >> 3) + "|" + (y >> 3);
}
var X = Math.random() * 1000 - 500;
var Y = Math.random() * 1000 - 500;
var RESULT = 0;``````

## Teardown

``````X = Math.random() * 1000 - 500;
Y = Math.random() * 1000 - 500;
RESULT = 0;``````

## Test runner

Testing in
TestOps/sec
Parse Integer
``RESULT = ParseIntHash(X, Y);``
``RESULT = TruncIntHash(X, Y);``
``RESULT = BestBoiHash(X, Y);``