Skip to content
New issue

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

Time units change during one run #222

Open
VitaliyKulikov opened this issue May 24, 2016 · 10 comments
Open

Time units change during one run #222

VitaliyKulikov opened this issue May 24, 2016 · 10 comments

Comments

@VitaliyKulikov
Copy link

Could we don't change time-units in output during one run.
I can't parse log file correctly then time is in different units.

@maurcarvalho
Copy link
Contributor

maurcarvalho commented May 24, 2016

@VitaliyKulikov what you mean? Could you please provide an example containing:

  • Problem description
  • What is showing in your log
  • Expected result

Thanks a lot,
MC

@VitaliyKulikov
Copy link
Author

@mauriciojr thanks for quick replay. sure, here is more details.

i need parse log file and collect time for some executions. so, in log i have:

#methodA(...): in 11.90ms (too slow!)
#methodB(...): in 20.15ms (too slow!)
#methodC(...): in 2min (too slow!)

i know that i can cast all time to one unit, but wanna that all time was in one unit - ms OR min, like:

#methodA(...): in 11.90ms (too slow!)
#methodB(...): in 20.15ms (too slow!)
#methodC(...): in 120000ms (too slow!)

@dmarkov
Copy link

dmarkov commented May 30, 2016

@yegor256 dispatch this issue please, see par.21

@yegor256
Copy link
Member

@VitaliyKulikov well, this is by design... How would you suggest to make this behavior configurable? The only idea I have is through system properties. something like java -Djcabi.log.smartTime=false Would that work?

@VitaliyKulikov
Copy link
Author

@yegor256 sure, it will work.
as a suggestion, i prefer to use annotation parameter, like:

@Loggable(smartTime = false)

also, as i understand time-unit will be MICROSECONDS by default.

@yegor256
Copy link
Member

@VitaliyKulikov in that case, maybe it's better to do it this way:

@Loggable(timeUnit = TimeUnit.MICROSECONDS)

By default timeUnit attribute will be null, which will mean that the most appropriate time unit will be used. Make sense?

@VitaliyKulikov
Copy link
Author

@yegor256 awesome )).
just in case, if timeUnit = TimeUnit.SECONDS we will lost precision OR we wanna float?
For example converting 999 milliseconds to seconds results in 0

@yegor256
Copy link
Member

@VitaliyKulikov maybe we can add one more argument precision, which will contain the amount of digits after the dot? by default it's -1, which means "up to you":

@Loggable(timeUnit = TimeUnit.MICROSECONDS, precision = 2)

what do you think?

@VitaliyKulikov
Copy link
Author

@yegor256 yep. i think, it will be the best solution for all needs.
just to clarify, here are few use-cases:

@Loggable(timeUnit = TimeUnit.SECONDS, precision = 2)
input: 100 ms | output: 0.00 s
input: 10000 ms | output: 0.01 s
input: 1000000 ms | output: 1.00 s

@Loggable(timeUnit = TimeUnit.MICROSECONDS)
input: 100 ms | output: 100 ms
input: 20000 ms | output: 20000 ms

@yegor256
Copy link
Member

@VitaliyKulikov not exactly :) "ms" means milliseconds, while "μs" means microseconds. but you got the idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants