-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# 常见问题 | ||
|
||
## 关于性能 | ||
|
||
我对[示例项目](https://github.com/stick-i/spel-validator-example)创建了一组简单的api测试用例,共15个请求,在后面的测试中,我会使用它们来进行测试。 | ||
|
||
![img_4.png](../image/faq-api-test.png) | ||
|
||
::: tip 测试环境 | ||
|
||
- Mac mini 2023款,M2芯片,16G内存 | ||
- 示例项目的接口中无业务逻辑,只有参数校验 | ||
- SpEL Validator 版本:v0.2.0-beta | ||
- JDK版本:8 | ||
- SpringBoot版本:2.7.17 | ||
|
||
::: | ||
|
||
### 执行耗时 | ||
|
||
测试条件: | ||
|
||
- 开启debug日志 | ||
- 接口未预热 | ||
- 使用Apifox进行2线程3循环的测试,共90次请求 | ||
|
||
测试结果: | ||
|
||
除了前几次请求耗时会达到 10ms 以上, | ||
后续请求耗时会稳定在 0~1ms 左右。 | ||
|
||
![img_2.png](../image/faq-execution-time1.png) | ||
![img.png](../image/faq-execution-time2.png) | ||
|
||
其中每条记录表示一次接口调用的完整校验耗时。 | ||
|
||
### 火焰图 | ||
|
||
测试条件: | ||
|
||
- 关闭debug日志 | ||
- 接口充分预热 | ||
- 使用 Apifox 进行10线程10循环的测试,共1500次请求 | ||
- 使用 IDEA 自带的 IntelliJ Profiler 进行分析 | ||
|
||
得到如下的火焰图 | ||
|
||
![img_1.png](../image/faq-flame1.png) | ||
|
||
![img_5.png](../image/faq-flame2.png) | ||
|
||
可以看到,本组件的总耗时为170ms,平均每个请求耗时约0.11ms。 | ||
|
||
其中解析SpEL表达式的总耗时为110ms,占比约65%。 | ||
|
||
随后我在不同的数量的线程和循环次数后重新测试,得到的结果如下: | ||
|
||
- 5线程100循环,共7500次请求,总耗时约为 930ms,平均每个请求耗时约0.12ms,其中解析SpEL表达式的总耗时为 420ms,占比约45%。 | ||
- 20线程,30循环,共9000次此请求,总耗时约为 1190ms,平均每个请求耗时约0.13ms,其中解析SpEL表达式的总耗时为 390ms,占比约33%。 | ||
|
||
这样看来,目前的性能表现还算可以接受,但还有优化空间,后续会继续优化。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
|
||
下面以 `@SpelNotNull` 为例,展示如何实现自定义约束注解。 | ||
|
||
**以下内容还没写完** | ||
|
||
## 创建约束注解类 | ||
|
||
```java | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.