Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go-fuse
Commits
13122745
Commit
13122745
authored
May 27, 2012
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for memory use.
parent
1106b7e2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
fuse/loopback_test.go
fuse/loopback_test.go
+36
-0
No files found.
fuse/loopback_test.go
View file @
13122745
...
...
@@ -9,6 +9,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"syscall"
"testing"
...
...
@@ -570,6 +571,41 @@ func CompareSlices(t *testing.T, got, want []byte) {
}
}
// Check that reading large files doesn't lead to large allocations.
func
TestReadLargeMemCheck
(
t
*
testing
.
T
)
{
ts
:=
NewTestCase
(
t
)
defer
ts
.
Cleanup
()
content
:=
RandomData
(
385
*
1023
)
err
:=
ioutil
.
WriteFile
(
ts
.
origFile
,
[]
byte
(
content
),
0644
)
CheckSuccess
(
err
)
f
,
err
:=
os
.
Open
(
ts
.
mountFile
)
CheckSuccess
(
err
)
buf
:=
make
([]
byte
,
len
(
content
)
+
1024
)
f
.
Read
(
buf
)
CheckSuccess
(
err
)
f
.
Close
()
runtime
.
GC
()
var
before
,
after
runtime
.
MemStats
N
:=
100
runtime
.
ReadMemStats
(
&
before
)
for
i
:=
0
;
i
<
N
;
i
++
{
f
,
_
:=
os
.
Open
(
ts
.
mountFile
)
f
.
Read
(
buf
)
f
.
Close
()
}
runtime
.
ReadMemStats
(
&
after
)
delta
:=
int
((
after
.
TotalAlloc
-
before
.
TotalAlloc
))
delta
=
(
delta
-
40000
)
/
N
limit
:=
5000
if
delta
>
limit
{
t
.
Errorf
(
"bytes per loop: %d, limit %d"
,
delta
,
limit
)
}
}
func
TestReadLarge
(
t
*
testing
.
T
)
{
ts
:=
NewTestCase
(
t
)
defer
ts
.
Cleanup
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment