#GitHub - seantheman1/Gfps: A simple impr...
1 messages · Page 1 of 1 (latest)
this is a bad implementation that does not really work well
first of all, floating point has limited precision and doing 1 / frametime is suboptimal
what you can do is simply:
---@const
local historySeconds = 1
local frames = { }
local function onFrame()
local t = SysTime()
while frames[1] < t - historySeconds do
table.remove(frames, 1)
end
table.insert(frames, t)
end
and then use the frames variable as the source of frame times to do the math
for the current fps, you simply get the count after onFrame: #frames
for the average frametime, calculate differences between records and... average them
for the average fps, keep a history of the fps values at each frame for some time
etc etc, you get it
the provided implementation is, however, not the most efficient, but its good enough xd
I’ll have to give that a try thanks for the optimization side of things
If u wanna change anything i posted it on GitHub you could make a pull request
@elder wasp Thanks
kinda busy with stuff so all i can is just provide a better (although untested) implementation of it right now
Alright
local historySeconds = 10
-- do note that this only works till the 2^51 (or 52?)st frame, and then probably stops working right due to FP precision
local frames = {
bottom = 0, top = 0,
list = { }
}
local function onFrame()
local t = SysTime()
-- remove records that are too old
local list = frames.list
local bottom = frames.bottom
while list[bottom] and list[bottom] < t - historySeconds do
list[bottom] = nil
bottom = bottom + 1
end
frames.bottom = bottom
local top = frames.top + 1
frames.top = top
list[top] = t
end
-- some examples
-- (all assume there is at least one frame)
-- how many frames are recorded
do
print(frames.top - frames.bottom)
end
-- how much time is recorded
do
print(frames.list[frames.top] - frames.list[frames.bottom])
end
-- how may frames have passed in the last N seconds
local function frameCount(interval)
local t = SysTime() - interval
local list = frames.list
local intervalBottom
for i = frames.bottom, frames.top do
if frames[i] >= t then
intervalBottom = i
break
end
end
return intervalBottom and frames.top - intervalBottom
end
i think that will be way more efficient
less overhead for counting, less overhead for inserting/removing frames in the history
Currently I’m not at my pc but when I get to it I’ll make some changes
you may want to write the description yourself instead of chatgpt-ing it
Performance Optimization: Provides insights into potential bottlenecks and optimization suggestions
it's an fps display not a profiler
Use color_white?
Copilot moment
Nah jk, sometimes I get recommended that and I'm like "that's white bro"
It would be personally a good thing to implement 1% and 5%, mins really doesn't help a lot because it doesn't give the full picture since a stutter might trigger it, in places where it shouldn't be accounted as gameplay
But the % would
I couldn't implement it on mine
https://sharex.imgonzo.dev/f/apxdAyXPE7eWKT5gwFtV.mp4
I couldn't implement it 
Yeah idk why but co pilot always recommends white
I just put white since it easier to remember but yeah lol
True I’ll fix that
Odd I removed that early I probably forgot to make a GitHub commit
1% and 5% lows would be simple but the issue is implanting might be a little odd since I might have to change a few function within in my code to make it possible and without the making graph look funky. I’m reworking the code later today when I get the time
I fixed the GitHub page and steam.
“This addon does not currently support public servers” ??
Your description also states it uses the MIT license while the license file is GPLv2
Again you may want to strongly consider writing the description yourself, it's a simple enough addon
You can’t run client side addons unless they change smth that’s already existing within a public server. For example materials or textures.
I usually write it myself. Most of the stuff I wrote my self but 2 things were written by my friend so I had no idea bro used ai lol it just sounded good. My bad
If u want feel free to check the description again as I’ve fixed any issue related to that
I’ll be updating the add on to support customization. Afterwards I’ll be adding 1% low and 5% lows, to show more performance metrics.
The way it's worded would make me think I, as a server owner, wouldn't be able to use it even if added to the server. Might be worth specifying that it will only work in MP if the server also has it instead