I have a question about Jmeter. I configured the thread group informations : number of threads ,ramp-up period , Loop .After running ,my CSV file contains different informations regarding the test performance ,except these configuration data. Where does JMETER save them ?
2 Answers
JMeter doesn't store this kind of information in .jtl result file. The only thing you can configure to be saved is threads count. Add the next line to user.properties file (lives under /bin folder of your JMeter installation)
jmeter.save.saveservice.thread_counts=true
to tell JMeter to store threads number as well. See Default Configuration chapter of Listeners manual entry for more information.
Alternative options are:
- You can get this information from jmeter.log file. Look for something like:
2014/10/23 15:20:43 INFO - jmeter.threads.ThreadGroup: Starting thread group number 1 threads 10 ramp-up 15 perThread 1500.0 delayedStart=false
If you need to store threads number, ramp-up time and loops count into a file you can use Beanshell Sampler for this. Here's the code which will store threads number, ramp-up time and loops count into config.txt file:
import org.apache.commons.io.FileUtils; int threads = ctx.getThreadGroup().getPropertyAsInt("ThreadGroup.num_threads"); int loops = ctx.getThreadGroup().getSamplerController().getPropertyAsInt("LoopController.loops"); int rampup = ctx.getThreadGroup().getPropertyAsInt("ThreadGroup.ramp_time"); File config = new File("config.txt"); if (!config.exists()){ FileUtils.write(config, "Threads: " + threads + " loops: " + loops + " rampup: " + rampup); }
For advanced information on Beanshell scripting in JMeter see How to use BeanShell: JMeter's favorite built-in component guide.
You can get them included in the output results quite easily by appending them to the thread group name, or a sample name.
For example:
- create a new test plan
- add config element user defined variables, with a variable called threads with value 2.
- add a thread group
- set the threads field to '${threads}'
- add a postprocessor->debug postprocessor
- change the name of the debug postprocessor to 'thread ${__threadNum} of ${threads} threads'
when you run this test plan, the sample results will contain an extra entry telling you number of this thread and the total in the group.
you don't need an extra sampler, this is just a demo. you can include the variable anywhere you want it to be displayed or recorded.