10 stable releases

2.0.0 Jan 20, 2024
1.3.4 Nov 1, 2023
1.3.3 Jul 4, 2023
1.3.2 Oct 16, 2022
0.1.1 Jul 11, 2018

#631 in Command line utilities

Download history 3/week @ 2024-01-14 13/week @ 2024-02-25 9/week @ 2024-03-10 1/week @ 2024-03-17 45/week @ 2024-03-31

55 downloads per month

MIT license

21KB
293 lines

xstream

crates.io documentation license tests

A command line tool to split a stream by a delimiter and pipe each section to a child process.

Each chunk can be piped to a new process, with limited parallelism, or for embarassingly parallel processing, processes can be reused.

Installation

cargo install xstream-util

Benchmarks

For a simple illustration of the speed up for reasonably sized streams, the following simple benchmark compares generating 1001 streams of integers and summing them with bc.

First, generate a null delimited set of streams with

time for I in {10000..11000}; do seq $I; echo -ne '0\0'; done

This stream is roughly 50M, making each stream roughly 50k.

I then piped this into xstream as

| time xstream -0 -w '' -- bash -c 'paste -sd+ | bc' > /dev/null

and xargs as

| time xargs -0I@ bash -c '<<< "@" head -n-1 | paste -sd+ | bc' > /dev/null

which on my system gives:

Program User System Elapsed
xstream 10.21s 1.67s 0:09.58
xargs 15.72s 2.85s 0:14.52

This benchmark is a toy example, but xstream already provides a 30% speed up when each stream is only 50k.

Dependencies

~0–10MB
~90K SLoC