HW9

环境、工具

Win10操作系统、VSCode、pflag、martini

github传送门

github地址

实验过程

  • 配置环境,下载pflag、martini。
  • 创建文件夹HW9,在HW9创建main.go和service文件夹,在service文件夹创建server.go。
  • main.go
    在这里插入图片描述
  • server.go
    在这里插入图片描述
  • 运行
    在这里插入图片描述
  • 在浏览器输入网址 localhost:9876,可以看到server.go里写的string出现在屏幕上。
    在这里插入图片描述
    在这里插入图片描述
  • 使用 curl 测试
    在这里插入图片描述
  • 使用 ab 测试
    执行ab -n 1000 -c 100 http://localhost:9876/
    在这里插入图片描述
    ab命令基本参数如下:
    ab -n 访问次数 -c 并发量 url地址

测试结果解释如下:

Server Software:
Server Hostname: localhost
Server Port: 9876 ###端口号

Document Path: /
Document Length: 20 bytes ###文档返回的长度为 20 bytes

Concurrency Level: 100 ###并发数为100
Time taken for tests: 0.597 seconds ###总请求时间为 0.597 seconds
Complete requests: 1000 ###总请求数为1000
Failed requests: 0 ###失败请求数为0
Total transferred: 137000 bytes
HTML transferred: 20000 bytes
Requests per second: 1675.86 [#/sec] (mean) ###平均每秒的请求数为1675.86
Time per request: 59.671 [ms] (mean) ###平均每个请求消耗的时间 59.671 ms
Time per request: 0.597 [ms] (mean, across all concurrent requests) ###上面的请求除以并发数
Transfer rate: 224.21 [Kbytes/sec] received ###传输速率

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.4 0 1
Processing: 27 55 10.2 54 82
Waiting: 13 55 10.7 54 82
Total: 27 55 10.3 54 82

Percentage of the requests served within a certain time (ms)
50% 54 ###50%的请求都在 54 ms 内完成
66% 56
75% 59
80% 61
90% 69
95% 76
98% 81
99% 81
100% 82 (longest request)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值