use std::concat; use std::str::FromStr; use criterion::{BenchmarkId, Criterion}; use radix_common::math::*; use crate::macros::QUICK; use crate::{bench_ops, ops_fn, ops_root_fn, process_op}; const ADD_OPERANDS: [(&str, &str); 4] = [ ( "1485492504343953926634900000000000000000.12312312312312", "1485492504343953926634900000000000000000.12312312312312", ), ( "-1485492504343953926634900000000000000000.12312312312312", "1485492504343953926634900000000000000000.12312312312312", ), ("1", "-1"), ( "-1485492504343953926634900000000000000000.12312312312312", "-1485492504343953926634900000000000000000.12312312312312", ), ]; const SUB_OPERANDS: [(&str, &str); 4] = [ ( "1485492504343953926634900000000000000000.12312312312312", "1485492504343953926634900000000000000000.12312312312312", ), ( "-1485492504343953926634900000000000000000.12312312312312", "1485492504343953926634900000000000000000.12312312312312", ), ("1", "-1"), ( "-1485492504343953926634900000000000000000.12312312312312", "-1485492504343953926634900000000000000000.12312312312312", ), ]; const MUL_OPERANDS: [(&str, &str); 4] = [ ( "2789604461865809771.854925043439539", "2789604461865809771.8549250434395392", ), ( "-2789604461865809771.854925043439539", "2789604461865809771.8549250434395392", ), ("63499233282.0282019728", "1312.31233"), ("-123123123123", "-1"), ]; const DIV_OPERANDS: [(&str, &str); 4] = [ ( "278960446186580977117.854925043439539", "278960446186580977117.8549250434395392", ), ( "-278960446186580977117.854925043439539", "278960446186580977117.8549250434395392", ), ("63499233282.0282019728", "1312.31233"), ("-123123123123", "-1"), ]; const ROOT_OPERANDS: [(&str, &str); 4] = [ ( "3138550867693340381917894711603833208051.177722232017256447", "17", ), ("12379879872423987.123123123", "13"), ("12379879872423987.123123123", "5"), ("9", "2"), ]; const POW_OPERANDS: [(&str, &str); 4] = [ ("12.123123123", "13"), ("1.123123123", "5"), ("4", "5"), ("9", "2"), ]; const TO_STRING_OPERANDS: [&str; 4] = [ "3138550867693340381917894711603833208051.177722232017256447", "-11237987890123090890328.1928379813", "12379879872423987.123123123", "9", ]; const FROM_STRING_OPERANDS: [&str; 4] = [ "3138550867693340381917894711603833208051.177722232017256447", "-11237987890123090890328.1928379813", "12379879872423987.123123123", "9", ]; ops_fn!(Decimal, checked_powi, i64, "clone"); ops_root_fn!(Decimal, checked_nth_root, "clone"); bench_ops!(Decimal, "add"); bench_ops!(Decimal, "sub"); bench_ops!(Decimal, "mul"); bench_ops!(Decimal, "div"); bench_ops!(Decimal, "root", u32); bench_ops!(Decimal, "pow", i64); bench_ops!(Decimal, "to_string"); bench_ops!(Decimal, "from_string");