Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7.1.2 benchmark #1759

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
- stable
- beta
- nightly
- 1.48.0

features:
- ''
Expand Down Expand Up @@ -65,29 +64,7 @@ jobs:
command: test
args: --verbose ${{ matrix.features }}

minrust:
name: Test minimal rust version
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install rust (${{ env.RUST_MINVERSION }})
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_MINVERSION }}
profile: minimal
override: true

- name: Cache
uses: Swatinem/rust-cache@v1

- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --verbose --no-default-features --features "alloc,std"


bench:
name: Bench
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: codspeed-benchmarks

on:
push:
branches:
- "main"
pull_request:
# `workflow_dispatch` allows CodSpeed to trigger backtest
# performance analysis in order to generate initial data.
workflow_dispatch:

jobs:
benchmarks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup rust toolchain, cache and cargo-codspeed binary
uses: moonrepo/setup-rust@v0
with:
channel: stable
cache-target: release
bins: cargo-codspeed

- name: Build the benchmark target(s)
run: cargo codspeed build -p benchmarks

- name: Run the benchmarks
uses: CodSpeedHQ/action@v2
with:
run: cargo codspeed run -p benchmarks
token: ${{ secrets.CODSPEED_TOKEN }}
4 changes: 4 additions & 0 deletions benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ harness = false
name = "json"
path = "benches/json.rs"
harness = false


[dev-dependencies]
codspeed-criterion-compat = "2.4.1"
5 changes: 1 addition & 4 deletions benchmarks/benches/arithmetic.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#[macro_use]
extern crate criterion;

#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

use criterion::Criterion;
use codspeed_criterion_compat::{criterion_group, criterion_main, Criterion};
use nom::{
branch::alt,
character::complete::{char, digit1, one_of, space0},
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benches/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

use criterion::*;
use codspeed_criterion_compat::*;
use nom::{IResult, bytes::complete::{tag, take_while1}, character::complete::{line_ending, char}, multi::many1};

#[cfg_attr(rustfmt, rustfmt_skip)]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benches/ini.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

use criterion::*;
use codspeed_criterion_compat::*;

use nom::{
bytes::complete::take_while,
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benches/ini_str.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

use criterion::*;
use codspeed_criterion_compat::*;

use nom::{
bytes::complete::{is_a, tag, take_till, take_while},
Expand Down
17 changes: 13 additions & 4 deletions benchmarks/benches/json.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#[macro_use]
extern crate criterion;

#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

use criterion::Criterion;
use codspeed_criterion_compat::*;
use nom::{
branch::alt,
bytes::complete::{tag, take},
Expand Down Expand Up @@ -151,6 +148,17 @@ fn json_bench(c: &mut Criterion) {
});
}

static CANADA: &str = include_str!("../canada.json");
fn canada_json(c: &mut Criterion) {
// test once to make sure it parses correctly
json(CANADA).unwrap();

// println!("data:\n{:?}", json(data));
c.bench_function("json canada", |b| {
b.iter(|| json(CANADA).unwrap());
});
}

fn recognize_float_bytes(c: &mut Criterion) {
println!(
"recognize_float_bytes result: {:?}",
Expand Down Expand Up @@ -216,6 +224,7 @@ fn std_float_bytes(c: &mut Criterion) {
criterion_group!(
benches,
json_bench,
canada_json,
recognize_float_bytes,
recognize_float_str,
float_bytes,
Expand Down
5 changes: 1 addition & 4 deletions benchmarks/benches/number.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#[macro_use]
extern crate criterion;

#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

use criterion::Criterion;
use codspeed_criterion_compat::*;
use nom::number::complete;

fn parser(i: &[u8]) -> nom::IResult<&[u8], u64> {
Expand Down
9 changes: 9 additions & 0 deletions benchmarks/canada.json

Large diffs are not rendered by default.

Loading