| 1 | |
package kg.apc.jmeter.vizualizers; |
| 2 | |
|
| 3 | |
import kg.apc.charting.AbstractGraphRow; |
| 4 | |
import kg.apc.jmeter.JMeterPluginsUtils; |
| 5 | |
import kg.apc.jmeter.graphs.AbstractOverTimeVisualizer; |
| 6 | |
import org.apache.jmeter.samplers.SampleResult; |
| 7 | |
|
| 8 | |
public class BytesThroughputOverTimeGui |
| 9 | |
extends AbstractOverTimeVisualizer { |
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
public BytesThroughputOverTimeGui() { |
| 16 | 6 | super(); |
| 17 | 6 | setGranulation(1000); |
| 18 | 6 | graphPanel.getGraphObject().setYAxisLabel("Bytes /sec"); |
| 19 | 6 | } |
| 20 | |
|
| 21 | |
private void addBytes(String threadGroupName, long time, int value) { |
| 22 | 4 | AbstractGraphRow row = model.get(threadGroupName); |
| 23 | |
|
| 24 | 4 | if (row == null) { |
| 25 | 2 | row = getNewRow(model, AbstractGraphRow.ROW_SUM_VALUES, threadGroupName, AbstractGraphRow.MARKER_SIZE_SMALL, false, false, false, true, true); |
| 26 | |
} |
| 27 | |
|
| 28 | |
|
| 29 | 4 | if (getGranulation() > 0) { |
| 30 | 4 | row.add(time, value * 1000.0d / getGranulation()); |
| 31 | |
} |
| 32 | 4 | } |
| 33 | |
|
| 34 | |
public String getLabelResource() { |
| 35 | 1 | return this.getClass().getSimpleName(); |
| 36 | |
} |
| 37 | |
|
| 38 | |
@Override |
| 39 | |
public String getStaticLabel() { |
| 40 | 13 | return JMeterPluginsUtils.prefixLabel("Bytes Throughput Over Time"); |
| 41 | |
} |
| 42 | |
|
| 43 | |
@Override |
| 44 | |
public void add(SampleResult res) { |
| 45 | 2 | if (!isSampleIncluded(res)) { |
| 46 | 0 | return; |
| 47 | |
} |
| 48 | 2 | super.add(res); |
| 49 | 2 | addBytes("Bytes Received per Second", normalizeTime(res.getEndTime()), res.getBytes()); |
| 50 | 2 | int sentBytes = 0; |
| 51 | 2 | String samplerData = res.getSamplerData(); |
| 52 | 2 | if (samplerData != null) { |
| 53 | 0 | sentBytes = samplerData.length(); |
| 54 | |
} |
| 55 | 2 | addBytes("Bytes Sent per Second", normalizeTime(res.getEndTime()), sentBytes); |
| 56 | 2 | updateGui(null); |
| 57 | 2 | } |
| 58 | |
|
| 59 | |
@Override |
| 60 | |
protected JSettingsPanel createSettingsPanel() { |
| 61 | 8 | return new JSettingsPanel(this, |
| 62 | |
JSettingsPanel.TIMELINE_OPTION |
| 63 | |
| JSettingsPanel.GRADIENT_OPTION |
| 64 | |
| JSettingsPanel.FINAL_ZEROING_OPTION |
| 65 | |
| JSettingsPanel.LIMIT_POINT_OPTION |
| 66 | |
| JSettingsPanel.MAXY_OPTION |
| 67 | |
| JSettingsPanel.RELATIVE_TIME_OPTION |
| 68 | |
| JSettingsPanel.MARKERS_OPTION); |
| 69 | |
} |
| 70 | |
|
| 71 | |
@Override |
| 72 | |
public String getWikiPage() { |
| 73 | 7 | return "BytesThroughput"; |
| 74 | |
} |
| 75 | |
} |