mirror of
https://github.com/arnaucube/sonobe-playground.git
synced 2026-01-13 17:41:28 +01:00
Improve logging
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
use std::io;
|
||||
use std::{io, time::Instant};
|
||||
|
||||
use tracing::level_filters::LevelFilter;
|
||||
use tracing::{info, level_filters::LevelFilter};
|
||||
use tracing_subscriber::{EnvFilter, fmt::format::FmtSpan};
|
||||
|
||||
pub fn measure<T, Action: FnOnce() -> T>(action_name: &str, action: Action) -> T {
|
||||
let start = Instant::now();
|
||||
let result = action();
|
||||
info!("{action_name}: {:?}", start.elapsed());
|
||||
result
|
||||
}
|
||||
|
||||
fn get_filter() -> EnvFilter {
|
||||
EnvFilter::builder()
|
||||
.with_default_directive(LevelFilter::WARN.into())
|
||||
@@ -14,9 +21,8 @@ pub fn init_logging() {
|
||||
tracing_subscriber::fmt()
|
||||
.with_writer(io::stdout)
|
||||
.with_target(false)
|
||||
.without_time()
|
||||
.with_env_filter(get_filter())
|
||||
.with_span_events(FmtSpan::ENTER | FmtSpan::CLOSE)
|
||||
.with_span_events(FmtSpan::CLOSE)
|
||||
.with_level(false)
|
||||
.json()
|
||||
.try_init()
|
||||
|
||||
29
src/main.rs
29
src/main.rs
@@ -1,12 +1,10 @@
|
||||
use std::time::Instant;
|
||||
|
||||
use scenario_config::ScenarioConfig;
|
||||
use tracing::info;
|
||||
|
||||
use crate::{
|
||||
folding::{prepare_folding, verify_folding, FoldingSchemeExt, HyperNovaFolding, NovaFolding},
|
||||
logging::init_logging,
|
||||
};
|
||||
use crate::logging::measure;
|
||||
|
||||
mod circuit;
|
||||
mod logging;
|
||||
@@ -15,14 +13,12 @@ mod folding;
|
||||
mod input;
|
||||
mod scenario_config;
|
||||
|
||||
fn measure<T, Action: FnOnce() -> T>(action_name: &str, action: Action) -> T {
|
||||
let start = Instant::now();
|
||||
let result = action();
|
||||
info!("{action_name}: {:?}", start.elapsed());
|
||||
result
|
||||
}
|
||||
|
||||
fn scenario<FS: FoldingSchemeExt>(config: ScenarioConfig, rng: &mut impl rand::RngCore) {
|
||||
#[tracing::instrument(skip(config, rng))]
|
||||
fn scenario<FS: FoldingSchemeExt>(
|
||||
config: ScenarioConfig,
|
||||
rng: &mut impl rand::RngCore,
|
||||
folding_scheme: &str,
|
||||
) {
|
||||
// ============== FOLDING PREPARATION ==========================================================
|
||||
|
||||
let start_state = config.start_ivc_state.clone();
|
||||
@@ -65,12 +61,7 @@ fn main() {
|
||||
let mut rng = rand::rngs::OsRng;
|
||||
let config = ScenarioConfig::new();
|
||||
|
||||
println!("========== Nova folding scheme ====================");
|
||||
scenario::<NovaFolding>(config.clone(), &mut rng);
|
||||
|
||||
println!("========== HyperNova<1,1> folding scheme ==========");
|
||||
scenario::<HyperNovaFolding<1, 1>>(config.clone(), &mut rng);
|
||||
|
||||
println!("========== HyperNova<2,2> folding scheme ==========");
|
||||
scenario::<HyperNovaFolding<2, 2>>(config, &mut rng);
|
||||
scenario::<NovaFolding>(config.clone(), &mut rng, "Nova");
|
||||
scenario::<HyperNovaFolding<1, 1>>(config.clone(), &mut rng, "HyperNova<1,1>");
|
||||
scenario::<HyperNovaFolding<2, 2>>(config.clone(), &mut rng, "HyperNova<2,2>");
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ use ark_bn254::Fr;
|
||||
use num_traits::Zero;
|
||||
use sonobe::frontend::circom::CircomFCircuit;
|
||||
|
||||
use crate::{circuit::create_circuit, input::prepare_input, measure};
|
||||
use crate::{circuit::create_circuit, input::prepare_input};
|
||||
use crate::logging::measure;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ScenarioConfig {
|
||||
|
||||
Reference in New Issue
Block a user