mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 22:07:58 +00:00
Migrate abandoned prettytable-rs to comfy-table (#11430)
* Migrate to comfy-table Signed-off-by: koushiro <koushiro.cqx@gmail.com> * disable the default features Signed-off-by: koushiro <koushiro.cqx@gmail.com>
This commit is contained in:
@@ -16,6 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
chrono = "0.4"
|
||||
clap = { version = "3.1.18", features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0" }
|
||||
comfy-table = { version = "5.0.1", default-features = false }
|
||||
handlebars = "4.2.2"
|
||||
hash-db = "0.15.2"
|
||||
hex = "0.4.3"
|
||||
@@ -26,7 +27,6 @@ lazy_static = "1.4.0"
|
||||
linked-hash-map = "0.5.4"
|
||||
log = "0.4.17"
|
||||
memory-db = "0.29.0"
|
||||
prettytable-rs = "0.8.0"
|
||||
rand = { version = "0.8.4", features = ["small_rng"] }
|
||||
rand_pcg = "0.3.1"
|
||||
serde = "1.0.136"
|
||||
|
||||
@@ -20,6 +20,12 @@
|
||||
|
||||
pub mod hardware;
|
||||
|
||||
use std::{boxed::Box, fs, path::Path};
|
||||
|
||||
use clap::Parser;
|
||||
use comfy_table::{Row, Table};
|
||||
use log::{error, info, warn};
|
||||
|
||||
use sc_cli::{CliConfiguration, Result, SharedParams};
|
||||
use sc_service::Configuration;
|
||||
use sc_sysinfo::{
|
||||
@@ -27,11 +33,6 @@ use sc_sysinfo::{
|
||||
benchmark_memory, benchmark_sr25519_verify, ExecutionLimit,
|
||||
};
|
||||
|
||||
use clap::Parser;
|
||||
use log::{error, info, warn};
|
||||
use prettytable::{cell, row, table};
|
||||
use std::{boxed::Box, fmt::Debug, fs, path::Path};
|
||||
|
||||
use crate::shared::check_build_profile;
|
||||
pub use hardware::{Metric, Requirement, Requirements, Throughput, SUBSTRATE_REFERENCE_HARDWARE};
|
||||
|
||||
@@ -160,7 +161,8 @@ impl MachineCmd {
|
||||
/// Prints a human-readable summary.
|
||||
fn print_summary(&self, requirements: Requirements, results: Vec<BenchResult>) -> Result<()> {
|
||||
// Use a table for nicer console output.
|
||||
let mut table = table!(["Category", "Function", "Score", "Minimum", "Result"]);
|
||||
let mut table = Table::new();
|
||||
table.set_header(["Category", "Function", "Score", "Minimum", "Result"]);
|
||||
// Count how many passed and how many failed.
|
||||
let (mut passed, mut failed) = (0, 0);
|
||||
for (requirement, result) in requirements.0.iter().zip(results.iter()) {
|
||||
@@ -217,15 +219,16 @@ impl MachineCmd {
|
||||
|
||||
impl BenchResult {
|
||||
/// Format [`Self`] as row that can be printed in a table.
|
||||
fn to_row(&self, req: &Requirement) -> prettytable::Row {
|
||||
fn to_row(&self, req: &Requirement) -> Row {
|
||||
let passed = if self.passed { "✅ Pass" } else { "❌ Fail" };
|
||||
row![
|
||||
req.metric.category(),
|
||||
req.metric.name(),
|
||||
vec![
|
||||
req.metric.category().into(),
|
||||
req.metric.name().into(),
|
||||
format!("{}", self.score),
|
||||
format!("{}", req.minimum),
|
||||
format!("{} ({: >5.1?} %)", passed, self.rel_score * 100.0)
|
||||
format!("{} ({: >5.1?} %)", passed, self.rel_score * 100.0),
|
||||
]
|
||||
.into()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user