| 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 HitsPerSecondGui |
| 9 | |
extends AbstractOverTimeVisualizer { |
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
public HitsPerSecondGui() { |
| 15 | 8 | super(); |
| 16 | 8 | setGranulation(1000); |
| 17 | 8 | graphPanel.getGraphObject().setYAxisLabel("Number of hits /sec"); |
| 18 | 8 | } |
| 19 | |
|
| 20 | |
private void addHit(String threadGroupName, long time, int count) { |
| 21 | 1337 | AbstractGraphRow row = model.get(threadGroupName); |
| 22 | |
|
| 23 | 1337 | if (row == null) { |
| 24 | 3 | row = getNewRow(model, AbstractGraphRow.ROW_SUM_VALUES, threadGroupName, AbstractGraphRow.MARKER_SIZE_SMALL, false, false, false, true, true); |
| 25 | |
} |
| 26 | |
|
| 27 | |
|
| 28 | 1337 | if (getGranulation() > 0) { |
| 29 | 1337 | row.add(time, count * 1000.0d / getGranulation()); |
| 30 | |
} |
| 31 | 1337 | } |
| 32 | |
|
| 33 | |
@Override |
| 34 | |
public String getLabelResource() { |
| 35 | 1 | return this.getClass().getSimpleName(); |
| 36 | |
} |
| 37 | |
|
| 38 | |
@Override |
| 39 | |
public String getStaticLabel() { |
| 40 | 18 | return JMeterPluginsUtils.prefixLabel("Hits per Second"); |
| 41 | |
} |
| 42 | |
|
| 43 | |
private void addHits(SampleResult res) { |
| 44 | 1337 | SampleResult[] subResults = res.getSubResults(); |
| 45 | |
|
| 46 | 1337 | if (!isFromTransactionControler(res)) { |
| 47 | 1337 | addHit("Server Hits per Second", normalizeTime(res.getStartTime()), 1); |
| 48 | |
} |
| 49 | 1338 | for (int i = 0; i < subResults.length; i++) { |
| 50 | 1 | addHits(subResults[i]); |
| 51 | |
} |
| 52 | 1337 | } |
| 53 | |
|
| 54 | |
@Override |
| 55 | |
public void add(SampleResult res) { |
| 56 | 1336 | if (!isSampleIncluded(res)) { |
| 57 | 0 | return; |
| 58 | |
} |
| 59 | 1336 | super.add(res); |
| 60 | 1336 | addHits(res); |
| 61 | 1336 | updateGui(null); |
| 62 | 1336 | } |
| 63 | |
|
| 64 | |
@Override |
| 65 | |
protected JSettingsPanel createSettingsPanel() { |
| 66 | 10 | return new JSettingsPanel(this, |
| 67 | |
JSettingsPanel.TIMELINE_OPTION |
| 68 | |
| JSettingsPanel.GRADIENT_OPTION |
| 69 | |
| JSettingsPanel.FINAL_ZEROING_OPTION |
| 70 | |
| JSettingsPanel.LIMIT_POINT_OPTION |
| 71 | |
| JSettingsPanel.RELATIVE_TIME_OPTION |
| 72 | |
| JSettingsPanel.MAXY_OPTION |
| 73 | |
| JSettingsPanel.MARKERS_OPTION); |
| 74 | |
} |
| 75 | |
|
| 76 | |
@Override |
| 77 | |
public String getWikiPage() { |
| 78 | 9 | return "HitsPerSecond"; |
| 79 | |
} |
| 80 | |
} |