Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

19
LINES

< > BotCompany Repo | #1033433 // FPSCounter

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (9204L/51K).

sclass FPSCounter {
  new Timestamp started;
  double counter;
  
  synchronized void inc() { counter++; }

  synchronized double get() {
    ret doubleRatio(counter, secondsSinceStart());
  }
  
  synchronized bool isEmpty() { ret counter == 0; }
  
  double secondsSinceStart() { ret elapsedSeconds(started); }
  
  synchronized void reset {
    started = tsNow();
    counter = 0;
  }
}

Author comment

Began life as a copy of #1006530

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033433
Snippet name: FPSCounter
Eternal ID of this version: #1033433/4
Text MD5: e6dd717c6df01eee9d591fb8f97a633a
Transpilation MD5: 80fc5bc5b5ac8ead49b8e3b0e4e41911
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-07-19 21:08:57
Source code size: 407 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 172 / 322
Version history: 3 change(s)
Referenced in: #1033685 - RollingFPSCounter - produces a new value every second and averages over 5 seconds [dev.]
#1033686 - DoubleFPSCounter - always shows counter for previous whole second
#1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)