diff --git a/g/database/gdb/gdb_unit_1_test.go b/g/database/gdb/gdb_unit_1_test.go index 365671e85..bf132375c 100644 --- a/g/database/gdb/gdb_unit_1_test.go +++ b/g/database/gdb/gdb_unit_1_test.go @@ -33,6 +33,9 @@ func init() { db = r } // 准备测试数据结构 + if _, err := db.Exec("CREATE DATABASE IF NOT EXISTS `test` CHARACTER SET UTF8"); err != nil { + gtest.Fatal(err) + } if _, err := db.Exec("DROP TABLE `user`"); err != nil { gtest.Fatal(err) } diff --git a/g/os/gcache/gcache_mem_cache.go b/g/os/gcache/gcache_mem_cache.go index 4428324ac..ad0f245d3 100644 --- a/g/os/gcache/gcache_mem_cache.go +++ b/g/os/gcache/gcache_mem_cache.go @@ -63,8 +63,8 @@ func newMemCache(lruCap...int) *memCache { closed : gtype.NewBool(), } if len(lruCap) > 0 { - c.lru = newMemCacheLru(c) c.cap = lruCap[0] + c.lru = newMemCacheLru(c) } return c } diff --git a/g/os/grpool/grpool_testb2_test.go b/g/os/grpool/grpool_bench2_test.go similarity index 100% rename from g/os/grpool/grpool_testb2_test.go rename to g/os/grpool/grpool_bench2_test.go diff --git a/g/os/grpool/grpool_testb1_test.go b/g/os/grpool/grpool_bench_1_test.go similarity index 100% rename from g/os/grpool/grpool_testb1_test.go rename to g/os/grpool/grpool_bench_1_test.go diff --git a/g/os/grpool/grpool_test.go b/g/os/grpool/grpool_test.go deleted file mode 100644 index 1107499c2..000000000 --- a/g/os/grpool/grpool_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// 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) -} \ No newline at end of file