-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into remove-keys-from-artifact
* master: chore: Reuse workspace target directory in wasm build script (#2312) feat(nargo): Add `--workspace` flag to run commands in every package (#2313) chore(frontend): Replace `ModuleOrigin` with `Location` on `ModuleData` (#2308) fix: Fix 3 parser test cases in parsing (#2284) fix: Require package names to be non-empty (#2293) fix(nargo)!: Remove `-p` short flag from the `--program-dir` flag (#2300) feat: optionally output a debug artifact on compile (#2260) chore: `nargo info` now prints information as a prettified table (#2282) fix(lsp): Pass `--program-dir` to test command from codelens (#2292) fix(nargo): Allow `--program-dir` flag anywhere in a command (#2290) feat: Execute brillig opcodes with constant inputs at compile-time (#2190) feat: Add basic benchmarking (#2213) feat: Include struct names in ABIs (#2266) feat(nargo): Add `--exact` flag to `nargo test` (#2272)
- Loading branch information
Showing
97 changed files
with
1,242 additions
and
242 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use noirc_errors::debug_info::DebugInfo; | ||
use serde::{Deserialize, Serialize}; | ||
use std::{ | ||
collections::{BTreeMap, BTreeSet}, | ||
path::PathBuf, | ||
}; | ||
|
||
use fm::FileId; | ||
use noirc_frontend::hir::Context; | ||
|
||
/// For a given file, we store the source code and the path to the file | ||
/// so consumers of the debug artifact can reconstruct the original source code structure. | ||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct DebugFile { | ||
pub source: String, | ||
pub path: PathBuf, | ||
} | ||
|
||
/// A Debug Artifact stores, for a given program, the debug info for every function | ||
/// along with a map of file Id to the source code so locations in debug info can be mapped to source code they point to. | ||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct DebugArtifact { | ||
pub debug_symbols: Vec<DebugInfo>, | ||
pub file_map: BTreeMap<FileId, DebugFile>, | ||
} | ||
|
||
impl DebugArtifact { | ||
pub fn new(debug_symbols: Vec<DebugInfo>, compilation_context: &Context) -> Self { | ||
let mut file_map = BTreeMap::new(); | ||
|
||
let files_with_debug_symbols: BTreeSet<FileId> = debug_symbols | ||
.iter() | ||
.flat_map(|function_symbols| function_symbols.locations.values().map(|loc| loc.file)) | ||
.collect(); | ||
|
||
for file_id in files_with_debug_symbols { | ||
let file_source = compilation_context.file_manager.fetch_file(file_id).source(); | ||
|
||
file_map.insert( | ||
file_id, | ||
DebugFile { | ||
source: file_source.to_string(), | ||
path: compilation_context.file_manager.path(file_id).to_path_buf(), | ||
}, | ||
); | ||
} | ||
|
||
Self { debug_symbols, file_map } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//! Select representative tests to bench with criterion | ||
use assert_cmd::prelude::{CommandCargoExt, OutputAssertExt}; | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use paste::paste; | ||
use pprof::criterion::{Output, PProfProfiler}; | ||
use std::process::Command; | ||
include!("./utils.rs"); | ||
|
||
macro_rules! criterion_command { | ||
($command_name:tt, $command_string:expr) => { | ||
paste! { | ||
fn [<criterion_selected_tests_ $command_name>](c: &mut Criterion) { | ||
let test_program_dirs = get_selected_tests(); | ||
for test_program_dir in test_program_dirs { | ||
let mut cmd = Command::cargo_bin("nargo").unwrap(); | ||
cmd.arg("--program-dir").arg(&test_program_dir); | ||
cmd.arg($command_string); | ||
|
||
c.bench_function(&format!("{}_{}", test_program_dir.file_name().unwrap().to_str().unwrap(), $command_string), |b| { | ||
b.iter(|| cmd.assert()) | ||
}); | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
criterion_command!(execution, "execute"); | ||
criterion_group! { | ||
name = benches; | ||
config = Criterion::default().sample_size(20).with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))); | ||
targets = criterion_selected_tests_execution | ||
} | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//! Select representative tests to bench with iai | ||
use assert_cmd::prelude::{CommandCargoExt, OutputAssertExt}; | ||
use iai::black_box; | ||
use paste::paste; | ||
use std::process::Command; | ||
include!("./utils.rs"); | ||
|
||
macro_rules! iai_command { | ||
($command_name:tt, $command_string:expr) => { | ||
paste! { | ||
fn [<iai_selected_tests_ $command_name>]() { | ||
let test_program_dirs = get_selected_tests(); | ||
for test_program_dir in test_program_dirs { | ||
let mut cmd = Command::cargo_bin("nargo").unwrap(); | ||
cmd.arg("--program-dir").arg(&test_program_dir); | ||
cmd.arg($command_string); | ||
|
||
black_box(cmd.assert()); | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
iai_command!(execution, "execute"); | ||
iai::main!(iai_selected_tests_execution); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use std::path::PathBuf; | ||
|
||
#[allow(unused)] | ||
fn get_selected_tests() -> Vec<PathBuf> { | ||
let manifest_dir = match std::env::var("CARGO_MANIFEST_DIR") { | ||
Ok(dir) => PathBuf::from(dir), | ||
Err(_) => std::env::current_dir().unwrap().join("crates").join("nargo_cli"), | ||
}; | ||
let test_dir = manifest_dir.join("tests").join("execution_success"); | ||
|
||
let selected_tests = | ||
vec!["8_integration", "sha256_blocks", "struct", "eddsa", "regression", "regression_2099"]; | ||
selected_tests.into_iter().map(|t| test_dir.join(t)).collect() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.