Commit aa43afa 1 parent 22e056a commit aa43afa Copy full SHA for aa43afa
File tree 1 file changed +23
-1
lines changed
1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ GoLand 打开项目时会自动初始化 `go mod tidy`,VS Code 不会,需要
37
37
``` json
38
38
// 注意,这份配置应该位于 launch.json 的 configurations 字段下
39
39
{
40
- "name" : " Launch File" , // 会显示在 VS Code 界面的人类可读的名字
40
+ "name" : " Launch File" , // 会显示在 VS Code debug 界面的人类可读的名字
41
41
"type" : " go" , // 声明为 go 语言的配置
42
42
"request" : " launch" ,
43
43
"mode" : " debug" , // 支持断点调试
@@ -146,3 +146,25 @@ bufio.NewReader(os.Stdin)
146
146
```
147
147
148
148
参考 [ Stack Overflow] ( https://stackoverflow.com/questions/64786161/use-input-stdin-in-debug-console-vscode ) ,也可以在 args 中配置标准输入重定向。
149
+
150
+ ## Benchmark
151
+
152
+ 除了基础的单元测试,也支持配置 go 内置的 benchmark。
153
+ 假设基准测试代码都在 ` benchmark ` 目录下。本质上也是 ` go test -c ` 然后执行构建的可执行文件。
154
+
155
+ ``` json
156
+ {
157
+ "name" : " Benchmark" ,
158
+ "type" : " go" ,
159
+ "request" : " launch" ,
160
+ "mode" : " test" ,
161
+ "program" : " ${workspaceFolder}\\ benchmark" ,
162
+ "output" : " ${workspaceFolder}\\ benchmark\\ benchmark" ,
163
+ "args" : [
164
+ " -test.bench=^Benchmark" , // 只关注 Benchmark 开头的函数
165
+ " -test.v" ,
166
+ " -test.run=^$" ,
167
+ " -test.benchmem" // 查看内存分配信息
168
+ ]
169
+ }
170
+ ```
You can’t perform that action at this time.
0 commit comments