Libraryless. Click here for Pure Java version (9204L/51K).
1 | sclass FPSCounter { |
2 | new Timestamp started; |
3 | double counter; |
4 | |
5 | synchronized void inc() { counter++; } |
6 | |
7 | synchronized double get() { |
8 | ret doubleRatio(counter, secondsSinceStart()); |
9 | } |
10 | |
11 | synchronized bool isEmpty() { ret counter == 0; } |
12 | |
13 | double secondsSinceStart() { ret elapsedSeconds(started); } |
14 | |
15 | synchronized void reset { |
16 | started = tsNow(); |
17 | counter = 0; |
18 | } |
19 | } |
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: | 173 / 323 |
Version history: | 3 change(s) |
Referenced in: | [show references] |