Skip to content

Commit

Permalink
Merge pull request KillingSpark#13 from tmiasko/dbus-core
Browse files Browse the repository at this point in the history
Add dbus-core to marshalling benchmarks
  • Loading branch information
KillingSpark authored Jul 18, 2020
2 parents 3073b3f + 8c4c805 commit 08d8a41
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ zvariant_derive = { git = "https://gitlab.freedesktop.org/zeenix/zbus", rev="8c2
serde = { version = "1.0", features = [ "derive" ] }
zbus = {git = "https://gitlab.freedesktop.org/zeenix/zbus", rev="8c2d6232"}

dbus-core = {git = "https://github.com/tmiasko/dbus-core", rev = "7d8889483e759080c057c8c2a9d866eb506e7104"}
dbus-pure = {git = "https://github.com/Arnavion/dbus-pure", version = "0.1.0"}

dbus-message-parser = "1.0"
Expand Down
32 changes: 32 additions & 0 deletions benches/marshal_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,33 @@ fn make_rustbus_message<'a, 'e>(parts: &'a MessageParts, send_it: bool) {
}
}

fn make_dbus_core_message(parts: &MessageParts, send_it: bool) {
use dbus_core::codec::Struct;
use dbus_core::message::{MessageBuf, Signal};

let mut buf = MessageBuf::from(Signal {
path: &parts.object,
interface: &parts.interface,
member: &parts.member,
});
for _ in 0..parts.repeat {
buf.encode(&parts.string1);
buf.encode(&parts.int1);
buf.encode(&Struct((&parts.int2, &parts.string2)));
buf.encode(&parts.dict);
buf.encode(&parts.int_array);
buf.encode(&parts.string_array);
}
if send_it {
unimplemented!();
} else {
buf.set_serial(1);
let msg = buf.into_message().unwrap();
black_box(msg.header_bytes());
black_box(msg.body_bytes());
}
}

fn make_dbus_message_parser_message(parts: &MessageParts, send_it: bool) {
let mut signal =
dbus_message_parser::Message::signal(&parts.object, &parts.interface, &parts.member);
Expand Down Expand Up @@ -583,6 +610,11 @@ fn run_marshal_benches(group_name: &str, c: &mut Criterion, parts: &MessageParts
make_dbus_bytestream_message(parts, false);
})
});
group.bench_function("marshal_dbus_core", |b| {
b.iter(|| {
make_dbus_core_message(parts, false);
})
});
group.bench_function("marshal_dbus_msg_parser", |b| {
b.iter(|| {
make_dbus_message_parser_message(parts, false);
Expand Down

0 comments on commit 08d8a41

Please sign in to comment.