go -- 测试
2024-10-19 15:29:26
package 测试 import (
"fmt"
"github.com/magiconair/properties/assert"
"net/http"
"net/http/httptest"
"testing"
) func TestPing(t *testing.T) { for i:=0; i<10; i++ { t.Run("sds", func(t *testing.T) {
t.Parallel()
r := setupRouter()
w := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/ping", nil)
if err != nil {
return
}
r.ServeHTTP(w, req) assert.Equal(t, w.Code, 200)
assert.Equal(t, w.Body.String(), "pong")
assert.Equal(t, w.Body.String(), "pong")
})
} } func BenchmarkPing(b *testing.B) {
b.SetParallelism(100)
for i := 0; i < b.N; i++ { b.RunParallel(func(pb *testing.PB) {
fmt.Println(i)
r := setupRouter() w := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/ping", nil)
if err != nil {
return
}
b.SetBytes(100)
for pb.Next() {
r.ServeHTTP(w, req)
} })
} }
最新文章
- how2heap分析系列:2_fastbin_dup
- Java基础学习(四)
- [原]简易android反编译教程
- jquery validate 在ajax提交表单下的验证方法
- Linux下执行程序出现 Text file busy 提示时的处理方式
- spring applicationContext.xml 文件
- shell入门之变量测试 分类: 学习笔记 linux ubuntu 2015-07-10 15:49 31人阅读 评论(0) 收藏
- python Debug 单步调试
- [虚拟化/云][全栈demo] 为qemu增加一个PCI的watchdog外设(一)
- HDU5804--Price List
- nyoj940 A dp problem 打表
- 【C++】undered_map的用法总结(1)
- ngnix使用超时响应时间配置避坑一例
- spring @Value注解#和$区别
- html中img图片居中
- laravel 安装步骤
- android 手机不能断点
- 【Python】python3实现网页爬虫下载图片
- 微信小游戏 50M那部分的缓存机制的使用
- jquery closest &; parent比较
热门文章
- Java 之 Response 发送验证码案例
- react native错误排查-TypeError: window.deltaUrlToBlobUrl is not a function
- 高阶函数概念以及map/filter/reduce
- 申请软件著作权,wps显示代码行号功能
- Android笔记(七十五) Android中的图片压缩
- 【Mybatis异常】 org.apache.ibatis.binding.BindingException: Parameter &#39;storeId&#39; not found. Available parameters are [form, param1]
- Oracle11g安装步骤(CentOS7)
- Python入门篇-functools
- cmdb资产管理2
- centos7最小安装后无法联网解决方法