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

Test codspeed #1738

Merged
merged 3 commits into from
Apr 21, 2024
Merged
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
34 changes: 34 additions & 0 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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)
working-directory: ./benchmarks
run: cargo codspeed build

- name: Run the benchmarks
uses: CodSpeedHQ/action@v2
with:
working-directory: ./benchmarks
run: cargo codspeed run
token: ${{ secrets.CODSPEED_TOKEN }}
3 changes: 3 additions & 0 deletions benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ harness = false
name = "json_streaming"
path = "benches/json_streaming.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::{tag, take_while1}, character:: char, multi::many, OutputMode, Parser, PResult, error::Error, Mode, sequence::{preceded, delimited, separated_pair, terminated, pair}, OutputM, Emit, Complete};

#[cfg_attr(rustfmt, rustfmt_skip)]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benches/http_streaming.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::streaming::{tag, take_while1}, character::streaming::{line_ending, char}, multi::many, Parser};

#[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
7 changes: 2 additions & 5 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::{tag, take},
Expand Down Expand Up @@ -304,7 +301,7 @@ fn verbose_json(c: &mut Criterion) {
.unwrap();

// println!("data:\n{:?}", json(data));
c.bench_function("json vebose", |b| {
c.bench_function("json verbose", |b| {
b.iter(|| {
json::<VerboseError<&str>>()
.process::<OutputM<Emit, Emit, Complete>>(data)
Expand Down
5 changes: 1 addition & 4 deletions benchmarks/benches/json_streaming.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::streaming::{tag, take},
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
Loading