From ff2a43e593956b8b90c26607a553a042d7793fe4 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 20 Jun 2024 11:29:39 +0200 Subject: [PATCH] Reduced memory usage --- bench_test.go | 8 ++++++++ src/build/fs/Walk.go | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bench_test.go b/bench_test.go index 46f5f83..d091d84 100644 --- a/bench_test.go +++ b/bench_test.go @@ -21,3 +21,11 @@ func BenchmarkExpressions(b *testing.B) { compiler.Run() } } + +func BenchmarkHello(b *testing.B) { + compiler := build.New("examples/hello") + + for i := 0; i < b.N; i++ { + compiler.Run() + } +} diff --git a/src/build/fs/Walk.go b/src/build/fs/Walk.go index 78d6043..ce22ac5 100644 --- a/src/build/fs/Walk.go +++ b/src/build/fs/Walk.go @@ -5,8 +5,6 @@ import ( "unsafe" ) -const blockSize = 4096 - // Walk calls your callback function for every file name inside the directory. // It doesn't distinguish between files and directories. func Walk(directory string, callBack func(string)) error { @@ -17,7 +15,7 @@ func Walk(directory string, callBack func(string)) error { } defer syscall.Close(fd) - buffer := make([]byte, blockSize) + buffer := make([]byte, 1024) for { n, err := syscall.ReadDirent(fd, buffer)