[informant]: MillisecondDuration
-> as_millis()
(#11211)
* [informant]: `MillisecondDuration` -> `as_millis()` This commit removes the trait `MillisecondDuration` and replaces it with `Duration::as_millis` instead * [grumble]: extract `elapsed()` to variable
This commit is contained in:
parent
e0e79fdee0
commit
293e06e0f4
@ -33,7 +33,7 @@ use ethcore::{
|
|||||||
};
|
};
|
||||||
use ethcore_service::ClientService;
|
use ethcore_service::ClientService;
|
||||||
use cache::CacheConfig;
|
use cache::CacheConfig;
|
||||||
use informant::{Informant, FullNodeInformantData, MillisecondDuration};
|
use informant::{Informant, FullNodeInformantData};
|
||||||
use params::{SpecType, Pruning, Switch, tracing_switch_to_bool, fatdb_switch_to_bool};
|
use params::{SpecType, Pruning, Switch, tracing_switch_to_bool, fatdb_switch_to_bool};
|
||||||
use helpers::{to_client_config, execute_upgrades};
|
use helpers::{to_client_config, execute_upgrades};
|
||||||
use dir::Directories;
|
use dir::Directories;
|
||||||
@ -294,13 +294,13 @@ fn execute_import_light(cmd: ImportBlockchain) -> Result<(), String> {
|
|||||||
}
|
}
|
||||||
client.flush_queue();
|
client.flush_queue();
|
||||||
|
|
||||||
let ms = timer.elapsed().as_milliseconds();
|
let elapsed = timer.elapsed();
|
||||||
let report = client.report();
|
let report = client.report();
|
||||||
|
|
||||||
info!("Import completed in {} seconds, {} headers, {} hdr/s",
|
info!("Import completed in {} seconds, {} headers, {} hdr/s",
|
||||||
ms / 1000,
|
elapsed.as_secs(),
|
||||||
report.blocks_imported,
|
report.blocks_imported,
|
||||||
(report.blocks_imported * 1000) as u64 / ms,
|
(report.blocks_imported as u128 * 1000) / elapsed.as_millis(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -415,16 +415,16 @@ fn execute_import(cmd: ImportBlockchain) -> Result<(), String> {
|
|||||||
user_defaults.save(&user_defaults_path)?;
|
user_defaults.save(&user_defaults_path)?;
|
||||||
|
|
||||||
let report = client.report();
|
let report = client.report();
|
||||||
|
let elapsed = timer.elapsed();
|
||||||
let ms = timer.elapsed().as_milliseconds();
|
let ms = timer.elapsed().as_millis();
|
||||||
info!("Import completed in {} seconds, {} blocks, {} blk/s, {} transactions, {} tx/s, {} Mgas, {} Mgas/s",
|
info!("Import completed in {} seconds, {} blocks, {} blk/s, {} transactions, {} tx/s, {} Mgas, {} Mgas/s",
|
||||||
ms / 1000,
|
elapsed.as_secs(),
|
||||||
report.blocks_imported,
|
report.blocks_imported,
|
||||||
(report.blocks_imported * 1000) as u64 / ms,
|
(report.blocks_imported as u128 * 1000) / ms,
|
||||||
report.transactions_applied,
|
report.transactions_applied,
|
||||||
(report.transactions_applied * 1000) as u64 / ms,
|
(report.transactions_applied as u128 * 1000) / ms,
|
||||||
report.gas_processed / 1_000_000,
|
report.gas_processed / 1_000_000,
|
||||||
(report.gas_processed / (ms * 1000)).low_u64(),
|
report.gas_processed / (ms * 1000),
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,12 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
extern crate ansi_term;
|
use std::sync::Arc;
|
||||||
use self::ansi_term::Colour::{White, Yellow, Green, Cyan, Blue};
|
|
||||||
use self::ansi_term::{Colour, Style};
|
|
||||||
|
|
||||||
use std::sync::{Arc};
|
|
||||||
use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering as AtomicOrdering};
|
use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering as AtomicOrdering};
|
||||||
use std::time::{Instant, Duration};
|
use std::time::{Instant, Duration};
|
||||||
|
|
||||||
|
use ansi_term::Colour::{White, Yellow, Green, Cyan, Blue};
|
||||||
|
use ansi_term::{Colour, Style};
|
||||||
use atty;
|
use atty;
|
||||||
use ethcore::client::Client;
|
use ethcore::client::Client;
|
||||||
use client_traits::{BlockInfo, ChainInfo, BlockChainClient, ChainNotify};
|
use client_traits::{BlockInfo, ChainInfo, BlockChainClient, ChainNotify};
|
||||||
@ -55,18 +53,6 @@ pub fn format_bytes(b: usize) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Something that can be converted to milliseconds.
|
|
||||||
pub trait MillisecondDuration {
|
|
||||||
/// Get the value in milliseconds.
|
|
||||||
fn as_milliseconds(&self) -> u64;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MillisecondDuration for Duration {
|
|
||||||
fn as_milliseconds(&self) -> u64 {
|
|
||||||
self.as_secs() * 1000 + self.subsec_nanos() as u64 / 1_000_000
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct CacheSizes {
|
struct CacheSizes {
|
||||||
sizes: ::std::collections::BTreeMap<&'static str, usize>,
|
sizes: ::std::collections::BTreeMap<&'static str, usize>,
|
||||||
@ -308,13 +294,13 @@ impl<T: InformantData> Informant<T> {
|
|||||||
paint(White.bold(), format!("{}", chain_info.best_block_hash)),
|
paint(White.bold(), format!("{}", chain_info.best_block_hash)),
|
||||||
if self.target.executes_transactions() {
|
if self.target.executes_transactions() {
|
||||||
format!("{} blk/s {} tx/s {} Mgas/s",
|
format!("{} blk/s {} tx/s {} Mgas/s",
|
||||||
paint(Yellow.bold(), format!("{:7.2}", (client_report.blocks_imported * 1000) as f64 / elapsed.as_milliseconds() as f64)),
|
paint(Yellow.bold(), format!("{:7.2}", (client_report.blocks_imported * 1000) as f64 / elapsed.as_millis() as f64)),
|
||||||
paint(Yellow.bold(), format!("{:6.1}", (client_report.transactions_applied * 1000) as f64 / elapsed.as_milliseconds() as f64)),
|
paint(Yellow.bold(), format!("{:6.1}", (client_report.transactions_applied * 1000) as f64 / elapsed.as_millis() as f64)),
|
||||||
paint(Yellow.bold(), format!("{:6.1}", (client_report.gas_processed / 1000).low_u64() as f64 / elapsed.as_milliseconds() as f64))
|
paint(Yellow.bold(), format!("{:6.1}", (client_report.gas_processed / 1000).low_u64() as f64 / elapsed.as_millis() as f64))
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
format!("{} hdr/s",
|
format!("{} hdr/s",
|
||||||
paint(Yellow.bold(), format!("{:6.1}", (client_report.blocks_imported * 1000) as f64 / elapsed.as_milliseconds() as f64))
|
paint(Yellow.bold(), format!("{:6.1}", (client_report.blocks_imported * 1000) as f64 / elapsed.as_millis() as f64))
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
paint(Green.bold(), format!("{:5}", queue_info.unverified_queue_size)),
|
paint(Green.bold(), format!("{:5}", queue_info.unverified_queue_size)),
|
||||||
@ -401,7 +387,7 @@ impl ChainNotify for Informant<FullNodeInformantData> {
|
|||||||
Colour::White.bold().paint(format!("{}", header_view.hash())),
|
Colour::White.bold().paint(format!("{}", header_view.hash())),
|
||||||
Colour::Yellow.bold().paint(format!("{}", block.transactions_count())),
|
Colour::Yellow.bold().paint(format!("{}", block.transactions_count())),
|
||||||
Colour::Yellow.bold().paint(format!("{:.2}", header_view.gas_used().low_u64() as f32 / 1000000f32)),
|
Colour::Yellow.bold().paint(format!("{:.2}", header_view.gas_used().low_u64() as f32 / 1000000f32)),
|
||||||
Colour::Purple.bold().paint(format!("{}", new_blocks.duration.as_milliseconds())),
|
Colour::Purple.bold().paint(format!("{}", new_blocks.duration.as_millis())),
|
||||||
Colour::Blue.bold().paint(format!("{:.2}", size as f32 / 1024f32)),
|
Colour::Blue.bold().paint(format!("{:.2}", size as f32 / 1024f32)),
|
||||||
if skipped > 0 {
|
if skipped > 0 {
|
||||||
format!(" + another {} block(s) containing {} tx(s)",
|
format!(" + another {} block(s) containing {} tx(s)",
|
||||||
|
Loading…
Reference in New Issue
Block a user