Skip to content

Commit

Permalink
benchmarks: bump rust-protobuf dependency to 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
goffrie committed Feb 20, 2024
1 parent 0ad9676 commit 662f46b
Show file tree
Hide file tree
Showing 7 changed files with 1,603 additions and 234 deletions.
2 changes: 1 addition & 1 deletion pb-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ walkdir = "2.3.1"
# only used when benchmarking PROST!
prost = { version = "0.6", optional = true }
# only used when benchmarking rust-protobuf
protobuf = { version = "2.17", features = ["with-bytes"], optional = true }
protobuf = { version = "3.3", features = ["bytes"], optional = true }

[dev-dependencies]
compact_str = { version = "0.5", features = ["serde"] }
Expand Down
4 changes: 2 additions & 2 deletions pb-test/pb_test_gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ pb-jelly-gen = { path = "../../pb-jelly-gen" }
# only used when benchmarking PROST!
prost-build = { version = "0.6", optional = true }
# only used when benchmarking rust-protobuf
protoc-rust = { version = "2.17", optional = true }
protobuf-codegen = { version = "3.3", optional = true }

[features]
bench_prost = ["prost-build"]
bench_rust_protobuf = ["protoc-rust"]
bench_rust_protobuf = ["protobuf-codegen"]

# Override pb-jelly dependency for generated crates as well
[patch.crates-io]
Expand Down
18 changes: 9 additions & 9 deletions pb-test/pb_test_gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use pb_jelly_gen::GenProtos;
#[cfg(feature = "bench_prost")]
use prost_build;
#[cfg(feature = "bench_rust_protobuf")]
use protoc_rust::Customize;
use protobuf_codegen::Customize;

fn main() -> std::io::Result<()> {
// Tell Cargo only re-run our build script if something in protos changes
Expand Down Expand Up @@ -38,19 +38,19 @@ fn main() -> std::io::Result<()> {
// compile the protos we use for bench marking, if we want to benchmark against rust_protobuf
if cfg!(feature = "bench_rust_protobuf") {
let mut crate_path = env!("CARGO_MANIFEST_DIR").to_owned();
crate_path.push_str("/../gen/rust_protobuf");
crate_path.push_str("/../src/gen/rust_protobuf");
fs::create_dir_all(&crate_path)?;

#[cfg(feature = "bench_rust_protobuf")]
protoc_rust::Codegen::new()
.out_dir("../gen/rust_protobuf")
.inputs(&["../proto/packages/pbtest/bench.proto"])
protobuf_codegen::Codegen::new()
.out_dir("../src/gen/rust_protobuf")
.inputs(&[
"../proto/packages/pbtest/bench.proto",
"../../pb-jelly-gen/proto/rust/extensions.proto",
])
.include("../../pb-jelly-gen/proto")
.include("../proto/packages")
.customize(Customize {
carllerche_bytes_for_bytes: Some(true),
..Default::default()
})
.customize(Customize::default().tokio_bytes(true))
.run()
.expect("failed to generate rust_protobuf protos!");
}
Expand Down
4 changes: 2 additions & 2 deletions pb-test/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ mod rust_protobuf {

b.iter(|| {
// Deserialize our proto
let mut input_stream = CodedInputStream::from_carllerche_bytes(&bytes_buf);
let mut input_stream = CodedInputStream::from_tokio_bytes(&bytes_buf);
let mut de_proto = BytesData::default();
de_proto
.merge_from(&mut input_stream)
Expand Down Expand Up @@ -344,7 +344,7 @@ mod rust_protobuf {

b.iter(|| {
// Deserialize our proto
let mut input_stream = CodedInputStream::from_carllerche_bytes(&bytes_buf);
let mut input_stream = CodedInputStream::from_tokio_bytes(&bytes_buf);
let mut de_proto = StringMessage::default();
de_proto
.merge_from(&mut input_stream)
Expand Down
2 changes: 1 addition & 1 deletion pb-test/src/gen/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Why does this module exist?

When trying to include generated code from [`protoc-rust`](https://github.com/stepancheg/rust-protobuf/tree/master/protoc-rust) in the same fashion as `PROST!`, e.g.
When trying to include generated code from [`protobuf-codegen`](https://github.com/stepancheg/rust-protobuf/tree/master/protobuf-codegen) in the same fashion as `PROST!`, e.g.
```
mod gen {
include!(concat!(env!("CARGO_MANIFEST_DIR"), "/gen/prost/pbtest.rs"));
Expand Down
Loading

0 comments on commit 662f46b

Please sign in to comment.