big_o

Crates.iobig_o
lib.rsbig_o
version0.1.4
sourcesrc
created_at2022-06-16 14:58:12.583308
updated_at2022-10-21 14:28:53.352007
descriptionInfers asymptotic computational complexity
homepagehttps://github.com/maksym-arutyunyan/big_o
repositoryhttps://github.com/maksym-arutyunyan/big_o
max_upload_size
id607505
size68,428
Maksym Arutyunyan (maksym-arutyunyan)

documentation

https://docs.rs/big-o/

README

big_o

big_o GitHub Actions big_o on crates.io big_o on docs.rs

Infers asymptotic computational complexity.

big_o helps to estimate computational complexity of algorithms by inspecting measurement data (eg. execution time, memory consumption, etc). Users are expected to provide measurement data, big_o will try to fit a set of complexity models and return the best fit.

Example

use assert_approx_eq::assert_approx_eq;

// 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_eq!(complexity.name, big_o::Name::Quadratic);
assert_eq!(complexity.notation, "O(n^2)");
assert_approx_eq!(complexity.params.gain.unwrap(), 1.0, 1e-6);
assert_approx_eq!(complexity.params.offset.unwrap(), 0.0, 1e-6);
assert!(complexity.rank < big_o::complexity("O(n^3)").unwrap().rank);
Commit count: 11

cargo fmt