Skip to main content

read_recent_profiles

Function read_recent_profiles 

Source
pub fn read_recent_profiles(
    fs: &dyn Fs,
    paths: &dyn Pather,
    limit: usize,
) -> Result<Vec<Profile>>
Expand description

Read up to limit most recent profiles, newest first.

Profiles are returned in reverse chronological order (newest first). The cap exists because callers know how much they need — --runs 5 asks for five — and the directory may have hundreds of files.

Implementation: Fs::read_dir already returns entries sorted by name, and profile-<unix_ts>-… is fixed-prefix monotonic, so lexical-ascending == chronological-ascending. We .rev() the iterator to walk newest-first, filter, and take(limit) so we only allocate the rows we’ll actually return.