开发者

How do I save my Apache jMeter results to a CSV file?

开发者 https://www.devze.com 2023-03-11 19:22 出处:网络
I\'ve created my jMeter test which make 20,000 HTTP requests.I\'ve included the \"View Results in Table\" listener.After running the test, I would like to save the table r开发者_如何学运维esults to a

I've created my jMeter test which make 20,000 HTTP requests. I've included the "View Results in Table" listener. After running the test, I would like to save the table r开发者_如何学运维esults to a CSV file.


Ok, I figured it out. Least intuitive UI ever... Browse the file name as you want from file system using browse option OR fill the absolute file name in 'Filename' field and then start the test. This creates and writes to the file.

Refer attached image. It is possible to choose CSV, XML and JTL format as required. Filename should be complete path.

How do I save my Apache jMeter results to a CSV file?


Just add Aggregate Report to your test plan by choosing Thread->Listener->AggregateReport Run your Test.When it is completed aggregate report will displays the information about the test runs.Here there is an option to save the report as csv.


The way to do it is using beanshell. You need to download the library and add it to the lib folder. Then create a BeanShell sampler with your request and add code. Something like the following would do:

import org.apache.jmeter.services.FileServer;

// Static elements or calculations
String Variable1 = vars.get("ValueForVariable1AsMentionedInJMeterScript");
String Variable2 = vars.get("ValueForVariable1AsMentionedInJMeterScript");
String Variable3 = vars.get("ValueForVariable1AsMentionedInJMeterScript");


// Open File(s)
f = new FileOutputStream(FileServer.getFileServer().getBaseDir()+"\\NameOfTheCSVFile.csv", true); 
p = new PrintStream(f); 

// Write data to file 
p.println(Variable1 + "," + Variable2 + "," + Variable3);

// Close File(s)
p.close();f.close();

//this is for veryfying your code
return jsonOutput;

ValueForVariable1AsMentionedInJMeterScript is the name of your variable in your script.

For more info please see this page: http://hellotestworld.com/2013/05/02/write-a-file-from-a-jmeter-script/


There are many ways you can push for the results. This is CLI way:

STEPS: 1. download the latest jmeter version

  1. Extract in your desired directory. For example, extract to /tmp/
  2. Now, default output file format will be csv. No need to change anything or specify in the CLI command.
  3. Save jmx file from UI console. Say, you have saved on examples directory for example:
  4. Now, Run the command from CLI console: jmeter -n -t examples/test.jmx -l examples/output.csv
#

Now, if you want to change the default format, check the following parameter in jmeter.properties file: jmeter.save.saveservice.output_format=xml

Now if you run the command, ./jmeter -n -t examples/test.jmx -l examples/output.jtl output get stored in xml format.

Now, make the request on multiple server(Additional info query for good knowledge): We can specify host and port as argument/tags in CLI command

./jmeter -n -t examples/test.jmx -l examples/output.csv -JHOST=<HOST> -JPORT=<PORT>


maybe it can be useful for you http://www.2min2code.com/articles/jmeter_intro/simple_data_writer


You can save the result in any of the listener, below are the steps -

Go to Thread--> Add --> Listener --> View result tree(or any other listener) Picture here

Here you can save the file by giving the file name as abc.csv and go for configure, there you need to uncheck xml file and click on csv file. Also the file result abc.csv is by default saved in the bin folder of the apache-jmeter tool.


1.Open Terminal

2.Navigate to bin folder of Jmeter

3.Run jmeter -n –t (path of jmx file)/test.jmx -l(path to save your result)/testresults.csv

-n-It specifies JMeter is to run in non-gui mode

-t-Name of JMX file that you want to run

-l: Name of csv file to log results


In ViewResultsTree there will be an option "write results to a file/Read from a file" under that in the FileName field enter the path where the file needs to be saved along with the filename as "fileName.csv". Click on configure then uncheck "save as XML Option" and check "save as csv".


Open the user.properties file. You might have the value jmeter.save.saveservice.output_format=xml

Change it to

jmeter.save.saveservice.output_format=csv

You can generate the csv file and Output folder by below steps :

1.Open Terminal

2.Navigate to bin folder of Jmeter

sh jmeter.sh -n -t your_JMX_File.jmx -l your_output_csv_file.csv -e -o yourTargetedOutputFolder

0

精彩评论

暂无评论...
验证码 换一张
取 消