GolangNote

Golang笔记

自己测试golang web 框架性能的方法

Permalink

在选择Golang web 框架时往往需要先了解其性能,下面是一种在自己电脑上比较的简单方法。

测试golang web 框架性能

有个开源的项目帮你轻松做到:

安装: go get github.com/julienschmidt/go-http-routing-benchmark 这可能需要很长时间,因为要安装很多框架。

切换到目录,运行

plaintext: http-routing-benchmark
1
2
cd $GOPATH/src/github.com/julienschmidt/go-http-routing-benchmark
go test -bench=.

默认会比较所有的框架,你也可以只比较你关心的框架:

plaintext: bench
1
go test -bench="Martini|Gin|HttpMux"

注意:这只是路由解析性能的比较。

本文网址: https://golangnote.com/topic/17.html 转摘请注明来源

Related articles

Golang Range 的性能提升Tip

Go 语言里使用 range 可以方便遍历数组(array)、切片(slice)、字典(map)和信道(chan)。这里主要关注他们的性能。...

golang web 框架 goji 介绍

goji 是个后起的golang web框架,避免其它golang web 框架走过的坑,在性能、简单性方面做得很好。...

Golang 泛型性能初识

编程时,我们通常需要编写“泛型”函数,其中确切的数据类型并不重要。例如,您可能想编写一个简单的函数来对数字进行求和。Go 直到最近才有这个概念,但最近才添加了它(从1.18版开始)。...

Write a Comment to "自己测试golang web 框架性能的方法"

Submit Comment Login
Based on Golang + fastHTTP + sdb | go1.22.3 Processed in 0ms