mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 11:07:56 +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:
@@ -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