chunker-0.1.1 has been yanked.
chunker
Minimalistic alternative to rayon’s par_iter/par_chunks + inner iteration + reduce for parallel processing of slices with progress bar by default.
Despite its name, this crate is really tiny: only 80 SLOC.
Usage
cargo add chunker
Call chunker::run or chunker::run_mut with these arguments:
items— slice of values to process in parallelconfig— configuration:thread_count,chunk_size,progress_bar,bar_stepinit— function to initialize a worker’s intermediate resultwork—Fnaccepting an individual value fromitemsand mutating the worker’s intermediate result (and/or mutating the value itself in the case ofrun_mut)gather—FnMutaccepting anmpsc::Receiverof workers’ intermediate results in random order and returns the final result (usually viareduce)
Example
Sum of squares:
run
Simple parallel implementaion of word counting:
use ;
$ hyperfine 'target/release/examples/count_words <kjvbible_x10.txt'
Benchmark 1: target/release/examples/count_words <kjvbible_x10.txt
Time (mean ± σ): 84.0 ms ± 1.3 ms [User: 314.6 ms, System: 28.2 ms]
Range (min … max): 82.4 ms … 87.8 ms 34 runs