Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Pass compile time to solc_success/on_solc_success
Browse files Browse the repository at this point in the history
  • Loading branch information
ecmendenhall committed Mar 31, 2022
1 parent f402f13 commit b4991f9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
8 changes: 5 additions & 3 deletions ethers-solc/src/compile/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ use crate::{
use rayon::prelude::*;

use crate::filter::SparseOutputFileFilter;
use std::{collections::btree_map::BTreeMap, path::PathBuf};
use std::{collections::btree_map::BTreeMap, path::PathBuf, time::Instant};

#[derive(Debug)]
pub struct ProjectCompiler<'a, T: ArtifactOutput> {
Expand Down Expand Up @@ -457,9 +457,10 @@ fn compile_sequential(
input.sources.keys()
);

let start = Instant::now();
report::solc_spawn(&solc, &version, &input, &actually_dirty);
let output = solc.compile_exact(&input)?;
report::solc_success(&solc, &version, &output);
report::solc_success(&solc, &version, &output, &start.elapsed());
tracing::trace!("compiled input, output has error: {}", output.has_error());
tracing::trace!("received compiler output: {:?}", output.contracts.keys());
aggregated.extend(version.clone(), output);
Expand Down Expand Up @@ -542,9 +543,10 @@ fn compile_parallel(
input.sources.len(),
input.sources.keys()
);
let start = Instant::now();
report::solc_spawn(&solc, &version, &input, &actually_dirty);
solc.compile(&input).map(move |output| {
report::solc_success(&solc, &version, &output);
report::solc_success(&solc, &version, &output, &start.elapsed());
(version, output)
})
})
Expand Down
19 changes: 16 additions & 3 deletions ethers-solc/src/report/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use std::{
atomic::{AtomicBool, AtomicUsize, Ordering},
Arc,
},
time::Duration,
};

mod compiler;
Expand Down Expand Up @@ -115,7 +116,14 @@ pub trait Reporter: 'static {
}

/// Invoked with the `CompilerOutput` if [`Solc::compile()`] was successful
fn on_solc_success(&self, _solc: &Solc, _version: &Version, _output: &CompilerOutput) {}
fn on_solc_success(
&self,
_solc: &Solc,
_version: &Version,
_output: &CompilerOutput,
_duration: &Duration,
) {
}

/// Invoked before a new [`Solc`] bin is installed
fn on_solc_installation_start(&self, _version: &Version) {}
Expand Down Expand Up @@ -181,8 +189,13 @@ pub(crate) fn solc_spawn(
get_default(|r| r.reporter.on_solc_spawn(solc, version, input, dirty_files));
}

pub(crate) fn solc_success(solc: &Solc, version: &Version, output: &CompilerOutput) {
get_default(|r| r.reporter.on_solc_success(solc, version, output));
pub(crate) fn solc_success(
solc: &Solc,
version: &Version,
output: &CompilerOutput,
duration: &Duration,
) {
get_default(|r| r.reporter.on_solc_success(solc, version, output, duration));
}

#[allow(unused)]
Expand Down

0 comments on commit b4991f9

Please sign in to comment.