Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improve Response Time Graph Y axis scale with huge values or small va…

…lues (< 1000ms). Add a new field to define increment scale

Bugzilla Id: 54532

git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1444399 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit eb22e8412a993a41f14f54e26b81a0ff9bcc4a49 1 parent c07fb45
@milamberspace milamberspace authored
View
BIN  docs/images/screenshots/response_time_graph.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  docs/images/screenshots/response_time_graph_settings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
44 src/components/org/apache/jmeter/visualizers/RespTimeGraphChart.java
@@ -74,6 +74,8 @@
protected int height;
+ protected int incrYAxisScale;
+
protected String[] legendLabels = { JMeterUtils.getResString("aggregate_graph_legend") }; // $NON-NLS-1$
protected int maxYAxisScale;
@@ -151,6 +153,13 @@ public void setHeight(int h) {
}
/**
+ * @param incrYAxisScale the incrYAxisScale to set
+ */
+ public void setIncrYAxisScale(int incrYAxisScale) {
+ this.incrYAxisScale = incrYAxisScale;
+ }
+
+ /**
* @return the maxYAxisScale
*/
public int getMaxYAxisScale() {
@@ -264,10 +273,10 @@ public void setShowGrouping(boolean showGrouping) {
private void drawSample(String _title, String[] _xAxisLabels,
String _yAxisTitle, String[] _legendLabels,
- double[][] _data, int _width, int _height,
+ double[][] _data, int _width, int _height, int _incrScaleYAxis,
Color[] _color, Font legendFont, Graphics g) {
- double max = maxYAxisScale > 0 ? maxYAxisScale : findMax(_data); // define max scale y axis
+ double max = maxYAxisScale > 0 ? maxYAxisScale : getTopValue(findMax(_data), BigDecimal.ROUND_UP); // define max scale y axis
try {
// if the title graph is empty, we can assume some default
if (_title.length() == 0 ) {
@@ -313,11 +322,17 @@ private void drawSample(String _title, String[] _xAxisLabels,
// Y Axis ruler
try {
- BigDecimal round = new BigDecimal(max / 1000d);
- round = round.setScale(0, BigDecimal.ROUND_UP);
- double topValue = round.doubleValue() * 1000;
- yaxis.setUserDefinedScale(0, 500);
- yaxis.setNumItems((int) (topValue / 500)+1);
+ double numInterval = _height / 50; // ~a tic every 50 px
+ double incrYAxis = new Double(max / numInterval);
+ double incrTopValue = _incrScaleYAxis;
+ if (_incrScaleYAxis == 0) {
+ incrTopValue = getTopValue(incrYAxis, BigDecimal.ROUND_HALF_UP);
+ }
+ if (incrTopValue < 1) {
+ incrTopValue = 1.0d; // Increment cannot be < 1
+ }
+ yaxis.setUserDefinedScale(0, incrTopValue);
+ yaxis.setNumItems(new Double(max / incrTopValue).intValue() + 1);
yaxis.setShowGridLines(1);
} catch (PropertyException e) {
log.warn("",e);
@@ -350,13 +365,26 @@ private void drawSample(String _title, String[] _xAxisLabels,
}
}
+ private int getTopValue(double value, int roundMode) {
+ String maxStr = String.valueOf(Math.round(value));
+ String divValueStr = "1"; //$NON-NLS-1$
+ for (int i = 1; i < maxStr.length(); i++) {
+ divValueStr += "0"; //$NON-NLS-1$
+ }
+ int divValueInt = Integer.parseInt(divValueStr);
+ BigDecimal round = new BigDecimal(value / divValueInt);
+ round = round.setScale(0, roundMode);
+ int topValue = round.intValue() * divValueInt;
+ return topValue;
+ }
+
@Override
public void paintComponent(Graphics graphics) {
if (data != null && this.title != null && this.xAxisLabels != null &&
this.yAxisLabel != null && this.yAxisTitle != null) {
drawSample(this.title, this.xAxisLabels,
this.yAxisTitle, this.legendLabels,
- this.data, this.width, this.height, this.color,
+ this.data, this.width, this.height, this.incrYAxisScale, this.color,
this.legendFont, graphics);
}
}
View
17 src/components/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java
@@ -158,7 +158,7 @@
new JLabeledTextField(JMeterUtils.getResString("graph_resp_time_xaxis_time_format"), 10); //$NON-NLS-1$ $NON-NLS-2$
private final JLabeledTextField maxValueYAxisLabel =
- new JLabeledTextField(JMeterUtils.getResString("aggregate_graph_yaxis_max_value"), 8); //$NON-NLS-1$
+ new JLabeledTextField(JMeterUtils.getResString("aggregate_graph_yaxis_max_value"), 5); //$NON-NLS-1$
/**
* checkbox for use dynamic graph size
@@ -170,6 +170,9 @@
private final JLabeledTextField graphHeight =
new JLabeledTextField(JMeterUtils.getResString("aggregate_graph_height"), 6); //$NON-NLS-1$
+ private final JLabeledTextField incrScaleYAxis =
+ new JLabeledTextField(JMeterUtils.getResString("aggregate_graph_increment_scale"), 5); //$NON-NLS-1$
+
private long minStartTime = Long.MAX_VALUE;
private long maxStartTime = Long.MIN_VALUE;
@@ -302,6 +305,7 @@ public void makeGraph() {
graphPanel.setHeight(height);
graphPanel.setWidth(width);
+ graphPanel.setIncrYAxisScale(getIncrScaleYAxis());
// Draw the graph
graphPanel.repaint();
}
@@ -575,6 +579,15 @@ private JPanel createGraphActionsPane() {
return linesColors;
}
+ private int getIncrScaleYAxis() {
+ int incrYAxisScale = 0;
+ String iyas = incrScaleYAxis.getText();
+ if (iyas.length() != 0) {
+ incrYAxisScale = Integer.parseInt(iyas);
+ }
+ return incrYAxisScale;
+ }
+
private JPanel createGraphSettingsPane() {
JPanel settingsPane = new JPanel(new BorderLayout());
settingsPane.setBorder(BorderFactory.createTitledBorder(
@@ -713,7 +726,7 @@ private JPanel createGraphYAxisPane() {
BorderFactory.createEtchedBorder(),
JMeterUtils.getResString("aggregate_graph_yaxis_group"))); // $NON-NLS-1$
yAxisPane.add(maxValueYAxisLabel);
-
+ yAxisPane.add(incrScaleYAxis);
yAxisPane.add(numberShowGrouping);
return yAxisPane;
}
View
3  src/core/org/apache/jmeter/resources/messages.properties
@@ -46,6 +46,7 @@ aggregate_graph_draw_outlines=Draw outlines bar?
aggregate_graph_dynamic_size=Dynamic graph size
aggregate_graph_font=Font\:
aggregate_graph_height=Height\:
+aggregate_graph_increment_scale=Increment scale\:
aggregate_graph_legend=Legend
aggregate_graph_legend.placement.bottom=Bottom
aggregate_graph_legend.placement.left=Left
@@ -73,7 +74,7 @@ aggregate_graph_value_font=Value font\:
aggregate_graph_value_labels_vertical=Value labels vertical?
aggregate_graph_width=Width\:
aggregate_graph_xaxis_group=X Axis
-aggregate_graph_yaxis_group=Y Axis
+aggregate_graph_yaxis_group=Y Axis (milli-seconds)
aggregate_graph_yaxis_max_value=Scale maximum value\:
aggregate_report=Aggregate Report
aggregate_report_90=90%
View
3  src/core/org/apache/jmeter/resources/messages_fr.properties
@@ -40,6 +40,7 @@ aggregate_graph_draw_outlines=Bordure de barre ?
aggregate_graph_dynamic_size=Taille de graphique dynamique
aggregate_graph_font=Police \:
aggregate_graph_height=Hauteur \:
+aggregate_graph_increment_scale=Intervalle \u00E9chelle \:
aggregate_graph_legend=L\u00E9gende
aggregate_graph_legend.placement.bottom=Bas
aggregate_graph_legend.placement.left=Gauche
@@ -67,7 +68,7 @@ aggregate_graph_value_font=Police de la valeur \:
aggregate_graph_value_labels_vertical=Libell\u00E9 de valeurs vertical ?
aggregate_graph_width=Largeur \:
aggregate_graph_xaxis_group=Abscisses
-aggregate_graph_yaxis_group=Ordonn\u00E9es
+aggregate_graph_yaxis_group=Ordonn\u00E9es (milli-secondes)
aggregate_graph_yaxis_max_value=Echelle maximum \:
aggregate_report=Rapport agr\u00E9g\u00E9
aggregate_report_90=90%
View
1  xdocs/changes.xml
@@ -143,6 +143,7 @@ This does not affect JMeter operation.
<h3>Listeners</h3>
<ul>
+<li><bugzilla>54532</bugzilla> - Improve Response Time Graph Y axis scale with huge values or small values (&lt; 1000ms). Add a new field to define increment scale</li>
</ul>
<h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>
View
BIN  xdocs/images/screenshots/response_time_graph.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  xdocs/images/screenshots/response_time_graph_settings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
6 xdocs/usermanual/component_reference.xml
@@ -2909,7 +2909,7 @@ the graph as a PNG file.</description>
</properties>
</component>
-<component name="Response Time Graph" index="&sect-num;.3.13" width="869" height="620" screenshot="response_time_graph.png">
+<component name="Response Time Graph" index="&sect-num;.3.13" width="921" height="616" screenshot="response_time_graph.png">
<description>
The Response Time Graph draws a line chart showing the evolution of response time during the test, for each labelled request.
If many samples exist for the same timestamp, the mean value is displayed.
@@ -2917,7 +2917,7 @@ If many samples exist for the same timestamp, the mean value is displayed.
<div align="center">
<p>
The figure below shows an example of settings to draw this graph.
-<figure width="871" height="489" image="response_time_graph_settings.png">Response time graph settings</figure>
+<figure width="919" height="481" image="response_time_graph_settings.png">Response time graph settings</figure>
</p>
</div>
<p><i>Please note: All this parameters <b>aren't</b> saved in JMeter jmx script.</i></p>
@@ -2933,7 +2933,7 @@ If many samples exist for the same timestamp, the mean value is displayed.
Use Width and Height fields to define a custom size. The unit is pixel. </property>
<property name="X Axis settings" required="No">Customize the date format of X axis label.
The syntax is the Java <a href="http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat API</a>.</property>
- <property name="Y Axis settings" required="No">Define a custom maximum value for Y Axis. Show or not the number grouping in Y Axis labels.</property>
+ <property name="Y Axis settings" required="No">Define a custom maximum value for Y Axis in milli-seconds. Define the increment for the scale (in ms) Show or not the number grouping in Y Axis labels.</property>
<property name="Legend" required="Yes">Define the placement and font settings for chart legend</property>
</properties>
</component>
Please sign in to comment.
Something went wrong with that request. Please try again.