Skip to content

Commit 8fb01f0

Browse files
authored
Merge branch 'undera:master' into master
2 parents 4143bef + 1cdffbe commit 8fb01f0

75 files changed

Lines changed: 1657 additions & 387 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pr.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
1818

1919
- name: Setup PHP Action
2020
uses: shivammathur/setup-php@2.24.0
@@ -25,18 +25,18 @@ jobs:
2525
- name: Prepare upload
2626
run: ./prepare-upload.sh
2727

28-
- uses: actions/setup-java@v3
28+
- uses: actions/setup-java@v4
2929
with:
3030
distribution: temurin
31-
java-version: '8'
31+
java-version: '11'
3232
cache: maven
3333

3434
- name: Maven tests
3535
run: mvn -T 1C -Djava.awt.headless=true -Dmaven.test.redirectTestOutputToFile=true --fail-at-end --batch-mode org.jacoco:jacoco-maven-plugin:prepare-agent test org.jacoco:jacoco-maven-plugin:report install
3636
# working-directory: ./plugins/dummy
3737

3838
- name: Codecov
39-
uses: codecov/codecov-action@v3.1.1
39+
uses: codecov/codecov-action@v5
4040

4141
- name: Perform upload
4242
run: 'curl --fail -vk https://jmeter-plugins.org/unzip.php -F "zipfile=@upload/site.zip" -H "Authorization: Bearer ${{ secrets.UPLOAD_TOKEN }}"'

graphs/graphs-additional/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333

3434
<properties>
3535
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36-
<maven.compiler.source>1.7</maven.compiler.source>
37-
<maven.compiler.target>1.7</maven.compiler.target>
36+
<maven.compiler.source>1.8</maven.compiler.source>
37+
<maven.compiler.target>1.8</maven.compiler.target>
3838
</properties>
3939
<dependencies>
4040
<dependency>

graphs/graphs-basic/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333

3434
<properties>
3535
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36-
<maven.compiler.source>1.7</maven.compiler.source>
37-
<maven.compiler.target>1.7</maven.compiler.target>
36+
<maven.compiler.source>1.8</maven.compiler.source>
37+
<maven.compiler.target>1.8</maven.compiler.target>
3838
</properties>
3939
<dependencies>
4040
<dependency>

graphs/graphs-composite/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333

3434
<properties>
3535
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36-
<maven.compiler.source>1.7</maven.compiler.source>
37-
<maven.compiler.target>1.7</maven.compiler.target>
36+
<maven.compiler.source>1.8</maven.compiler.source>
37+
<maven.compiler.target>1.8</maven.compiler.target>
3838
</properties>
3939
<dependencies>
4040
<dependency>

graphs/graphs-dist/pom.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>kg.apc</groupId>
88
<artifactId>jmeter-plugins-graphs-dist</artifactId>
9-
<version>2.0</version>
9+
<version>2.1</version>
1010

1111
<name>Distribution Graphs Plugins</name>
1212
<description>Distribution Graphs Plugins</description>
@@ -33,19 +33,24 @@
3333

3434
<properties>
3535
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36-
<maven.compiler.source>1.7</maven.compiler.source>
37-
<maven.compiler.target>1.7</maven.compiler.target>
36+
<maven.compiler.source>1.8</maven.compiler.source>
37+
<maven.compiler.target>1.8</maven.compiler.target>
3838
</properties>
3939
<dependencies>
4040
<dependency>
4141
<groupId>kg.apc</groupId>
4242
<artifactId>jmeter-plugins-cmn-jmeter</artifactId>
43-
<version>0.3</version>
43+
<version>0.9</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.apache.commons</groupId>
47+
<artifactId>commons-math3</artifactId>
48+
<version>3.6.1</version>
4449
</dependency>
4550
<dependency>
4651
<groupId>kg.apc</groupId>
4752
<artifactId>jmeter-plugins-emulators</artifactId>
48-
<version>0.2</version>
53+
<version>0.4</version>
4954
<scope>test</scope>
5055
</dependency>
5156
</dependencies>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package kg.apc.charting.elements;
2+
3+
import kg.apc.charting.AbstractGraphPanelChartElement;
4+
import org.apache.commons.math3.stat.descriptive.rank.PSquarePercentile;
5+
6+
public class GraphPanelChartPercentileElement extends AbstractGraphPanelChartElement {
7+
private final PSquarePercentile percentile;
8+
9+
public GraphPanelChartPercentileElement(double percentile) {
10+
this.percentile = new PSquarePercentile(percentile);
11+
}
12+
13+
@Override
14+
public double getValue() {
15+
synchronized (this) {
16+
return percentile.getResult();
17+
}
18+
}
19+
20+
@Override
21+
public void add(double val) {
22+
synchronized (this) {
23+
percentile.increment(val);
24+
}
25+
}
26+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package kg.apc.charting.rows;
2+
3+
import kg.apc.charting.AbstractGraphPanelChartElement;
4+
import kg.apc.charting.AbstractGraphRow;
5+
import kg.apc.charting.elements.GraphPanelChartPercentileElement;
6+
7+
import java.util.Iterator;
8+
import java.util.Map;
9+
import java.util.concurrent.ConcurrentSkipListMap;
10+
11+
public class GraphRowOverTimePercentile extends AbstractGraphRow {
12+
private final ConcurrentSkipListMap<Long, AbstractGraphPanelChartElement> values; // key is sample time interval
13+
private final double percentile;
14+
15+
public GraphRowOverTimePercentile(double percentile) {
16+
super();
17+
values = new ConcurrentSkipListMap<>();
18+
this.percentile = percentile;
19+
}
20+
21+
@Override
22+
public void add(long xVal, double yVal) {
23+
GraphPanelChartPercentileElement el = (GraphPanelChartPercentileElement) values.get(xVal);
24+
if (el == null) {
25+
el = new GraphPanelChartPercentileElement(percentile);
26+
values.put(xVal, el);
27+
}
28+
el.add(yVal);
29+
yVal = el.getValue();
30+
super.add(xVal, yVal);
31+
}
32+
33+
@Override
34+
public Iterator<Map.Entry<Long, AbstractGraphPanelChartElement>> iterator() {
35+
return values.entrySet().iterator();
36+
}
37+
38+
@Override
39+
public int size() {
40+
return values.size();
41+
}
42+
43+
@Override
44+
public AbstractGraphPanelChartElement getElement(long value) {
45+
return values.get(value);
46+
}
47+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package kg.apc.jmeter.vizualizers;
2+
3+
import kg.apc.charting.AbstractGraphRow;
4+
import kg.apc.charting.rows.GraphRowOverTimePercentile;
5+
import kg.apc.jmeter.JMeterPluginsUtils;
6+
import kg.apc.jmeter.graphs.AbstractOverTimeVisualizer;
7+
import org.apache.jmeter.samplers.SampleResult;
8+
import org.apache.jmeter.util.JMeterUtils;
9+
import org.slf4j.Logger;
10+
import org.slf4j.LoggerFactory;
11+
12+
import java.awt.*;
13+
import java.text.DecimalFormat;
14+
import java.util.*;
15+
import java.util.List;
16+
import java.util.stream.Collectors;
17+
18+
public class ResponseTimesPercentilesOverTimeGui extends AbstractOverTimeVisualizer {
19+
20+
private static final Logger log = LoggerFactory.getLogger(ResponseTimesPercentilesOverTimeGui.class);
21+
protected List<Double> percentiles;
22+
protected Map<Double, Double> shadingFactors; // render each percentile with a lighter alpha value
23+
protected Map<String, Color> baseColors;
24+
25+
public ResponseTimesPercentilesOverTimeGui() {
26+
super();
27+
setGranulation(30000);
28+
getGraphPanelChart().getChartSettings().setLineWidth(3);
29+
getGraphPanelChart().setYAxisLabel("Response times in ms");
30+
31+
String percentilesConfig = JMeterUtils.getPropDefault("jmeterPlugin.percentilesOverTime", "50,90,95,99");
32+
try {
33+
percentiles = Arrays.stream(percentilesConfig.split(","))
34+
.map(Double::valueOf)
35+
.collect(Collectors.toList());
36+
} catch (NumberFormatException e) {
37+
log.error("Invalid percentiles configuration", e);
38+
percentiles = Collections.singletonList(50d);
39+
}
40+
shadingFactors = new HashMap<>();
41+
for (int i = 0; i < percentiles.size(); i++) {
42+
// color shades should not get lighter than an alpha value of 32 out of 255
43+
shadingFactors.put(percentiles.get(i), percentiles.size()>1 ? Math.pow(32d/256d, (double)i/(percentiles.size()-1)) : 1);
44+
}
45+
baseColors = new HashMap<>();
46+
}
47+
48+
public String getLabelResource() {
49+
return this.getClass().getSimpleName();
50+
}
51+
52+
@Override
53+
public String getStaticLabel() {
54+
return JMeterPluginsUtils.prefixLabel("Response Times Percentiles Over Time");
55+
}
56+
57+
protected synchronized AbstractGraphRow getNewRow(String label, boolean isAggregate, double percentile) {
58+
final AbstractGraphRow newRow = new GraphRowOverTimePercentile(percentile);
59+
final String suffix = new DecimalFormat(" (p#.####)").format(percentile);
60+
newRow.setLabel(label+suffix);
61+
newRow.setMarkerSize(AbstractGraphRow.MARKER_SIZE_NONE);
62+
newRow.setDrawBar(false);
63+
newRow.setDrawLine(true);
64+
newRow.setDrawValueLabel(false);
65+
newRow.setDrawThickLines(false);
66+
newRow.setShowInLegend(true);
67+
68+
// Avoid cycling of colors for subsequent percentiles: Let base class assign color only once, then store it.
69+
Color color = baseColors.get(label);
70+
if (color != null) {
71+
color = new Color(color.getRed(), color.getGreen(), color.getBlue(),
72+
(int)(color.getAlpha() * shadingFactors.get(percentile)));
73+
}
74+
AbstractGraphRow addedRow = getNewRow(newRow, color, isAggregate, true);
75+
if (color == null) {
76+
baseColors.put(label, addedRow.getColor());
77+
}
78+
return addedRow;
79+
}
80+
81+
@Override
82+
public void add(SampleResult res) {
83+
if (!isSampleIncluded(res)) {
84+
return;
85+
}
86+
super.add(res);
87+
88+
final String labelAgg = "Overall Response Times";
89+
String label = res.getSampleLabel();
90+
long time = normalizeTime(res.getEndTime());
91+
long elapsed = res.getTime();
92+
93+
for (double p : percentiles) {
94+
getNewRow(label, false, p).add(time, elapsed);
95+
getNewRow(labelAgg, true, p).add(time, elapsed);
96+
}
97+
98+
updateGui(null);
99+
}
100+
101+
@Override
102+
protected JSettingsPanel createSettingsPanel() {
103+
return new JSettingsPanel(this,
104+
JSettingsPanel.TIMELINE_OPTION
105+
| JSettingsPanel.GRADIENT_OPTION
106+
| JSettingsPanel.LIMIT_POINT_OPTION
107+
| JSettingsPanel.AGGREGATE_OPTION
108+
| JSettingsPanel.MAXY_OPTION
109+
| JSettingsPanel.RELATIVE_TIME_OPTION
110+
| JSettingsPanel.MARKERS_OPTION);
111+
}
112+
113+
@Override
114+
public String getWikiPage() {
115+
return "ResponseTimesPercentilesOverTime";
116+
}
117+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package kg.apc.charting.elements;
2+
3+
import org.junit.Test;
4+
5+
import static org.junit.Assert.assertEquals;
6+
7+
public class GraphPanelChartPercentileElementTest {
8+
9+
/**
10+
*
11+
*/
12+
@Test
13+
public void testAdd() {
14+
System.out.println("add");
15+
GraphPanelChartPercentileElement instance = new GraphPanelChartPercentileElement(50);
16+
instance.add(0);
17+
}
18+
19+
/**
20+
*
21+
*/
22+
@Test
23+
public void testGetValue() {
24+
System.out.println("getValue");
25+
GraphPanelChartPercentileElement instance = new GraphPanelChartPercentileElement(50);
26+
instance.add(1);
27+
instance.add(2);
28+
instance.add(3);
29+
double result = instance.getValue();
30+
assertEquals(2, result, 0.0);
31+
}
32+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package kg.apc.charting.rows;
2+
3+
import kg.apc.charting.AbstractGraphPanelChartElement;
4+
import kg.apc.charting.elements.GraphPanelChartPercentileElement;
5+
import org.junit.Before;
6+
import org.junit.Test;
7+
8+
import static org.junit.Assert.*;
9+
10+
public class GraphRowOverTimePercentileTest {
11+
12+
private GraphRowOverTimePercentile instance;
13+
14+
/**
15+
*
16+
*/
17+
@Before
18+
public void setUp() {
19+
instance = new GraphRowOverTimePercentile(50);
20+
}
21+
22+
/**
23+
*
24+
*/
25+
@Test
26+
public void testAdd() {
27+
System.out.println("add");
28+
instance.add(1, 1);
29+
assertEquals(1, instance.size());
30+
}
31+
32+
/**
33+
*
34+
*/
35+
@Test
36+
public void testIterator() {
37+
System.out.println("iterator");
38+
assertNotNull(instance.iterator());
39+
assertFalse(instance.iterator().hasNext());
40+
instance.add(0, 0);
41+
assertTrue(instance.iterator().hasNext());
42+
}
43+
44+
/**
45+
*
46+
*/
47+
@Test
48+
public void testSize() {
49+
System.out.println("size");
50+
instance.add(1, 1);
51+
instance.add(1, 1);
52+
instance.add(2, 1);
53+
54+
assertEquals(2, instance.size());
55+
}
56+
57+
/**
58+
*
59+
*/
60+
@Test
61+
public void testGetElement() {
62+
System.out.println("getElement");
63+
long xValue = 100L; double yValue = 10d;
64+
AbstractGraphPanelChartElement expResult = new GraphPanelChartPercentileElement(50);
65+
expResult.add(yValue);
66+
instance.add(xValue, yValue);
67+
AbstractGraphPanelChartElement result = instance.getElement(xValue);
68+
assertEquals(expResult.getValue(), result.getValue(), 0.0);
69+
}
70+
71+
}

0 commit comments

Comments
 (0)