Basic DPS tracker?

Hey, and thanks for reading in advance.

I’m helping a buddy out with his outbreak-survival lookalike game, and I’m attempting to code a DPS tracker for the training dummies.

I can calculate DPS just fine for a weapon of which I already know the damage value and fire rate, but for this, I’m looking to extrapolate DPS from the rate at which the dummy’s health depletes. I started out simply adding the health difference to a variable and then subtracting that difference a second later, but I realized that this was not a true measure of damage dealt per second - just the total damage dealt within that second.

Has anyone coded something like this before? Any formulas you might share? Any help or advice is appreciated.

Maybe you could try looking over a longer span of time, like 5 seconds, and dividing the damage dealt by 5.