Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
d6323c8c
Commit
d6323c8c
authored
Mar 19, 2018
by
Yilun Chong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change to deal all messages in one loop
parent
501c13f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
go_benchmark_test.go
benchmarks/go_benchmark_test.go
+19
-18
No files found.
benchmarks/go_benchmark_test.go
View file @
d6323c8c
...
...
@@ -78,44 +78,45 @@ func init() {
func
Benchmark
(
b
*
testing
.
B
)
{
for
_
,
ds
:=
range
datasets
{
b
.
Run
(
ds
.
name
,
func
(
b
*
testing
.
B
)
{
counter
:=
0
count
:=
len
(
ds
.
marshaled
)
b
.
Run
(
"Unmarshal"
,
func
(
b
*
testing
.
B
)
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
payload
:=
ds
.
marshaled
[
counter
%
count
]
out
:=
ds
.
newMessage
()
if
err
:=
proto
.
Unmarshal
(
payload
,
out
);
err
!=
nil
{
b
.
Fatalf
(
"can't unmarshal message %d %v"
,
counter
%
count
,
err
)
for
j
,
payload
:=
range
ds
.
marshaled
{
out
:=
ds
.
newMessage
()
if
err
:=
proto
.
Unmarshal
(
payload
,
out
);
err
!=
nil
{
b
.
Fatalf
(
"can't unmarshal message %d %v"
,
j
,
err
)
}
}
counter
++
}
})
b
.
Run
(
"Marshal"
,
func
(
b
*
testing
.
B
)
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
m
:=
ds
.
unmarshaled
[
counter
%
count
]
if
_
,
err
:=
proto
.
Marshal
(
m
);
err
!=
nil
{
b
.
Fatalf
(
"can't marshal message %d %+v: %v"
,
counter
%
count
,
m
,
err
)
for
j
,
m
:=
range
ds
.
unmarshaled
{
if
_
,
err
:=
proto
.
Marshal
(
m
);
err
!=
nil
{
b
.
Fatalf
(
"can't marshal message %d %+v: %v"
,
j
,
m
,
err
)
}
}
counter
++
}
})
b
.
Run
(
"Size"
,
func
(
b
*
testing
.
B
)
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
proto
.
Size
(
ds
.
unmarshaled
[
counter
%
count
])
counter
++
for
_
,
m
:=
range
ds
.
unmarshaled
{
proto
.
Size
(
m
)
}
}
})
b
.
Run
(
"Clone"
,
func
(
b
*
testing
.
B
)
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
proto
.
Clone
(
ds
.
unmarshaled
[
counter
%
count
])
counter
++
for
_
,
m
:=
range
ds
.
unmarshaled
{
proto
.
Clone
(
m
)
}
}
})
b
.
Run
(
"Merge"
,
func
(
b
*
testing
.
B
)
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
out
:=
ds
.
newMessage
()
proto
.
Merge
(
out
,
ds
.
unmarshaled
[
counter
%
count
])
counter
++
for
_
,
m
:=
range
ds
.
unmarshaled
{
out
:=
ds
.
newMessage
()
proto
.
Merge
(
out
,
m
)
}
}
})
})
...
...
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