Frames-per-second counter for Javascript.
importFpsfrom'@dimensionalpocket/fps'// Initialize a counter with a given sample size in frames.// Default sample size is 60 (1 second).// Larger sizes affect average calculations.constfps=newFps(300)// 5 seconds// Synchronous usage (no await):fps.start()// ... your codefps.stop()// Synchronous or asynchronous:varstartAt=fps.now()// ... your codefps.add(fps.now()-startAt)// Returns the average FPSfps.average()// Usage with reactive libsfps.total// returns the sum of all given valuesfps.size// the sample countfps.total/fps.size// the average valuefps.max// the largest value (resets every 10 iterations)MIT