Skip to content

Commit e96e639

Browse files
author
binbin.hou
committed
release branch 2.0.5
1 parent 09f0690 commit e96e639

17 files changed

+162
-45
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,9 @@ add junit test
6565
|:---|:---|:---|:---|:--|:---|
6666
| 1 | U | 移除对于 log-integration 的依赖 | | 2020-6-15 20:10:40 | |
6767
| 2 | O | 文档优化 | | 2020-6-15 20:10:40 | |
68+
69+
# release_2.0.5
70+
71+
| 序号 | 变更类型 | 具体 | 说明 | 时间 | 备注 |
72+
|:---|:---|:---|:---|:--|:---|
73+
| 1 | F | 新增内存消耗特性 | | 2020-6-16 13:53:54 | |

README-EN.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@
2929

3030
[CHANGELOG](CHANGELOG.md)
3131

32-
### v2.0.4 major change
32+
### v2.0.5 major change
3333

34-
1. remove log-integration dependency
35-
36-
2. doc optimize
34+
1. new feature for memory cost
3735

3836
# Quick Start
3937

@@ -49,7 +47,7 @@
4947
<dependency>
5048
<groupId>com.github.houbb</groupId>
5149
<artifactId>junitperf</artifactId>
52-
<version>2.0.4</version>
50+
<version>2.0.5</version>
5351
</dependency>
5452
```
5553

@@ -84,7 +82,7 @@ config for test
8482
| threads | How many threads are used to execute | int | 1 | |
8583
| warmUp | Preparation time | long | 0 | Unit:mills |
8684
| duration | Execution time | long | 60_000(1 min) | Unit:mills |
87-
| statistics | Statistics impl | StatisticsCalculator | DefaultStatisticsCalculator | |
85+
| latencyStatistics | Statistics impl | StatisticsCalculator | DefaultStatisticsCalculator | |
8886
| reporter | Reporter impl | Reporter | ConsoleReporter | |
8987

9088
as following:
@@ -109,7 +107,7 @@ public class JunitPerfConfigTest {
109107

110108
### Reporter types
111109

112-
This is mainly the **output method** for performance test statistics.
110+
This is mainly the **output method** for performance test latencyStatistics.
113111

114112
The following methods are supported:
115113

@@ -190,4 +188,4 @@ Later, style adjustments will be made.
190188

191189
# Road-MAP
192190

193-
- [ ] Memory usage statistics
191+
- [ ] Memory usage latencyStatistics

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@
2929

3030
[变更日志](CHANGELOG.md)
3131

32-
### v2.0.4 主要变更
32+
### v2.0.5 主要变更
3333

34-
1. 移除对于 log-integration 的依赖
35-
36-
2. 文档优化
34+
1. 新增内存消耗特性
3735

3836
# 快速开始
3937

@@ -49,7 +47,7 @@
4947
<dependency>
5048
<groupId>com.github.houbb</groupId>
5149
<artifactId>junitperf</artifactId>
52-
<version>2.0.4</version>
50+
<version>2.0.5</version>
5351
</dependency>
5452
```
5553

@@ -84,7 +82,7 @@ public class HelloWorldTest {
8482
| threads | 执行时使用多少线程执行 | int | 1 | |
8583
| warmUp | 准备时间 | long | 0 | 单位:毫秒 |
8684
| duration | 执行时间 | long | 60_000(1分钟) | 单位:毫秒 |
87-
| statistics | 统计实现 | StatisticsCalculator | DefaultStatisticsCalculator | |
85+
| latencyStatistics | 统计实现 | StatisticsCalculator | DefaultStatisticsCalculator | |
8886
| reporter | 报告实现 | Reporter | ConsoleReporter | |
8987

9088
使用如下:
@@ -171,6 +169,7 @@ public class JunitPerfRequireTest {
171169
[INFO] 2018-01-14 22:16:31.424 [] - Min latency: 200.2112ms (Required: -1.0ms) - PASSED
172170
[INFO] 2018-01-14 22:16:31.424 [] - Max latency: 205.67862ms (Required: -1.0ms) - PASSED
173171
[INFO] 2018-01-14 22:16:31.425 [] - Ave latency: 202.97829ms (Required: -1.0ms) - PASSED
172+
[INFO] 2018-01-14 22:16:31.425 [] - Memory cost: 16byte
174173
```
175174

176175
### HTML 方式
@@ -219,5 +218,6 @@ idea 用户请勾选上图中的选项
219218

220219
# 后期 Road-MAP
221220

222-
- [ ] 内存使用统计
221+
- [ x ] 内存使用统计
223222

223+
- [ ] 支持线程的 sync 同步执行

pom.xml

+13-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.github.houbb</groupId>
66
<artifactId>junitperf</artifactId>
7-
<version>2.0.5-SNAPSHOT</version>
7+
<version>2.0.5</version>
88

99
<properties>
1010
<!--============================== All Plugins START ==============================-->
@@ -35,6 +35,7 @@
3535
<junit.version>5.2.0</junit.version>
3636
<freemarker.version>2.3.23</freemarker.version>
3737
<google.guava.version>21.0</google.guava.version>
38+
<lucene-core.version>4.0.0</lucene-core.version>
3839

3940
<!--sonar-->
4041
<sonar.java.binaries>target/classes</sonar.java.binaries>
@@ -76,6 +77,12 @@
7677
<version>${junit.version}</version>
7778
</dependency>
7879

80+
<dependency>
81+
<groupId>org.apache.lucene</groupId>
82+
<artifactId>lucene-core</artifactId>
83+
<version>${lucene-core.version}</version>
84+
</dependency>
85+
7986
</dependencies>
8087
</dependencyManagement>
8188

@@ -108,6 +115,11 @@
108115
<artifactId>junit-jupiter-engine</artifactId>
109116
</dependency>
110117

118+
<dependency>
119+
<groupId>org.apache.lucene</groupId>
120+
<artifactId>lucene-core</artifactId>
121+
</dependency>
122+
111123
</dependencies>
112124

113125
<build>

release.bat

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ ECHO "============================= RELEASE START..."
1010

1111
:: 版本号信息(需要手动指定)
1212
:::: 旧版本名称
13-
SET version=2.0.4
13+
SET version=2.0.5
1414
:::: 新版本名称
15-
SET newVersion=2.0.5
15+
SET newVersion=2.0.6
1616
:::: 组织名称
1717
SET groupName=com.github.houbb
1818
:::: 项目名称

src/main/java/com/github/houbb/junitperf/core/annotation/JunitPerfConfig.java

+6-9
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,11 @@
66
import com.github.houbb.junitperf.core.report.impl.ConsoleReporter;
77
import com.github.houbb.junitperf.core.statistics.StatisticsCalculator;
88
import com.github.houbb.junitperf.core.statistics.impl.DefaultStatisticsCalculator;
9-
109
import org.apiguardian.api.API;
11-
import org.junit.jupiter.api.Test;
1210
import org.junit.jupiter.api.TestTemplate;
1311
import org.junit.jupiter.api.extension.ExtendWith;
14-
import org.junit.platform.commons.annotation.Testable;
1512

16-
import java.lang.annotation.Documented;
17-
import java.lang.annotation.ElementType;
18-
import java.lang.annotation.Retention;
19-
import java.lang.annotation.RetentionPolicy;
20-
import java.lang.annotation.Target;
21-
import java.util.Set;
13+
import java.lang.annotation.*;
2214

2315
/**
2416
* 执行接口
@@ -38,12 +30,14 @@
3830
/**
3931
* 执行时使用多少线程执行
4032
* @return int val
33+
* @since 1.0.0
4134
*/
4235
int threads() default 1;
4336

4437
/**
4538
* 准备时间(单位:毫秒)
4639
* @return time in mills
40+
* @since 1.0.0
4741
*/
4842
long warmUp() default 0L;
4943

@@ -52,18 +46,21 @@
5246
* 默认值:默认为 1min
5347
* 这里的执行时间不包含准备时间。
5448
* @return time in mills
49+
* @since 1.0.0
5550
*/
5651
long duration() default 60_000L;
5752

5853
/**
5954
* 存放统计信息工具
6055
* @return 统计实现类
56+
* @since 1.0.0
6157
*/
6258
Class<? extends StatisticsCalculator> statistics() default DefaultStatisticsCalculator.class;
6359

6460
/**
6561
* 存放报告信息类
6662
* @return 报告信息
63+
* @since 1.0.0
6764
*/
6865
Class<? extends Reporter>[] reporter() default {ConsoleReporter.class};
6966

src/main/java/com/github/houbb/junitperf/core/report/impl/ConsoleReporter.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ public void report(Class testClass, Set<EvaluationContext> evaluationContextSet)
5757
statistics.getMaxLatency(MILLISECONDS),
5858
evaluationRequire.getRequireMax(),
5959
getStatus(evaluationResult.isMaxAchieved()));
60-
ConsoleUtil.info("Ave latency: {}ms (Required: {}ms) - {}",
60+
ConsoleUtil.info("Avg latency: {}ms (Required: {}ms) - {}",
6161
statistics.getMeanLatency(MILLISECONDS),
6262
evaluationRequire.getRequireAverage(),
6363
getStatus(evaluationResult.isAverageAchieved()));
6464

65+
// 输出内存信息
66+
reportMemory(statistics);
6567

6668
for (Map.Entry<Integer, Float> entry : evaluationRequire.getRequirePercentilesMap().entrySet()) {
6769
Integer percentile = entry.getKey();
@@ -78,6 +80,15 @@ public void report(Class testClass, Set<EvaluationContext> evaluationContextSet)
7880
}
7981
}
8082

83+
/**
84+
* 输出内存消耗信息
85+
* @param statistics 统计信息
86+
* @since 2.0.5
87+
*/
88+
private void reportMemory(final StatisticsCalculator statistics) {
89+
// 内存
90+
ConsoleUtil.info("Memory cost: {}byte", statistics.getMemory());
91+
}
8192

8293
/**
8394
* 获取状态

src/main/java/com/github/houbb/junitperf/core/statistics/StatisticsCalculator.java

+14
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,18 @@ public interface StatisticsCalculator extends Serializable {
7878
*/
7979
float getMeanLatency(TimeUnit unit);
8080

81+
/**
82+
* 添加内存
83+
* @param memoryKb 内存消耗
84+
* @since 2.0.5
85+
*/
86+
void setMemory(final long memoryKb);
87+
88+
/**
89+
* 获取内存的消耗
90+
* @return 内存消耗
91+
* @since 2.0.5
92+
*/
93+
long getMemory();
94+
8195
}

src/main/java/com/github/houbb/junitperf/core/statistics/impl/DefaultStatisticsCalculator.java

+36-9
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ public class DefaultStatisticsCalculator implements StatisticsCalculator {
2222

2323
//region private fields
2424
/**
25-
* 统计方式
25+
* 耗时统计方式
26+
* @since 1.0.0
2627
*/
27-
private final DescriptiveStatistics statistics;
28+
private final DescriptiveStatistics latencyStatistics;
2829

2930
/**
3031
* 执行评价计数
@@ -35,22 +36,38 @@ public class DefaultStatisticsCalculator implements StatisticsCalculator {
3536
* 错误计数
3637
*/
3738
private final AtomicLong errorCount = new AtomicLong();
39+
40+
/**
41+
* 内存消耗
42+
* @since 2.0.5
43+
*/
44+
private volatile long memoryKb;
45+
3846
//endregion
3947

4048
//region constructor
49+
/**
50+
* 默认构造器
51+
* @since 2.0.5
52+
*/
4153
public DefaultStatisticsCalculator() {
4254
this(new SynchronizedDescriptiveStatistics());
4355
}
4456

45-
public DefaultStatisticsCalculator(DescriptiveStatistics statistics) {
46-
this.statistics = statistics;
57+
/**
58+
* 私有构造器
59+
* @param latencyStatistics 延迟统计
60+
* @since 1.0.0
61+
*/
62+
private DefaultStatisticsCalculator(final DescriptiveStatistics latencyStatistics) {
63+
this.latencyStatistics = latencyStatistics;
4764
}
4865
//endregion
4966

5067
//region methods
5168
@Override
5269
public void addLatencyMeasurement(long executionTimeNs) {
53-
statistics.addValue(executionTimeNs);
70+
latencyStatistics.addValue(executionTimeNs);
5471
}
5572

5673
@Override
@@ -80,22 +97,32 @@ public long getEvaluationCount() {
8097

8198
@Override
8299
public float getLatencyPercentile(int percentile, TimeUnit unit) {
83-
return (float)statistics.getPercentile((double)(percentile)) / unit.toNanos(1);
100+
return (float) latencyStatistics.getPercentile((double)(percentile)) / unit.toNanos(1);
84101
}
85102

86103
@Override
87104
public float getMaxLatency(TimeUnit unit) {
88-
return (float)statistics.getMax() / unit.toNanos(1);
105+
return (float) latencyStatistics.getMax() / unit.toNanos(1);
89106
}
90107

91108
@Override
92109
public float getMinLatency(TimeUnit unit) {
93-
return (float)statistics.getMin() / unit.toNanos(1);
110+
return (float) latencyStatistics.getMin() / unit.toNanos(1);
94111
}
95112

96113
@Override
97114
public float getMeanLatency(TimeUnit unit) {
98-
return (float)statistics.getMean() / unit.toNanos(1);
115+
return (float) latencyStatistics.getMean() / unit.toNanos(1);
116+
}
117+
118+
@Override
119+
public void setMemory(long memoryKb) {
120+
this.memoryKb = memoryKb;
121+
}
122+
123+
@Override
124+
public long getMemory() {
125+
return this.memoryKb;
99126
}
100127
//endregion
101128

src/main/java/com/github/houbb/junitperf/model/vo/I18nVo.java

+14
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ public class I18nVo {
3434
private String max_latency;
3535
private String avg_latency;
3636

37+
/**
38+
* 内存消耗
39+
* @since 2.0.5
40+
*/
41+
private String memory;
42+
3743
public String getJunit_performance_report() {
3844
return junit_performance_report;
3945
}
@@ -161,4 +167,12 @@ public String getRequired() {
161167
public void setRequired(String required) {
162168
this.required = required;
163169
}
170+
171+
public String getMemory() {
172+
return memory;
173+
}
174+
175+
public void setMemory(String memory) {
176+
this.memory = memory;
177+
}
164178
}

0 commit comments

Comments
 (0)