jcabi-aspects
jcabi-aspects copied to clipboard
Time units change during one run
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.
@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
@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!)
@yegor256 dispatch this issue please, see par.21
@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?
@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.
@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?
@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
@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?
@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
@VitaliyKulikov not exactly :) "ms" means milliseconds, while "μs" means microseconds. but you got the idea