From cc845c61d3dcb6a4a6f62c7826e7141bd2611fb7 Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 15 Sep 2016 16:56:10 +0200 Subject: [PATCH 1/2] Import summary --- parity/blockchain.rs | 20 ++++++++++++++++---- parity/informant.rs | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/parity/blockchain.rs b/parity/blockchain.rs index 05f2a6f4f..72215ca59 100644 --- a/parity/blockchain.rs +++ b/parity/blockchain.rs @@ -17,20 +17,20 @@ use std::str::{FromStr, from_utf8}; use std::{io, fs}; use std::io::{BufReader, BufRead}; -use std::time::Duration; +use std::time::{Instant, Duration}; use std::thread::sleep; use std::sync::Arc; use rustc_serialize::hex::FromHex; use ethcore_logger::{setup_log, Config as LogConfig}; use io::{PanicHandler, ForwardPanic}; -use util::ToPretty; +use util::{ToPretty, Uint}; use rlp::PayloadInfo; use ethcore::service::ClientService; use ethcore::client::{Mode, DatabaseCompactionProfile, Switch, VMType, BlockImportError, BlockChainClient, BlockID}; use ethcore::error::ImportError; use ethcore::miner::Miner; use cache::CacheConfig; -use informant::Informant; +use informant::{Informant, MillisecondDuration}; use io_handler::ImportIoHandler; use params::{SpecType, Pruning}; use helpers::{to_client_config, execute_upgrades}; @@ -108,6 +108,8 @@ pub fn execute(cmd: BlockchainCmd) -> Result { } fn execute_import(cmd: ImportBlockchain) -> Result { + let timer = Instant::now(); + // Setup panic handler let panic_handler = PanicHandler::new_in_arc(); @@ -218,8 +220,18 @@ fn execute_import(cmd: ImportBlockchain) -> Result { } } client.flush_queue(); + let report = client.report(); - Ok("Import completed.".into()) + let ms = timer.elapsed().as_milliseconds(); + Ok(format!("Import completed in {} seconds, {} blocks, {} blk/s, {} transactions, {} tx/s, {} Mgas, {} Mgas/s", + ms / 1000, + report.blocks_imported, + (report.blocks_imported * 1000) as u64 / ms, + report.transactions_applied, + (report.transactions_applied * 1000) as u64 / ms, + report.gas_processed / From::from(1_000_000), + (report.gas_processed / From::from(ms * 1000)).low_u64(), + ).into()) } fn execute_export(cmd: ExportBlockchain) -> Result { diff --git a/parity/informant.rs b/parity/informant.rs index 58accd140..7f0534145 100644 --- a/parity/informant.rs +++ b/parity/informant.rs @@ -41,7 +41,7 @@ pub struct Informant { skipped: AtomicUsize, } -trait MillisecondDuration { +pub trait MillisecondDuration { fn as_milliseconds(&self) -> u64; } From 0124f985c3bea061d0c51392edaf378c3d4c597e Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 16 Sep 2016 12:18:27 +0200 Subject: [PATCH 2/2] Added docs --- parity/informant.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/parity/informant.rs b/parity/informant.rs index 7f0534145..f2cc41f64 100644 --- a/parity/informant.rs +++ b/parity/informant.rs @@ -41,7 +41,9 @@ pub struct Informant { skipped: AtomicUsize, } +/// Something that can be converted to milliseconds. pub trait MillisecondDuration { + /// Get the value in milliseconds. fn as_milliseconds(&self) -> u64; }