Skip to content

Commit

Permalink
docs: 补充文档内容
Browse files Browse the repository at this point in the history
  • Loading branch information
stick-i committed Aug 28, 2024
1 parent c7695d6 commit fdcc0bd
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,10 @@ https://github.com/stick-i/spel-validator/releases
### 分支说明

- `main`:主分支,已发布的最新版本代码将合入此分支。
- `docs`:文档分支,修改文档的内容将提交到这里。
- `vX.Y.Z`:版本分支,用于汇总及验证新版本的功能,已经发布的版本会将分支删除。
- `dev-xxx`:开发分支,用于开发新功能,每个dev分支都应当对应一个issue,功能开发完成后通过PR合入 `vX.Y.Z` 分支,并删除当前分支。
- `dev-num-desc`:开发分支,用于开发新功能,每个dev分支都应当对应一个issue,功能开发完成后通过PR合入 `vX.Y.Z` 分支,并删除当前分支。
- `docs`:文档分支,修改文档的内容将提交到这里。
- `gh-pages`:GitHub Pages 分支,用于发布在线文档。

## 💰 捐赠支持

Expand Down
1 change: 1 addition & 0 deletions document/web-docs/docs/.vuepress/configs/navbar/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const navbarZh: NavbarOptions = [
'/guide/user-guide.md',
'/guide/spel.md',
'/guide/custom.md',
'/guide/FAQ.md',
],
},
{
Expand Down
1 change: 1 addition & 0 deletions document/web-docs/docs/.vuepress/configs/sidebar/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const sidebarZh: SidebarOptions = {
'/guide/user-guide.md',
'/guide/spel.md',
'/guide/custom.md',
'/guide/FAQ.md',
],
},
],
Expand Down
61 changes: 61 additions & 0 deletions document/web-docs/docs/guide/FAQ.md
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%。

这样看来,目前的性能表现还算可以接受,但还有优化空间,后续会继续优化。
2 changes: 2 additions & 0 deletions document/web-docs/docs/guide/custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

下面以 `@SpelNotNull` 为例,展示如何实现自定义约束注解。

**以下内容还没写完**

## 创建约束注解类

```java
Expand Down
Binary file added document/web-docs/docs/image/faq-api-test.png
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.
Binary file added document/web-docs/docs/image/faq-flame1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added document/web-docs/docs/image/faq-flame2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fdcc0bd

Please sign in to comment.