网站建设的业务员,wordpress font awesome,中国互联网金融公司排名,做黑彩票的网站赚钱目录
背景
环境安装
脚本编写
master
slave节点#xff08;golang/boomer#xff09;
问题 资料获取方法 背景
很早之前#xff0c;考虑单机执行能力#xff0c;使用locust做过公司短信网关的压测工作#xff0c;后来发现了一个golang版本的locust#xff0c;性能…目录
背景
环境安装
脚本编写
master
slave节点golang/boomer
问题 资料获取方法 背景
很早之前考虑单机执行能力使用locust做过公司短信网关的压测工作后来发现了一个golang版本的locust性能是python版本的5到10倍以上但是一直没有机会使用。
最近公司想做一个性能测试平台技术选型要求和开发的语言一致即golang所以我想到了boomer本文为boomer的使用记录。 环境安装
开发环境安装Python 3.7略locust 0.11.0pip install locustiogolang略boomergo get github.com/myzhan/boomer 注最新版本的boomer兼容了goczmq需要将locust升级到较高版本才能完成兼容。 脚本编写
master
这部分的代码不重要只要能启动就行。
from locust import Locust, TaskSet, taskclass MyTaskSet(TaskSet):task(20)def hello(self):passclass Dummy(Locust):task_set MyTaskSetslave节点golang/boomer
package mainimport (bytesencoding/jsonfmtio/ioutillognet/httptimegithub.com/myzhan/boomer
)func getDemo() {start : time.Now()resp, err : http.Get(http://httpbin.org/get?nameDetector)if err ! nil {log.Println(err)return}defer resp.Body.Close()fmt.Println(resp.Status)elapsed : time.Since(start)if resp.Status 200 OK {boomer.RecordSuccess(http, sostreq, elapsed.Nanoseconds()/int64(time.Millisecond), int64(10))} else {boomer.RecordFailure(http, sostreq, elapsed.Nanoseconds()/int64(time.Millisecond), sostreq not equal)}
}func postDemo() {start : time.Now()info : make(map[string]interface{})info[name] Detectorinfo[age] 15info[loc] 深圳// 将map解析未[]byte类型bytesData, _ : json.Marshal(info)// 将解析之后的数据转为*Reader类型reader : bytes.NewReader(bytesData)resp, _ : http.Post(http://httpbin.org/post,application/json,reader)body, _ : ioutil.ReadAll(resp.Body)fmt.Println(string(body))elapsed : time.Since(start)if resp.Status 200 OK {boomer.RecordSuccess(http, sostreq, elapsed.Nanoseconds()/int64(time.Millisecond), int64(10))} else {boomer.RecordFailure(http, sostreq, elapsed.Nanoseconds()/int64(time.Millisecond), sostreq not equal)}
}func main() {task1 : boomer.Task{Name: sostreq,// The weight is used to distribute goroutines over multiple tasks.Weight: 20,Fn: getDemo,}task2 : boomer.Task{Name: sostreq,// The weight is used to distribute goroutines over multiple tasks.Weight: 10,Fn: postDemo,}boomer.Run(task1, task2)
}
实际效果如下 问题
Failed to execute dot. Is Graphviz installed? Error: exec: dot: executable file not found in $PATH 资料获取方法
【留言777】 各位想获取源码等教程资料的朋友请点赞 评论 收藏三连
三连之后我会在评论区挨个私信发给你们~