You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Tanja Santner <sa...@gmx.at> on 2023/03/25 09:14:16 UTC

JDBC Request - get results in microseconds or nanoseconds

Hi,
 
I'm using JMeter 5.5 for testing my PostgreSQL database with JDBC Request. I'm getting my results in milliseconds - is there any way to get the results in nanoseconds or microseconds for more precise results? 
 
Thanks for helping,
Tanja

Re: JDBC Request - get results in microseconds or nanoseconds

Posted by Felix Schumacher <fe...@internetallee.de>.
Am 25.03.23 um 10:14 schrieb Tanja Santner:
> Hi,
>   
> I'm using JMeter 5.5 for testing my PostgreSQL database with JDBC Request. I'm getting my results in milliseconds - is there any way to get the results in nanoseconds or microseconds for more precise results?

With JMeter's built-in timer, you will not get more precision than 
milliseconds.

If you are willing to do some work on your own, you could use pre- and 
post-processors to time the samplers yourself and log the duration (and 
post-process those on your own):

Add a JSR223 PreProcessor and a JSR 223 PostProcessor on the top level 
of your Thread Group and use

vars.putObject("startTime",System.nanoTime())
for the PreProcessor script and

log.info("sampler: {}, durationInNanos: 
{}",sampler.name,System.nanoTime()-vars.getObject("startTime"))
for the PostProcessor script.
  
In your jmeter.log file, you should find log entries of the form

2023-03-26 14:59:10,116 INFO o.a.j.e.J.calc duration in nanoseconds: sampler: Do nothing, durationInNanos: 59063

("calc duration in nanoseconds" is the name of the PostProcessor)

To change the precision for the timer in JMeter, we would have to replace all timer related code and most probably all (external/third party) plug-ins. That seems a bit unrealistic.

But, if you think it would help your use case, feel free to open an issue on our bug tracker.

Felix