Created
August 30, 2019 15:56
-
-
Save jesty/b478cbd4341231286ff60085f9646407 to your computer and use it in GitHub Desktop.
JMeter test with JVM monitoring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.1.1 r1855137"> | |
<hashTree> | |
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true"> | |
<stringProp name="TestPlan.comments"></stringProp> | |
<boolProp name="TestPlan.functional_mode">false</boolProp> | |
<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp> | |
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp> | |
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true"> | |
<collectionProp name="Arguments.arguments"> | |
<elementProp name="host" elementType="Argument"> | |
<stringProp name="Argument.name">host</stringProp> | |
<stringProp name="Argument.value">localhost</stringProp> | |
<stringProp name="Argument.metadata">=</stringProp> | |
</elementProp> | |
<elementProp name="serverProtocol" elementType="Argument"> | |
<stringProp name="Argument.name">serverProtocol</stringProp> | |
<stringProp name="Argument.value">http</stringProp> | |
<stringProp name="Argument.metadata">=</stringProp> | |
</elementProp> | |
<elementProp name="jmxUri" elementType="Argument"> | |
<stringProp name="Argument.name">jmxUri</stringProp> | |
<stringProp name="Argument.value">service:jmx:rmi:///jndi/rmi://localhost:9010/jmxrmi</stringProp> | |
<stringProp name="Argument.metadata">=</stringProp> | |
</elementProp> | |
<elementProp name="serverPort" elementType="Argument"> | |
<stringProp name="Argument.name">serverPort</stringProp> | |
<stringProp name="Argument.value">8080</stringProp> | |
<stringProp name="Argument.metadata">=</stringProp> | |
</elementProp> | |
<elementProp name="reportPrefix" elementType="Argument"> | |
<stringProp name="Argument.name">reportPrefix</stringProp> | |
<stringProp name="Argument.value">test_${__time(MM-dd-yyyy-HH-mm-ss,)}</stringProp> | |
<stringProp name="Argument.metadata">=</stringProp> | |
</elementProp> | |
</collectionProp> | |
</elementProp> | |
<stringProp name="TestPlan.user_define_classpath"></stringProp> | |
</TestPlan> | |
<hashTree> | |
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Main test" enabled="true"> | |
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp> | |
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true"> | |
<boolProp name="LoopController.continue_forever">false</boolProp> | |
<stringProp name="LoopController.loops">1</stringProp> | |
</elementProp> | |
<stringProp name="ThreadGroup.num_threads">1000</stringProp> | |
<stringProp name="ThreadGroup.ramp_time">10</stringProp> | |
<boolProp name="ThreadGroup.scheduler">false</boolProp> | |
<stringProp name="ThreadGroup.duration"></stringProp> | |
<stringProp name="ThreadGroup.delay"></stringProp> | |
</ThreadGroup> | |
<hashTree> | |
<ConfigTestElement guiclass="HttpDefaultsGui" testclass="ConfigTestElement" testname="HTTP Request Defaults" enabled="true"> | |
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true"> | |
<collectionProp name="Arguments.arguments"> | |
<elementProp name="Content-Type" elementType="HTTPArgument"> | |
<boolProp name="HTTPArgument.always_encode">false</boolProp> | |
<stringProp name="Argument.value"></stringProp> | |
<stringProp name="Argument.metadata">=</stringProp> | |
<boolProp name="HTTPArgument.use_equals">true</boolProp> | |
<stringProp name="Argument.name">Content-Type</stringProp> | |
<stringProp name="HTTPArgument.content_type">application\json</stringProp> | |
</elementProp> | |
</collectionProp> | |
</elementProp> | |
<stringProp name="HTTPSampler.domain">${host}</stringProp> | |
<stringProp name="HTTPSampler.port">${serverPort}</stringProp> | |
<stringProp name="HTTPSampler.protocol">${serverProtocol}</stringProp> | |
<stringProp name="HTTPSampler.contentEncoding"></stringProp> | |
<stringProp name="HTTPSampler.path"></stringProp> | |
<stringProp name="HTTPSampler.concurrentPool">6</stringProp> | |
<stringProp name="HTTPSampler.connect_timeout"></stringProp> | |
<stringProp name="HTTPSampler.response_timeout"></stringProp> | |
</ConfigTestElement> | |
<hashTree/> | |
<HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true"> | |
<collectionProp name="HeaderManager.headers"> | |
<elementProp name="" elementType="Header"> | |
<stringProp name="Header.name">Content-Type</stringProp> | |
<stringProp name="Header.value">application/json</stringProp> | |
</elementProp> | |
<elementProp name="" elementType="Header"> | |
<stringProp name="Header.name">Accept</stringProp> | |
<stringProp name="Header.value">application/json</stringProp> | |
</elementProp> | |
</collectionProp> | |
</HeaderManager> | |
<hashTree/> | |
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Simple request" enabled="true"> | |
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp> | |
<elementProp name="HTTPsampler.Arguments" elementType="Arguments"> | |
<collectionProp name="Arguments.arguments"> | |
<elementProp name="" elementType="HTTPArgument"> | |
<boolProp name="HTTPArgument.always_encode">false</boolProp> | |
<stringProp name="Argument.value">{
 | |
"name": "Davide",
 | |
"surname": "Cerbo"
 | |
}</stringProp> | |
<stringProp name="Argument.metadata">=</stringProp> | |
</elementProp> | |
</collectionProp> | |
</elementProp> | |
<stringProp name="HTTPSampler.domain"></stringProp> | |
<stringProp name="HTTPSampler.port"></stringProp> | |
<stringProp name="HTTPSampler.protocol"></stringProp> | |
<stringProp name="HTTPSampler.contentEncoding"></stringProp> | |
<stringProp name="HTTPSampler.path">/test</stringProp> | |
<stringProp name="HTTPSampler.method">POST</stringProp> | |
<boolProp name="HTTPSampler.follow_redirects">true</boolProp> | |
<boolProp name="HTTPSampler.auto_redirects">false</boolProp> | |
<boolProp name="HTTPSampler.use_keepalive">true</boolProp> | |
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> | |
<stringProp name="HTTPSampler.embedded_url_re"></stringProp> | |
<stringProp name="HTTPSampler.connect_timeout"></stringProp> | |
<stringProp name="HTTPSampler.response_timeout"></stringProp> | |
</HTTPSamplerProxy> | |
<hashTree/> | |
</hashTree> | |
<kg.apc.jmeter.jmxmon.JMXMonCollector guiclass="kg.apc.jmeter.vizualizers.JMXMonGui" testclass="kg.apc.jmeter.jmxmon.JMXMonCollector" testname="Memory" enabled="true"> | |
<boolProp name="ResultCollector.error_logging">false</boolProp> | |
<objProp> | |
<name>saveConfig</name> | |
<value class="SampleSaveConfiguration"> | |
<time>true</time> | |
<latency>true</latency> | |
<timestamp>true</timestamp> | |
<success>true</success> | |
<label>true</label> | |
<code>true</code> | |
<message>true</message> | |
<threadName>true</threadName> | |
<dataType>true</dataType> | |
<encoding>false</encoding> | |
<assertions>true</assertions> | |
<subresults>true</subresults> | |
<responseData>false</responseData> | |
<samplerData>false</samplerData> | |
<xml>false</xml> | |
<fieldNames>true</fieldNames> | |
<responseHeaders>false</responseHeaders> | |
<requestHeaders>false</requestHeaders> | |
<responseDataOnError>false</responseDataOnError> | |
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage> | |
<assertionsResultsToSave>0</assertionsResultsToSave> | |
<bytes>true</bytes> | |
<sentBytes>true</sentBytes> | |
<url>true</url> | |
<threadCounts>true</threadCounts> | |
<idleTime>true</idleTime> | |
<connectTime>true</connectTime> | |
</value> | |
</objProp> | |
<stringProp name="filename">${reportPrefix}_memory.csv</stringProp> | |
<longProp name="interval_grouping">1000</longProp> | |
<boolProp name="graph_aggregated">false</boolProp> | |
<stringProp name="include_sample_labels"></stringProp> | |
<stringProp name="exclude_sample_labels"></stringProp> | |
<stringProp name="start_offset"></stringProp> | |
<stringProp name="end_offset"></stringProp> | |
<boolProp name="include_checkbox_state">false</boolProp> | |
<boolProp name="exclude_checkbox_state">false</boolProp> | |
<collectionProp name="samplers"> | |
<collectionProp name="-1524999844"> | |
<stringProp name="-1993889503">Memory</stringProp> | |
<stringProp name="1793609999">${jmxUri}</stringProp> | |
<stringProp name="0"></stringProp> | |
<stringProp name="0"></stringProp> | |
<stringProp name="-1508861468">java.lang:type=Memory</stringProp> | |
<stringProp name="-687755404">HeapMemoryUsage</stringProp> | |
<stringProp name="3599293">used</stringProp> | |
<stringProp name="1237">false</stringProp> | |
<stringProp name="1237">false</stringProp> | |
</collectionProp> | |
</collectionProp> | |
</kg.apc.jmeter.jmxmon.JMXMonCollector> | |
<hashTree/> | |
<kg.apc.jmeter.jmxmon.JMXMonCollector guiclass="kg.apc.jmeter.vizualizers.JMXMonGui" testclass="kg.apc.jmeter.jmxmon.JMXMonCollector" testname="Thread" enabled="true"> | |
<boolProp name="ResultCollector.error_logging">false</boolProp> | |
<objProp> | |
<name>saveConfig</name> | |
<value class="SampleSaveConfiguration"> | |
<time>true</time> | |
<latency>true</latency> | |
<timestamp>true</timestamp> | |
<success>true</success> | |
<label>true</label> | |
<code>true</code> | |
<message>true</message> | |
<threadName>true</threadName> | |
<dataType>true</dataType> | |
<encoding>false</encoding> | |
<assertions>true</assertions> | |
<subresults>true</subresults> | |
<responseData>false</responseData> | |
<samplerData>false</samplerData> | |
<xml>false</xml> | |
<fieldNames>true</fieldNames> | |
<responseHeaders>false</responseHeaders> | |
<requestHeaders>false</requestHeaders> | |
<responseDataOnError>false</responseDataOnError> | |
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage> | |
<assertionsResultsToSave>0</assertionsResultsToSave> | |
<bytes>true</bytes> | |
<sentBytes>true</sentBytes> | |
<url>true</url> | |
<threadCounts>true</threadCounts> | |
<idleTime>true</idleTime> | |
<connectTime>true</connectTime> | |
</value> | |
</objProp> | |
<stringProp name="filename">${reportPrefix}_thread.csv</stringProp> | |
<longProp name="interval_grouping">1000</longProp> | |
<boolProp name="graph_aggregated">false</boolProp> | |
<stringProp name="include_sample_labels"></stringProp> | |
<stringProp name="exclude_sample_labels"></stringProp> | |
<stringProp name="start_offset"></stringProp> | |
<stringProp name="end_offset"></stringProp> | |
<boolProp name="include_checkbox_state">false</boolProp> | |
<boolProp name="exclude_checkbox_state">false</boolProp> | |
<collectionProp name="samplers"> | |
<collectionProp name="-1359385524"> | |
<stringProp name="-1790576086">Thread</stringProp> | |
<stringProp name="1793609999">${jmxUri}</stringProp> | |
<stringProp name="0"></stringProp> | |
<stringProp name="0"></stringProp> | |
<stringProp name="1641949653">java.lang:type=Threading</stringProp> | |
<stringProp name="-722063099">ThreadCount</stringProp> | |
<stringProp name="0"></stringProp> | |
<stringProp name="1237">false</stringProp> | |
<stringProp name="1237">false</stringProp> | |
</collectionProp> | |
</collectionProp> | |
</kg.apc.jmeter.jmxmon.JMXMonCollector> | |
<hashTree/> | |
<kg.apc.jmeter.jmxmon.JMXMonCollector guiclass="kg.apc.jmeter.vizualizers.JMXMonGui" testclass="kg.apc.jmeter.jmxmon.JMXMonCollector" testname="CPU" enabled="true"> | |
<boolProp name="ResultCollector.error_logging">false</boolProp> | |
<objProp> | |
<name>saveConfig</name> | |
<value class="SampleSaveConfiguration"> | |
<time>true</time> | |
<latency>true</latency> | |
<timestamp>true</timestamp> | |
<success>true</success> | |
<label>true</label> | |
<code>true</code> | |
<message>true</message> | |
<threadName>true</threadName> | |
<dataType>true</dataType> | |
<encoding>false</encoding> | |
<assertions>true</assertions> | |
<subresults>true</subresults> | |
<responseData>false</responseData> | |
<samplerData>false</samplerData> | |
<xml>false</xml> | |
<fieldNames>true</fieldNames> | |
<responseHeaders>false</responseHeaders> | |
<requestHeaders>false</requestHeaders> | |
<responseDataOnError>false</responseDataOnError> | |
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage> | |
<assertionsResultsToSave>0</assertionsResultsToSave> | |
<bytes>true</bytes> | |
<sentBytes>true</sentBytes> | |
<url>true</url> | |
<threadCounts>true</threadCounts> | |
<idleTime>true</idleTime> | |
<connectTime>true</connectTime> | |
</value> | |
</objProp> | |
<stringProp name="filename">${reportPrefix}_cpu.csv</stringProp> | |
<longProp name="interval_grouping">1000</longProp> | |
<boolProp name="graph_aggregated">false</boolProp> | |
<stringProp name="include_sample_labels"></stringProp> | |
<stringProp name="exclude_sample_labels"></stringProp> | |
<stringProp name="start_offset"></stringProp> | |
<stringProp name="end_offset"></stringProp> | |
<boolProp name="include_checkbox_state">false</boolProp> | |
<boolProp name="exclude_checkbox_state">false</boolProp> | |
<collectionProp name="samplers"> | |
<collectionProp name="905392073"> | |
<stringProp name="66952">CPU</stringProp> | |
<stringProp name="1793609999">${jmxUri}</stringProp> | |
<stringProp name="0"></stringProp> | |
<stringProp name="0"></stringProp> | |
<stringProp name="1418096973">java.lang:type=OperatingSystem</stringProp> | |
<stringProp name="-101473953">ProcessCpuLoad</stringProp> | |
<stringProp name="0"></stringProp> | |
<stringProp name="1237">false</stringProp> | |
<stringProp name="1237">false</stringProp> | |
</collectionProp> | |
</collectionProp> | |
</kg.apc.jmeter.jmxmon.JMXMonCollector> | |
<hashTree/> | |
<kg.apc.jmeter.jmxmon.JMXMonCollector guiclass="kg.apc.jmeter.vizualizers.JMXMonGui" testclass="kg.apc.jmeter.jmxmon.JMXMonCollector" testname="Classes" enabled="true"> | |
<boolProp name="ResultCollector.error_logging">false</boolProp> | |
<objProp> | |
<name>saveConfig</name> | |
<value class="SampleSaveConfiguration"> | |
<time>true</time> | |
<latency>true</latency> | |
<timestamp>true</timestamp> | |
<success>true</success> | |
<label>true</label> | |
<code>true</code> | |
<message>true</message> | |
<threadName>true</threadName> | |
<dataType>true</dataType> | |
<encoding>false</encoding> | |
<assertions>true</assertions> | |
<subresults>true</subresults> | |
<responseData>false</responseData> | |
<samplerData>false</samplerData> | |
<xml>false</xml> | |
<fieldNames>true</fieldNames> | |
<responseHeaders>false</responseHeaders> | |
<requestHeaders>false</requestHeaders> | |
<responseDataOnError>false</responseDataOnError> | |
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage> | |
<assertionsResultsToSave>0</assertionsResultsToSave> | |
<bytes>true</bytes> | |
<sentBytes>true</sentBytes> | |
<url>true</url> | |
<threadCounts>true</threadCounts> | |
<idleTime>true</idleTime> | |
<connectTime>true</connectTime> | |
</value> | |
</objProp> | |
<stringProp name="filename">${reportPrefix}_classes.csv</stringProp> | |
<longProp name="interval_grouping">1000</longProp> | |
<boolProp name="graph_aggregated">false</boolProp> | |
<stringProp name="include_sample_labels"></stringProp> | |
<stringProp name="exclude_sample_labels"></stringProp> | |
<stringProp name="start_offset"></stringProp> | |
<stringProp name="end_offset"></stringProp> | |
<boolProp name="include_checkbox_state">false</boolProp> | |
<boolProp name="exclude_checkbox_state">false</boolProp> | |
<collectionProp name="samplers"> | |
<collectionProp name="870620920"> | |
<stringProp name="-1776693242">Classes</stringProp> | |
<stringProp name="1793609999">${jmxUri}</stringProp> | |
<stringProp name="0"></stringProp> | |
<stringProp name="0"></stringProp> | |
<stringProp name="298852167">java.lang:type=ClassLoading</stringProp> | |
<stringProp name="1141682300">LoadedClassCount</stringProp> | |
<stringProp name="0"></stringProp> | |
<stringProp name="1237">false</stringProp> | |
<stringProp name="1237">false</stringProp> | |
</collectionProp> | |
</collectionProp> | |
</kg.apc.jmeter.jmxmon.JMXMonCollector> | |
<hashTree/> | |
<ResultCollector guiclass="SummaryReport" testclass="ResultCollector" testname="Summary Report" enabled="true"> | |
<boolProp name="ResultCollector.error_logging">false</boolProp> | |
<objProp> | |
<name>saveConfig</name> | |
<value class="SampleSaveConfiguration"> | |
<time>true</time> | |
<latency>true</latency> | |
<timestamp>true</timestamp> | |
<success>true</success> | |
<label>true</label> | |
<code>true</code> | |
<message>true</message> | |
<threadName>true</threadName> | |
<dataType>true</dataType> | |
<encoding>false</encoding> | |
<assertions>true</assertions> | |
<subresults>true</subresults> | |
<responseData>false</responseData> | |
<samplerData>false</samplerData> | |
<xml>false</xml> | |
<fieldNames>true</fieldNames> | |
<responseHeaders>false</responseHeaders> | |
<requestHeaders>false</requestHeaders> | |
<responseDataOnError>false</responseDataOnError> | |
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage> | |
<assertionsResultsToSave>0</assertionsResultsToSave> | |
<bytes>true</bytes> | |
<sentBytes>true</sentBytes> | |
<url>true</url> | |
<threadCounts>true</threadCounts> | |
<idleTime>true</idleTime> | |
<connectTime>true</connectTime> | |
</value> | |
</objProp> | |
<stringProp name="filename">${reportPrefix}_summary.csv</stringProp> | |
</ResultCollector> | |
<hashTree/> | |
<ResultCollector guiclass="TableVisualizer" testclass="ResultCollector" testname="View Results in Table" enabled="true"> | |
<boolProp name="ResultCollector.error_logging">false</boolProp> | |
<objProp> | |
<name>saveConfig</name> | |
<value class="SampleSaveConfiguration"> | |
<time>true</time> | |
<latency>true</latency> | |
<timestamp>true</timestamp> | |
<success>true</success> | |
<label>true</label> | |
<code>true</code> | |
<message>true</message> | |
<threadName>true</threadName> | |
<dataType>true</dataType> | |
<encoding>false</encoding> | |
<assertions>true</assertions> | |
<subresults>true</subresults> | |
<responseData>false</responseData> | |
<samplerData>false</samplerData> | |
<xml>false</xml> | |
<fieldNames>true</fieldNames> | |
<responseHeaders>false</responseHeaders> | |
<requestHeaders>false</requestHeaders> | |
<responseDataOnError>false</responseDataOnError> | |
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage> | |
<assertionsResultsToSave>0</assertionsResultsToSave> | |
<bytes>true</bytes> | |
<sentBytes>true</sentBytes> | |
<url>true</url> | |
<threadCounts>true</threadCounts> | |
<idleTime>true</idleTime> | |
<connectTime>true</connectTime> | |
</value> | |
</objProp> | |
<stringProp name="filename"></stringProp> | |
</ResultCollector> | |
<hashTree/> | |
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true"> | |
<boolProp name="ResultCollector.error_logging">false</boolProp> | |
<objProp> | |
<name>saveConfig</name> | |
<value class="SampleSaveConfiguration"> | |
<time>true</time> | |
<latency>true</latency> | |
<timestamp>true</timestamp> | |
<success>true</success> | |
<label>true</label> | |
<code>true</code> | |
<message>true</message> | |
<threadName>true</threadName> | |
<dataType>true</dataType> | |
<encoding>false</encoding> | |
<assertions>true</assertions> | |
<subresults>true</subresults> | |
<responseData>false</responseData> | |
<samplerData>false</samplerData> | |
<xml>false</xml> | |
<fieldNames>true</fieldNames> | |
<responseHeaders>false</responseHeaders> | |
<requestHeaders>false</requestHeaders> | |
<responseDataOnError>false</responseDataOnError> | |
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage> | |
<assertionsResultsToSave>0</assertionsResultsToSave> | |
<bytes>true</bytes> | |
<sentBytes>true</sentBytes> | |
<url>true</url> | |
<threadCounts>true</threadCounts> | |
<idleTime>true</idleTime> | |
<connectTime>true</connectTime> | |
</value> | |
</objProp> | |
<stringProp name="filename"></stringProp> | |
</ResultCollector> | |
<hashTree/> | |
<PostThreadGroup guiclass="PostThreadGroupGui" testclass="PostThreadGroup" testname="tearDown" enabled="true"> | |
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp> | |
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true"> | |
<boolProp name="LoopController.continue_forever">false</boolProp> | |
<stringProp name="LoopController.loops">1</stringProp> | |
</elementProp> | |
<stringProp name="ThreadGroup.num_threads">1</stringProp> | |
<stringProp name="ThreadGroup.ramp_time">1</stringProp> | |
<boolProp name="ThreadGroup.scheduler">false</boolProp> | |
<stringProp name="ThreadGroup.duration"></stringProp> | |
<stringProp name="ThreadGroup.delay"></stringProp> | |
</PostThreadGroup> | |
<hashTree> | |
<JSR223Sampler guiclass="TestBeanGUI" testclass="JSR223Sampler" testname="Report image generation" enabled="true"> | |
<stringProp name="scriptLanguage">groovy</stringProp> | |
<stringProp name="parameters">${reportPrefix}</stringProp> | |
<stringProp name="filename"></stringProp> | |
<stringProp name="cacheKey">true</stringProp> | |
<stringProp name="script"> | |
import java.io.File; | |
import java.util.List; | |
import java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.text.ParseException; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
import java.util.function.Consumer; | |
import org.jfree.chart.ChartFactory; | |
import org.jfree.chart.ChartUtils; | |
import org.jfree.chart.JFreeChart; | |
import org.jfree.chart.axis.DateAxis; | |
import org.jfree.chart.axis.NumberAxis; | |
import org.jfree.chart.plot.XYPlot; | |
import org.jfree.data.time.Millisecond; | |
import org.jfree.data.time.TimeSeries; | |
import org.jfree.data.time.TimeSeriesCollection; | |
import org.jfree.data.xy.XYDataset; | |
public class JMXMonChart { | |
public static JFreeChart createChart(XYDataset dataset, String seriesName, String yAxisLabel, double upperBound) { | |
JFreeChart chart = ChartFactory.createTimeSeriesChart( | |
seriesName, // title | |
"Time", // x-axis label | |
yAxisLabel, // y-axis label | |
dataset); | |
XYPlot plot = (XYPlot) chart.getPlot(); | |
if(upperBound > 0) { | |
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); | |
yAxis.setUpperBound(upperBound); | |
} | |
DateAxis axis = (DateAxis) plot.getDomainAxis(); | |
axis.setDateFormatOverride(new SimpleDateFormat("hh:mm:ss")); | |
return chart; | |
} | |
public static XYDataset createDataset(String seriesName, String path, double div) throws Exception { | |
TimeSeries s1 = new TimeSeries(seriesName); | |
List<String> lines = null; | |
System.out.print("Waiting for report for " + seriesName + "..."); | |
while(lines == null || lines.size() == 0){ | |
lines = Files.readAllLines(Paths.get(path)); | |
System.out.print("."); | |
Thread.sleep(1000); | |
} | |
System.out.println("...image generation started!"); | |
lines | |
.stream() | |
.skip(1) | |
.forEach(new Consumer<String>() { | |
@Override | |
public void accept(String line) { | |
String[] split = line.split(","); | |
Millisecond time = new Millisecond(new Date(Long.parseLong(split[0]))); | |
double value = Double.parseDouble(split[4]) / div; | |
s1.add(time, value); | |
} | |
}); | |
TimeSeriesCollection dataset = new TimeSeriesCollection(); | |
dataset.addSeries(s1); | |
return dataset; | |
} | |
public static void createChartImage(String seriesName, String yAxisLabel, String path, double div, double upperBound) throws Exception { | |
JFreeChart chart = createChart(createDataset(seriesName, path, div), seriesName, yAxisLabel, upperBound); | |
ChartUtils.saveChartAsPNG(new File(path.replace(".csv", ".png")), chart, 500, 270); | |
} | |
} | |
new Thread(new Runnable() { | |
@Override | |
public void run() { | |
JMXMonChart.createChartImage("Memory", "Used Heap", args[0] + "_memory.csv", 1_000_000, 0); | |
JMXMonChart.createChartImage("Thread", "Live threads", args[0] + "_thread.csv", 1, 0); | |
JMXMonChart.createChartImage("CPU", "CPU Usage", args[0] + "_cpu.csv", 1, 1); | |
JMXMonChart.createChartImage("Classes", "Loaded classes", args[0] + "_classes.csv", 1, 0); | |
} | |
}).start(); | |
</stringProp> | |
</JSR223Sampler> | |
<hashTree/> | |
</hashTree> | |
</hashTree> | |
</hashTree> | |
</jmeterTestPlan> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment