Reduced memory usage
This commit is contained in:
parent
9b50c917e9
commit
ff2a43e593
@ -21,3 +21,11 @@ func BenchmarkExpressions(b *testing.B) {
|
|||||||
compiler.Run()
|
compiler.Run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkHello(b *testing.B) {
|
||||||
|
compiler := build.New("examples/hello")
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
compiler.Run()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -5,8 +5,6 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
const blockSize = 4096
|
|
||||||
|
|
||||||
// Walk calls your callback function for every file name inside the directory.
|
// Walk calls your callback function for every file name inside the directory.
|
||||||
// It doesn't distinguish between files and directories.
|
// It doesn't distinguish between files and directories.
|
||||||
func Walk(directory string, callBack func(string)) error {
|
func Walk(directory string, callBack func(string)) error {
|
||||||
@ -17,7 +15,7 @@ func Walk(directory string, callBack func(string)) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defer syscall.Close(fd)
|
defer syscall.Close(fd)
|
||||||
buffer := make([]byte, blockSize)
|
buffer := make([]byte, 1024)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
n, err := syscall.ReadDirent(fd, buffer)
|
n, err := syscall.ReadDirent(fd, buffer)
|
||||||
|
Loading…
Reference in New Issue
Block a user