From ba0ff4ede62fa9efe475cfb69d3db1177aa8abb7 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sun, 1 Oct 2023 19:48:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E5=A4=84=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/caches/list_file_hash_map.go | 4 ++++ internal/caches/list_file_hash_map_test.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/internal/caches/list_file_hash_map.go b/internal/caches/list_file_hash_map.go index 0c016a2..2a72529 100644 --- a/internal/caches/list_file_hash_map.go +++ b/internal/caches/list_file_hash_map.go @@ -113,6 +113,10 @@ func (this *FileListHashMap) Len() int { return len(this.m) } +func (this *FileListHashMap) SetIsAvailable(isAvailable bool) { + this.isAvailable = isAvailable +} + func (this *FileListHashMap) bigInt(hash string) uint64 { var bigInt = big.NewInt(0) bigInt.SetString(hash, 16) diff --git a/internal/caches/list_file_hash_map_test.go b/internal/caches/list_file_hash_map_test.go index e2bf7fd..06f6931 100644 --- a/internal/caches/list_file_hash_map_test.go +++ b/internal/caches/list_file_hash_map_test.go @@ -20,15 +20,19 @@ func TestFileListHashMap_Memory(t *testing.T) { runtime.ReadMemStats(stat1) var m = caches.NewFileListHashMap() + m.SetIsAvailable(true) for i := 0; i < 1_000_000; i++ { m.Add(stringutil.Md5(types.String(i))) } + t.Log("added:", m.Len(), "hashes") + var stat2 = &runtime.MemStats{} runtime.ReadMemStats(stat2) t.Log("ready", (stat2.Alloc-stat1.Alloc)/1024/1024, "M") + t.Log("remains:", m.Len(), "hashes") } func TestFileListHashMap_Memory2(t *testing.T) {