MCPcopy Index your code
hub / github.com/ChartGPU/ChartGPU / calculateExactFPS

Function calculateExactFPS

src/ChartGPU.ts:974–993  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

972 };
973
974 const calculateExactFPS = (): ExactFPS => {
975 if (frameTimestampCount < 2) {
976 return 0 as ExactFPS;
977 }
978
979 const startIndex = (frameTimestampIndex - frameTimestampCount + FRAME_BUFFER_SIZE) % FRAME_BUFFER_SIZE;
980
981 let totalDelta = 0;
982 for (let i = 1; i < frameTimestampCount; i++) {
983 const prevIndex = (startIndex + i - 1) % FRAME_BUFFER_SIZE;
984 const currIndex = (startIndex + i) % FRAME_BUFFER_SIZE;
985 const delta = frameTimestamps[currIndex] - frameTimestamps[prevIndex];
986 totalDelta += delta;
987 }
988
989 const avgFrameTime = totalDelta / (frameTimestampCount - 1);
990 const fps = avgFrameTime > 0 ? 1000 / avgFrameTime : 0;
991
992 return fps as ExactFPS;
993 };
994
995 const calculateFrameTimeStats = (): FrameTimeStats => {
996 if (frameTimestampCount < 2) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected