saltbot-org / saltbot

automated virtual betting bot
GNU General Public License v2.0
52 stars 45 forks source link

refactor math algos #516

Closed ghost closed 1 year ago

ghost commented 1 year ago

may fix performance issues, may totally bork things.

looking for peer review before merging to master.

calexil commented 1 year ago

@reconman looks clear to me, please test. This is my buddy rytak, he moved all the maths to floats to accelerate the calculations, should increase prediction speed by a noticeable margin

reconman commented 1 year ago

https://www.w3schools.com/js/js_numbers.asp

Unlike many other programming languages, JavaScript does not define different types of numbers, like integers, short, long, floating-point etc.

JavaScript numbers are always stored as double precision floating point numbers, following the international IEEE 754 standard.

This format stores numbers in 64 bits, where the number (the fraction) is stored in bits 0 to 51, the exponent in bits 52 to 62, and the sign in bit 63

This PR has no effect.

If it does, please add timers to the code and compare both versions.

The operation to measure would be the calculation of a new chromosome based on an imported one.

There should be at least 10k imported battle records, so a few more (which are added during the calculation) aren't scientifically significant.

ghost commented 1 year ago

That would explain a bit. Thanks for the link recon.

Appears that my changes here make it compliant with JS arithmetic recommendations. Done via JIT division for floating numbers that require a decimal output.

ghost commented 1 year ago

Closing PR. Slowdown appears to be happening elsewhere within the code. I'll make an issue post if anything is found.