Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #2102 from ethcore/import-stats
Browse files Browse the repository at this point in the history
Import command summary
  • Loading branch information
rphmeier authored Sep 16, 2016
2 parents f8f39c4 + 0124f98 commit 851b639
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
22 changes: 17 additions & 5 deletions parity/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -108,6 +108,8 @@ pub fn execute(cmd: BlockchainCmd) -> Result<String, String> {
}

fn execute_import(cmd: ImportBlockchain) -> Result<String, String> {
let timer = Instant::now();

// Setup panic handler
let panic_handler = PanicHandler::new_in_arc();

Expand Down Expand Up @@ -218,8 +220,18 @@ fn execute_import(cmd: ImportBlockchain) -> Result<String, String> {
}
}
client.flush_queue();

Ok("Import completed.".into())
let report = client.report();

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<String, String> {
Expand Down
4 changes: 3 additions & 1 deletion parity/informant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ pub struct Informant {
skipped: AtomicUsize,
}

trait MillisecondDuration {
/// Something that can be converted to milliseconds.
pub trait MillisecondDuration {
/// Get the value in milliseconds.
fn as_milliseconds(&self) -> u64;
}

Expand Down

0 comments on commit 851b639

Please sign in to comment.