Page 2 of 2

Re: Lua Vector

Posted: Thu May 02, 2019 8:20 pm
by raidho36
Well it it does the same check 2 times so that should be removed. But I was referring to the fact that it generates new strings while calling asserts - there should be constant strings only (or an entirely different solution). It's not wrong to perform error checking because overhead is small, but for trivial operations like vector additions it constitutes a very significant fraction of overall performance. Given that it's something usually used in high volume, it adds up fast. With my own library, I would perform this check one time where performance isn't critical, and then put effort into writing code where such errors will never occur to begin with, so there would be no need to check against them on every single operation.

Re: Lua Vector

Posted: Fri May 03, 2019 7:00 am
by Przemator
I should add, that I profiled my code for a simple racing game. First I used hump.vector After 10 seconds of profiling, there have been 50'000 calls to "isvector", which occupies 0.5 sec of CPU time, compared to 2 sec of total time. So I decided to switch to hump.vector-light and I saved 25% of CPU time.

Re: Lua Vector

Posted: Thu Sep 08, 2022 4:35 am
by marthev
raidho36 wrote: Wed May 01, 2019 7:53 pm It generates new strings every time it uses assert, that will be slow. Otherwise, looks like vector library from CPML.

Here's what I use. It's a bit more involved and explicit, but it runs fast.
Can i have the documentation for this, if you have, i really need it...
Please