You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by mi...@apache.org on 2012/08/14 19:08:51 UTC
svn commit: r1372968 - in /jmeter/trunk/src:
components/org/apache/jmeter/visualizers/LGraphVisualizer.java
core/org/apache/jmeter/resources/messages.properties
core/org/apache/jmeter/resources/messages_fr.properties
Author: milamber
Date: Tue Aug 14 17:08:51 2012
New Revision: 1372968
URL: http://svn.apache.org/viewvc?rev=1372968&view=rev
Log:
Change the lock method
Add a warning to prohibit the update of interval si no file
Remove a double check on durationTest and improves the message
Bugzilla Id: 53718
Modified:
jmeter/trunk/src/components/org/apache/jmeter/visualizers/LGraphVisualizer.java
jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/LGraphVisualizer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/LGraphVisualizer.java?rev=1372968&r1=1372967&r2=1372968&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/LGraphVisualizer.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/LGraphVisualizer.java Tue Aug 14 17:08:51 2012
@@ -78,6 +78,11 @@ public class LGraphVisualizer extends Ab
private final Font FONT_SMALL = new Font("SansSerif", Font.PLAIN, 10);
private final Border MARGIN = new EmptyBorder(0, 5, 0, 5);
+
+ /**
+ * Lock used to protect list update
+ */
+ private final transient Object lock = new Object();
private final String yAxisLabel = JMeterUtils.getResString("aggregate_graph_response_time");//$NON-NLS-1$
@@ -180,7 +185,7 @@ public class LGraphVisualizer extends Ab
init();
}
- public synchronized void add(final SampleResult sampleResult) {
+ public void add(final SampleResult sampleResult) {
final String sampleLabel = sampleResult.getSampleLabel();
Matcher matcher = null;
// Sampler selection
@@ -194,33 +199,35 @@ public class LGraphVisualizer extends Ab
final int startTimeInterval = (int) startTimeMS / intervalValue;
JMeterUtils.runSafe(new Runnable() {
public void run() {
- // Use for x-axis scale
- if (startTimeInterval < minStartTime) {
- minStartTime = startTimeInterval;
- } else if (startTimeInterval > maxStartTime) {
- maxStartTime = startTimeInterval;
- }
- // Generate x-axis label and associated color
- if (!seriesNames.containsKey(sampleLabel)) {
- seriesNames.put(sampleLabel,
- new LGraphLineBean(sampleLabel, listColors.get(colorIdx++)));
- // reset colors index
- if (colorIdx >= listColors.size()) {
- colorIdx = 0;
+ synchronized (lock) {
+ // Use for x-axis scale
+ if (startTimeInterval < minStartTime) {
+ minStartTime = startTimeInterval;
+ } else if (startTimeInterval > maxStartTime) {
+ maxStartTime = startTimeInterval;
}
- }
- // List of value by sampler
- if (pList.containsKey(sampleLabel)) {
- LinkedHashMap<Integer, Long> subList = pList.get(sampleLabel);
- long respTime = sampleResult.getTime();
- if (subList.containsKey(startTimeInterval)) {
- respTime = (subList.get(startTimeInterval) + respTime) / 2;
+ // Generate x-axis label and associated color
+ if (!seriesNames.containsKey(sampleLabel)) {
+ seriesNames.put(sampleLabel,
+ new LGraphLineBean(sampleLabel, listColors.get(colorIdx++)));
+ // reset colors index
+ if (colorIdx >= listColors.size()) {
+ colorIdx = 0;
+ }
+ }
+ // List of value by sampler
+ if (pList.containsKey(sampleLabel)) {
+ LinkedHashMap<Integer, Long> subList = pList.get(sampleLabel);
+ long respTime = sampleResult.getTime();
+ if (subList.containsKey(startTimeInterval)) {
+ respTime = (subList.get(startTimeInterval) + respTime) / 2;
+ }
+ subList.put(startTimeInterval, respTime);
+ } else {
+ LinkedHashMap<Integer, Long> newSubList = new LinkedHashMap<Integer, Long>();
+ newSubList.put(startTimeInterval, sampleResult.getTime());
+ pList.put(sampleLabel, newSubList);
}
- subList.put(startTimeInterval, respTime);
- } else {
- LinkedHashMap<Integer, Long> newSubList = new LinkedHashMap<Integer, Long>();
- newSubList.put(startTimeInterval, sampleResult.getTime());
- pList.put(sampleLabel, newSubList);
}
}
});
@@ -228,15 +235,6 @@ public class LGraphVisualizer extends Ab
}
public void makeGraph() {
- // Calculate the test duration. Needs to xAxis Labels and getData.
- durationTest = maxStartTime - minStartTime;
- if (durationTest <= 0) {
- JOptionPane.showMessageDialog(null, JMeterUtils
- .getResString("aggregate_graph_no_values_to_graph"), // $NON-NLS-1$
- JMeterUtils.getResString("aggregate_graph_no_values_to_graph"), // $NON-NLS-1$
- JOptionPane.WARNING_MESSAGE);
- return;
- }
Dimension size = graphPanel.getSize();
// canvas size
int width = (int) size.getWidth();
@@ -338,13 +336,15 @@ public class LGraphVisualizer extends Ab
return "graph_line_title"; // $NON-NLS-1$
}
- public synchronized void clearData() {
- seriesNames.clear();
- pList.clear();
- minStartTime = Integer.MAX_VALUE;
- maxStartTime = Integer.MIN_VALUE;
- durationTest = 0;
- colorIdx = 0;
+ public void clearData() {
+ synchronized (lock) {
+ seriesNames.clear();
+ pList.clear();
+ minStartTime = Integer.MAX_VALUE;
+ maxStartTime = Integer.MIN_VALUE;
+ durationTest = 0;
+ colorIdx = 0;
+ }
}
/**
@@ -482,10 +482,13 @@ public class LGraphVisualizer extends Ab
regexpChkBox.setEnabled(false);
}
} else if (eventSource == reloadButton || eventSource == intervalButton) {
- if (eventSource == intervalButton) {
- intervalValue = Integer.parseInt(intervalField.getText());
- }
- if (getFile() != null && getFile().length() > 0) {
+ if (getFile() == null || getFile().length() <= 0) {
+ String msgErr = JMeterUtils.getResString("graph_line_only_with_read_results_file"); // $NON-NLS-1$
+ JOptionPane.showMessageDialog(null, msgErr, msgErr, JOptionPane.WARNING_MESSAGE);
+ } else {
+ if (eventSource == intervalButton) {
+ intervalValue = Integer.parseInt(intervalField.getText());
+ }
clearData();
FilePanel filePanel = (FilePanel) getFilePanel();
filePanel.actionPerformed(event);
@@ -500,8 +503,8 @@ public class LGraphVisualizer extends Ab
durationTest = maxStartTime - minStartTime;
if (seriesNames.size() <= 0) {
msgErr = JMeterUtils.getResString("aggregate_graph_no_values_to_graph"); // $NON-NLS-1$
- } else if (durationTest <= 1) {
- msgErr = JMeterUtils.getResString("graph_line_no_duration"); // $NON-NLS-1$
+ } else if (durationTest < 1) {
+ msgErr = JMeterUtils.getResString("graph_line_not_enough_data"); // $NON-NLS-1$
}
if (msgErr == null) {
makeGraph();
Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1372968&r1=1372967&r2=1372968&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Tue Aug 14 17:08:51 2012
@@ -320,7 +320,8 @@ graph_choose_graphs=Graphs to Display
graph_full_results_title=Graph Full Results
graph_line_interval_label=Interval (ms):
graph_line_interval_reload=Apply interval
-graph_line_no_duration=Test with no duration. Unable to graph.
+graph_line_not_enough_data=Unable to graph, not enough data
+graph_line_only_with_read_results_file=Possible only with a read results file
graph_line_series_selection=Sampler label selection:
graph_line_settings_line=Line settings
graph_line_settings_pane=Graph settings
Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties?rev=1372968&r1=1372967&r2=1372968&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties Tue Aug 14 17:08:51 2012
@@ -314,7 +314,8 @@ graph_choose_graphs=Graphique \u00E0 aff
graph_full_results_title=Graphique de r\u00E9sultats complets
graph_line_interval_label=Interval (ms) \:
graph_line_interval_reload=Appliquer l'interval
-graph_line_no_duration=Test sans dur\u00E9e. Impossible de dessiner le graphique.
+graph_line_not_enough_data=Impossible de dessiner le graphique, pas assez de donn\u00E9es
+graph_line_only_with_read_results_file=Possible seulement quand c'est un fichier de r\u00E9sultats qui est lu.
graph_line_series_selection=S\u00E9lection des \u00E9chantillons par libell\u00E9 \:
graph_line_settings_line=Param\u00E9tres de la courbe
graph_line_settings_pane=Param\u00E9tres du graphique