Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
18 changed files
with
296 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/gin-gonic/gin" | ||
"github.com/google/uuid" | ||
"github.com/guonaihong/gout" | ||
"github.com/guonaihong/gout/filter" | ||
"sync/atomic" | ||
"time" | ||
) | ||
|
||
const ( | ||
benchNumber = 30000 | ||
benchConcurrent = 30 | ||
) | ||
|
||
func server() { | ||
router := gin.New() | ||
router.POST("/", func(c *gin.Context) { | ||
c.String(200, "hello world:gout") | ||
}) | ||
|
||
router.Run() | ||
} | ||
|
||
func customize() { | ||
i := int32(0) | ||
|
||
err := filter.NewBench(). | ||
Concurrent(benchConcurrent). | ||
Number(benchNumber). | ||
Loop(func(c *gout.Context) error { | ||
|
||
// 下面的代码,每次生成不一样的http body 用于压测 | ||
uid := uuid.New() | ||
id := atomic.AddInt32(&i, 1) | ||
|
||
c.POST(":8080").SetJSON(gout.H{"sid": uid.String(), | ||
"appkey": fmt.Sprintf("ak:%d", id), | ||
"text": fmt.Sprintf("test text :%d", id)}) | ||
return nil | ||
|
||
}).Do() | ||
|
||
if err != nil { | ||
fmt.Printf("err = %v\n", err) | ||
} | ||
} | ||
|
||
func main() { | ||
go server() | ||
time.Sleep(300 * time.Millisecond) | ||
|
||
customize() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.