v0.1.2
- add complexity rank, that allows to compare complexities one to another
Examples
Performance of O(n)
is better than O(n^3)
use big_o::{complexity, Name::Linear, Name::Cubic};
let linear = complexity("O(n)").unwrap();
assert_eq!(linear.name, Linear);
let cubic = complexity("O(n^3)").unwrap();
assert_eq!(cubic.name, Cubic);
assert!(linear.rank < cubic.rank);
Expect the result to be not worse than O(n^2)
// f(x) = gain * x ^ 2 + offset
let data = vec![(1., 1.), (2., 4.), (3., 9.), (4., 16.)];
let (complexity, _all) = big_o::infer_complexity(data).unwrap();
assert!(complexity.rank <= big_o::complexity("O(n^2)").unwrap().rank);