mirror of
https://gitee.com/johng/gf.git
synced 2024-12-04 21:28:22 +08:00
35 lines
839 B
Go
35 lines
839 B
Go
// Copyright 2017 gf Author(https://gitee.com/johng/gf). All Rights Reserved.
|
|
//
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
// If a copy of the MIT was not distributed with this file,
|
|
// You can obtain one at https://gitee.com/johng/gf.
|
|
|
|
package grpool_test
|
|
|
|
import (
|
|
"testing"
|
|
"runtime"
|
|
"fmt"
|
|
)
|
|
|
|
func increment() {
|
|
for i := 0; i < 100000; i++ {}
|
|
}
|
|
|
|
//func Test_GrpoolMemUsage(t *testing.T) {
|
|
// for i := 0; i < n; i++ {
|
|
// grpool.Add(increment)
|
|
// }
|
|
// mem := runtime.MemStats{}
|
|
// runtime.ReadMemStats(&mem)
|
|
// fmt.Println("mem usage:", mem.TotalAlloc/1024)
|
|
//}
|
|
|
|
func Test_GroroutineMemUsage(t *testing.T) {
|
|
for i := 0; i < n; i++ {
|
|
go increment()
|
|
}
|
|
mem := runtime.MemStats{}
|
|
runtime.ReadMemStats(&mem)
|
|
fmt.Println("mem usage:", mem.TotalAlloc/1024)
|
|
} |