gf/g/os/grpool/grpool_test.go
2018-07-27 15:48:49 +08:00

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)
}