| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -23,24 +23,20 @@ public class Profiler { | |
| private Long startTickInMs; | ||
| private Long stopTickInMs; | ||
|
|
||
| public Profiler() { | ||
| startTickInMs = null; | ||
| stopTickInMs = null; | ||
| } | ||
|
|
||
| public long start() { | ||
| startTickInMs = System.currentTimeMillis(); | ||
| startTickInMs = System.nanoTime(); | ||
| return startTickInMs.longValue(); | ||
| } | ||
|
|
||
| public long stop() { | ||
| stopTickInMs = System.currentTimeMillis(); | ||
| stopTickInMs = System.nanoTime(); | ||
| return stopTickInMs.longValue(); | ||
| } | ||
|
|
||
| public long getDuration() { | ||
| if (startTickInMs != null && stopTickInMs != null) | ||
| if (startTickInMs != null && stopTickInMs != null) { | ||
| return stopTickInMs.longValue() - startTickInMs.longValue(); | ||
|
Comment thread
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualityhasn't the semantics changed as it no longer return milliseconds but now micro-(or even nano-) seconds? (this goes for stop and start as well btw. Did you check the callers?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI did... and it doesn't change. Only the resolution does, Quick googled that one here for you: https://blogs.oracle.com/dholmes/entry/inside_the_hotspot_vm_clocks Implementation is still the same: http://stackoverflow.com/questions/351565/system-currenttimemillis-vs-system-nanotime Cheers,
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityYes, and so does the semantics of the return of starts() stop() and getDuration().
Sorry, something went wrong.
All reactions
|
||
| } | ||
|
|
||
| return -1; | ||
| } | ||
| Expand All | @@ -55,12 +51,14 @@ public boolean isStopped() { | |
|
|
||
| @Override | ||
| public String toString() { | ||
| if (startTickInMs == null) | ||
| if (startTickInMs == null) { | ||
| return "Not Started"; | ||
| } | ||
|
|
||
| if (stopTickInMs == null) | ||
| if (stopTickInMs == null) { | ||
| return "Started but not stopped"; | ||
| } | ||
|
|
||
| return "Done. Duration: " + getDuration() + "ms"; | ||
| } | ||
| } | ||
| } | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI'd use a new name for the var, like startTickInNanos (and of course stopTickInNanos)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThe nanoTime() is given in Microseconds. So, the MS still fits in.
Cheers,
Wilder
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.