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

20
LINES

< > BotCompany Repo | #1033686 // DoubleFPSCounter - always shows counter for previous whole second

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

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

sclass DoubleFPSCounter {
  new FPSCounter counter;
  volatile double value;

  synchronized void inc() {
    if (counter.secondsSinceStart() >= 1) {
      value = counter!;
      counter = new FPSCounter;
    }
    counter.inc();
  }

  synchronized double get() {
    ret value;
  }
  
  synchronized toString {
    ret counter.isEmpty() ? "" : formatDoubleX(get(), 1) +  " FPS";
  }
}

Author comment

Began life as a copy of #1033433

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033686
Snippet name: DoubleFPSCounter - always shows counter for previous whole second
Eternal ID of this version: #1033686/9
Text MD5: d48f778abd7c0882ab0483bd967030e7
Transpilation MD5: 1125c720e49141e061b6e4e505a906c9
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:09:59
Source code size: 406 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 171 / 308
Version history: 8 change(s)
Referenced in: [show references]