Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
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
capnproto
Commits
4dd3161d
Commit
4dd3161d
authored
Mar 28, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Benchmark improvements.
parent
eb710512
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
15 deletions
+28
-15
capnproto-common.h
c++/src/capnproto/benchmark/capnproto-common.h
+12
-9
runner.c++
c++/src/capnproto/benchmark/runner.c++
+16
-6
No files found.
c++/src/capnproto/benchmark/capnproto-common.h
View file @
4dd3161d
...
...
@@ -96,25 +96,28 @@ struct Packed {
}
};
static
byte
snappyReadBuffer
[
SNAPPY_BUFFER_SIZE
];
static
byte
snappyWriteBuffer
[
SNAPPY_BUFFER_SIZE
];
static
byte
snappyCompressedBuffer
[
SNAPPY_COMPRESSED_BUFFER_SIZE
];
struct
SnappyCompressed
{
typedef
FdInputStream
&
BufferedInput
;
typedef
SnappyMessageReader
MessageReader
;
typedef
BufferedInputStreamWrapper
BufferedInput
;
typedef
Snappy
Packed
MessageReader
MessageReader
;
class
ArrayMessageReader
:
private
ArrayInputStream
,
public
SnappyMessageReader
{
class
ArrayMessageReader
:
private
ArrayInputStream
,
public
Snappy
Packed
MessageReader
{
public
:
ArrayMessageReader
(
ArrayPtr
<
const
byte
>
array
,
ReaderOptions
options
=
ReaderOptions
(),
ArrayPtr
<
word
>
scratchSpace
=
nullptr
)
:
ArrayInputStream
(
array
),
SnappyMessageReader
(
*
this
,
options
,
scratchSpace
)
{}
SnappyPackedMessageReader
(
static_cast
<
ArrayInputStream
&>
(
*
this
),
options
,
scratchSpace
,
arrayPtr
(
snappyReadBuffer
,
SNAPPY_BUFFER_SIZE
))
{}
};
static
inline
void
write
(
OutputStream
&
output
,
MessageBuilder
&
builder
)
{
writeSnappyMessage
(
output
,
builder
);
}
static
inline
void
write
(
BufferedOutputStream
&
output
,
MessageBuilder
&
builder
)
{
writeSnappyMessage
(
output
,
builder
);
writeSnappyPackedMessage
(
output
,
builder
,
arrayPtr
(
snappyWriteBuffer
,
SNAPPY_BUFFER_SIZE
),
arrayPtr
(
snappyCompressedBuffer
,
SNAPPY_COMPRESSED_BUFFER_SIZE
));
}
};
...
...
c++/src/capnproto/benchmark/runner.c++
View file @
4dd3161d
...
...
@@ -278,11 +278,11 @@ void reportComparisonHeader() {
class
Gain
{
public
:
Gain
(
double
oldValue
,
double
newValue
)
:
amount
(
oldValue
<
newValue
?
newValue
/
oldValue
:
-
oldValue
/
new
Value
)
{}
:
amount
(
newValue
/
old
Value
)
{}
void
writeTo
(
std
::
ostream
&
os
)
{
if
(
-
2
<
amount
&&
amount
<
2
)
{
double
percent
=
(
amount
>
0
?
amount
-
1
:
amount
+
1
)
*
100
;
if
(
amount
<
2
)
{
double
percent
=
(
amount
-
1
)
*
100
;
os
<<
(
int
)(
percent
+
0.5
)
<<
"%"
;
}
else
{
os
<<
fixed
<<
setprecision
(
2
)
<<
amount
<<
"x"
;
...
...
@@ -311,8 +311,18 @@ void reportComparison(const char* name, double base, double protobuf, double cap
void
reportComparison
(
const
char
*
name
,
const
char
*
unit
,
double
protobuf
,
double
capnproto
,
uint64_t
iters
)
{
cout
<<
setw
(
35
)
<<
left
<<
name
<<
setw
(
15
-
strlen
(
unit
))
<<
right
<<
setprecision
(
2
)
<<
(
protobuf
/
iters
)
<<
unit
<<
setw
(
15
-
strlen
(
unit
))
<<
right
<<
setprecision
(
2
)
<<
(
capnproto
/
iters
)
<<
unit
;
<<
setw
(
15
-
strlen
(
unit
))
<<
fixed
<<
right
<<
setprecision
(
2
)
<<
(
protobuf
/
iters
)
<<
unit
<<
setw
(
15
-
strlen
(
unit
))
<<
fixed
<<
right
<<
setprecision
(
2
)
<<
(
capnproto
/
iters
)
<<
unit
;
// Since smaller is better, the "improvement" is the "gain" from capnproto to protobuf.
cout
<<
setw
(
14
)
<<
right
<<
Gain
(
capnproto
,
protobuf
)
<<
endl
;
}
void
reportIntComparison
(
const
char
*
name
,
const
char
*
unit
,
uint64_t
protobuf
,
uint64_t
capnproto
,
uint64_t
iters
)
{
cout
<<
setw
(
35
)
<<
left
<<
name
<<
setw
(
15
-
strlen
(
unit
))
<<
right
<<
(
protobuf
/
iters
)
<<
unit
<<
setw
(
15
-
strlen
(
unit
))
<<
right
<<
(
capnproto
/
iters
)
<<
unit
;
// Since smaller is better, the "improvement" is the "gain" from capnproto to protobuf.
cout
<<
setw
(
14
)
<<
right
<<
Gain
(
capnproto
,
protobuf
)
<<
endl
;
...
...
@@ -472,7 +482,7 @@ int main(int argc, char* argv[]) {
((
int64_t
)
protobuf
.
time
.
cpu
()
-
(
int64_t
)
protobufBase
.
time
.
cpu
())
/
1000.0
,
((
int64_t
)
capnp
.
time
.
cpu
()
-
(
int64_t
)
capnpBase
.
time
.
cpu
())
/
1000.0
,
iters
);
reportComparison
(
"bandwidth"
,
"B"
,
protobuf
.
throughput
,
capnp
.
throughput
,
iters
);
report
Int
Comparison
(
"bandwidth"
,
"B"
,
protobuf
.
throughput
,
capnp
.
throughput
,
iters
);
reportComparison
(
"binary size"
,
"kB"
,
fileSize
(
"protobuf-"
+
std
::
string
(
testCaseName
(
testCase
)))
/
1024.0
,
...
...
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