[go: up one dir, main page]

directories 6.0.0

A tiny mid-level library that provides platform-specific standard locations of directories for config, cache and other data on Linux, Windows and macOS by leveraging the mechanisms defined by the XDG base/user directory specifications on Linux, the Known Folder API on Windows, and the Standard Directory guidelines on macOS.
Documentation
#[macro_use]
extern crate bencher;
extern crate directories;

use bencher::Bencher;
use bencher::black_box;
use directories::BaseDirs;
use directories::ProjectDirs;
use directories::UserDirs;

fn base_dirs(b: &mut Bencher) {
    b.iter(|| {
        let _ = black_box(BaseDirs::new());
    });
}

fn user_dirs(b: &mut Bencher) {
    b.iter(|| {
        let _ = black_box(UserDirs::new());
    });
}

fn project_dirs_from_path(b: &mut Bencher) {
    b.iter(|| {
        let _ = black_box(ProjectDirs::from_path(Default::default()));
    });
}

fn project_dirs(b: &mut Bencher) {
    b.iter(|| {
        let _ = black_box(ProjectDirs::from("org", "foo", "Bar App"));
    });
}

benchmark_group!(constructors,
    base_dirs,
    user_dirs,
    project_dirs_from_path,
    project_dirs,
);
benchmark_main!(constructors);