Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
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
Commits
19e80b08
Commit
19e80b08
authored
Aug 04, 2011
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gob: add UpdateMemStats calls to malloc counter
R=golang-dev, dsymonds CC=golang-dev
https://golang.org/cl/4808071
parent
ee9168d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
1 deletion
+5
-1
src/pkg/gob/encode.go
src/pkg/gob/encode.go
+1
-1
src/pkg/gob/timing_test.go
src/pkg/gob/timing_test.go
+4
-0
No files found.
src/pkg/gob/encode.go
View file @
19e80b08
...
...
@@ -484,7 +484,7 @@ func isZero(val reflect.Value) bool {
case
reflect
.
Uint
,
reflect
.
Uint8
,
reflect
.
Uint16
,
reflect
.
Uint32
,
reflect
.
Uint64
,
reflect
.
Uintptr
:
return
val
.
Uint
()
==
0
}
panic
(
"unknown type in isZero"
+
val
.
Type
()
.
String
())
panic
(
"unknown type in isZero
"
+
val
.
Type
()
.
String
())
}
// encGobEncoder encodes a value that implements the GobEncoder interface.
...
...
src/pkg/gob/timing_test.go
View file @
19e80b08
...
...
@@ -53,6 +53,7 @@ func TestCountEncodeMallocs(t *testing.T) {
var
buf
bytes
.
Buffer
enc
:=
NewEncoder
(
&
buf
)
bench
:=
&
Bench
{
7
,
3.2
,
"now is the time"
,
[]
byte
(
"for all good men"
)}
runtime
.
UpdateMemStats
()
mallocs
:=
0
-
runtime
.
MemStats
.
Mallocs
const
count
=
1000
for
i
:=
0
;
i
<
count
;
i
++
{
...
...
@@ -61,6 +62,7 @@ func TestCountEncodeMallocs(t *testing.T) {
t
.
Fatal
(
"encode:"
,
err
)
}
}
runtime
.
UpdateMemStats
()
mallocs
+=
runtime
.
MemStats
.
Mallocs
fmt
.
Printf
(
"mallocs per encode of type Bench: %d
\n
"
,
mallocs
/
count
)
}
...
...
@@ -77,6 +79,7 @@ func TestCountDecodeMallocs(t *testing.T) {
}
}
dec
:=
NewDecoder
(
&
buf
)
runtime
.
UpdateMemStats
()
mallocs
:=
0
-
runtime
.
MemStats
.
Mallocs
for
i
:=
0
;
i
<
count
;
i
++
{
*
bench
=
Bench
{}
...
...
@@ -85,6 +88,7 @@ func TestCountDecodeMallocs(t *testing.T) {
t
.
Fatal
(
"decode:"
,
err
)
}
}
runtime
.
UpdateMemStats
()
mallocs
+=
runtime
.
MemStats
.
Mallocs
fmt
.
Printf
(
"mallocs per decode of type Bench: %d
\n
"
,
mallocs
/
count
)
}
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