diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1e6fea3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,46 @@ +name: CI + +on: + workflow_dispatch: + push: + branches: + - main + - dev + paths: + - 'src/**' + - 'Cargo.toml' + - 'Cargo.lock' + pull_request: + paths: + - 'src/**' + - 'Cargo.toml' + - 'Cargo.lock' + +# Common environment variables +env: + RUSTFLAGS: "-C debuginfo=1" + CARGO_TERM_COLOR: always + RUST_BACKTRACE: "1" + LOCK_FILE: Cargo.lock + +jobs: + style-check: + name: style-check + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy, rustfmt + - name: Run Style Check + run: | + make ci + + - name: Run + run: | + make run + + - name: Check git status + run: | + git diff --exit-code diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0b82a90 --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ + +ci: fmt clippy + +clippy: + cargo clippy --all-targets --all-features + +fmt: + cargo fmt -- --check + +run: + cargo run --release diff --git a/README.md b/README.md index 84dbaa3..61914a4 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,6 @@ # Serialization-benchmark-rs Benchmark for serialization in Rust, https://github.com/apache/incubator-horaedb/issues/1515. -# Related projects -- https://github.com/CeresDB/hash-benchmark-rs - - # Usage ```sh []# serialization-benchmark-rs --help @@ -17,8 +13,8 @@ Options: -V, --version Print version -[]# ./serialization-benchmark-rs -Benchmark test, batch_size=1000000, result: +[]# ./serialization-benchmark-rs +Benchmark test, batch_size=1000000, result: +------------+----------------+------------------+-------------+ | name | serialize time | deserialize time | cpu_utility | @@ -28,7 +24,7 @@ Benchmark test, batch_size=1000000, result: +------------+----------------+------------------+-------------+ []# ./serialization-benchmark-rs --batch-size 5000000 -Benchmark test, batch_size=5000000, result: +Benchmark test, batch_size=5000000, result: +------------+----------------+------------------+-------------+ | name | serialize time | deserialize time | cpu_utility | @@ -38,7 +34,7 @@ Benchmark test, batch_size=5000000, result: +------------+----------------+------------------+-------------+ []# ./serialization-benchmark-rs --enable-unsafe -Benchmark test, batch_size=1000000, result: +Benchmark test, batch_size=1000000, result: +------------+----------------+------------------+-------------+ | name | serialize time | deserialize time | cpu_utility | @@ -48,3 +44,6 @@ Benchmark test, batch_size=1000000, result: +------------+----------------+------------------+-------------+ ``` + +# Related projects +- https://github.com/CeresDB/hash-benchmark-rs diff --git a/src/main.rs b/src/main.rs old mode 100644 new mode 100755 index c581145..2d9f4f7 --- a/src/main.rs +++ b/src/main.rs @@ -14,10 +14,10 @@ use sysinfo::{CpuRefreshKind, RefreshKind, System}; #[derive(Parser)] #[clap(author, version, about, long_about = None)] struct Args { - #[clap(default_value = "1000000", long, env)] + #[clap(long, short('b'), default_value = "1000000")] batch_size: usize, - #[arg(long, env, help = "use unsafe feature within flatbuffer")] + #[arg(long, short('u'), help = "use unsafe feature within flatbuffer")] enable_unsafe: bool, } @@ -140,4 +140,3 @@ fn main() { table.printstd(); } - diff --git a/src/util.rs b/src/util.rs index d05ff1c..401ced2 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,4 +1,5 @@ extern crate flatbuffers; +#[rustfmt::skip] mod fbperson_generated; mod pbperson; use fbperson_generated::fbdemo::{FBPerson, FBPersonArgs, FBPet, FBPetArgs}; @@ -175,4 +176,3 @@ impl Serializable for ProtobufObject { context.duration.1 += start_time.elapsed(); } } -