Skip to content

Commit

Permalink
benches: add Field::mul_assign
Browse files Browse the repository at this point in the history
Signed-off-by: ljedrz <[email protected]>
  • Loading branch information
ljedrz committed May 24, 2024
1 parent de15609 commit bd08b25
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions circuit/types/field/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ description = "Field circuit for a decentralized virtual machine"
license = "Apache-2.0"
edition = "2021"

[[bench]]
name = "mul"
path = "benches/mul.rs"
harness = false

[dependencies.console]
package = "snarkvm-console-types-field"
path = "../../../console/types/field"
Expand All @@ -20,6 +25,9 @@ version = "=0.16.19"
path = "../boolean"
version = "=0.16.19"

[dev-dependencies.criterion]
version = "0.5"

[features]
default = [ "enable_console" ]
enable_console = [ "console" ]
41 changes: 41 additions & 0 deletions circuit/types/field/benches/mul.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (C) 2019-2023 Aleo Systems Inc.
// This file is part of the snarkVM library.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[macro_use]
extern crate criterion;

use snarkvm_circuit_environment::*;
use snarkvm_circuit_types_field::Field;

use criterion::Criterion;

fn bench_mul(c: &mut Criterion) {
c.bench_function("Field::mul_assign", move |b| {
let one = Field::<Circuit>::one();
let two = one.clone() + &one;
let mut base = two.clone();

b.iter(|| {
base *= &two;
})
});
}

criterion_group! {
name = mul;
config = Criterion::default();
targets = bench_mul
}

criterion_main!(mul);

0 comments on commit bd08b25

Please sign in to comment.