Lua Vector

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Lua Vector

Post 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.
User avatar
Przemator
Party member
Posts: 107
Joined: Fri Sep 28, 2012 6:59 pm

Re: Lua Vector

Post 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.
marthev
Prole
Posts: 1
Joined: Sat Sep 03, 2022 6:51 pm

Re: Lua Vector

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 43 guests