Skip to content

Commit

Permalink
Refactor performance to try to keep consistent with previous bencher …
Browse files Browse the repository at this point in the history
…records

The `definitions` test name is now a bit misleading since no definitions are
retrieved there, but it's still where user source files are ingested.
  • Loading branch information
ggiraldez authored and OmarTawfik committed Dec 27, 2024
1 parent 2d43da0 commit f79b528
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
5 changes: 2 additions & 3 deletions crates/solidity/testing/perf/benches/iai/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
#![allow(clippy::needless_pass_by_value)]

use std::hint::black_box;
use std::rc::Rc;

use iai_callgrind::{
library_benchmark, library_benchmark_group, main, Direction, FlamegraphConfig,
LibraryBenchmarkConfig, Tool, ValgrindTool,
};
use slang_solidity::bindings::BindingGraph;
use slang_solidity::bindings::BindingGraphBuilder;
use solidity_testing_perf::dataset::SourceFile;
use solidity_testing_perf::tests::definitions::Dependencies;
use solidity_testing_perf::tests::parser::ParsedFile;
Expand Down Expand Up @@ -46,7 +45,7 @@ define_payload_benchmark!(cursor, Vec<ParsedFile>);
define_payload_benchmark!(query, Vec<ParsedFile>);
define_benchmark!(init_bindings);
define_payload_benchmark!(definitions, Dependencies);
define_payload_benchmark!(references, Rc<BindingGraph>);
define_payload_benchmark!(references, BindingGraphBuilder);

library_benchmark_group!(
name = benchmarks;
Expand Down
16 changes: 3 additions & 13 deletions crates/solidity/testing/perf/src/tests/definitions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use std::rc::Rc;

use slang_solidity::bindings::{BindingGraph, BindingGraphBuilder};
use slang_solidity::bindings::BindingGraphBuilder;

use crate::tests::parser::ParsedFile;

Expand All @@ -19,7 +17,7 @@ pub fn setup() -> Dependencies {
}
}

pub fn run(dependencies: Dependencies) -> Rc<BindingGraph> {
pub fn run(dependencies: Dependencies) -> BindingGraphBuilder {
let Dependencies {
mut binding_graph_builder,
files,
Expand All @@ -35,13 +33,5 @@ pub fn run(dependencies: Dependencies) -> Rc<BindingGraph> {
.add_user_file(path.to_str().unwrap(), parse_output.create_tree_cursor());
}

let binding_graph = binding_graph_builder.resolve();
let definition_count = binding_graph
.all_definitions()
.filter(|definition| definition.get_file().is_user())
.count();

assert_eq!(definition_count, 882, "Failed to fetch all definitions");

binding_graph
binding_graph_builder
}
17 changes: 12 additions & 5 deletions crates/solidity/testing/perf/src/tests/references.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
use std::rc::Rc;
use slang_solidity::bindings::BindingGraphBuilder;

use slang_solidity::bindings::BindingGraph;

pub fn setup() -> Rc<BindingGraph> {
pub fn setup() -> BindingGraphBuilder {
let dependencies = super::definitions::setup();

super::definitions::run(dependencies)
}

pub fn run(binding_graph: Rc<BindingGraph>) {
pub fn run(binding_graph_builder: BindingGraphBuilder) {
let binding_graph = binding_graph_builder.resolve();

let definition_count = binding_graph
.all_definitions()
.filter(|definition| definition.get_file().is_user())
.count();

assert_eq!(definition_count, 882, "Failed to fetch all definitions");

let mut reference_count = 0_usize;
let mut resolved_references = 0_usize;

Expand Down

0 comments on commit f79b528

Please sign in to comment.