### Install hyperfine Source: https://github.com/uutils/coreutils/blob/main/src/uu/head/BENCHMARKING.md Installs the hyperfine benchmarking tool on Ubuntu systems. ```shell sudo apt-get install hyperfine ``` -------------------------------- ### Install uutils with GNU Make Source: https://github.com/uutils/coreutils/blob/main/README.md Installs all available utilities using GNU Make. This is a common method for projects built with Make. It can install all utilities by default. ```shell make install ``` -------------------------------- ### Install on NixOS Source: https://github.com/uutils/coreutils/wiki/Home Standard command to install the package on NixOS systems. ```shell $ nix-env -iA nixos.uutils-coreutils ``` -------------------------------- ### Install uutils with GNU Make and program prefix Source: https://github.com/uutils/coreutils/blob/main/README.md Installs every program with a custom prefix using GNU Make. The PROG_PREFIX variable sets the prefix for all installed programs. ```shell make PROG_PREFIX=uu- install ``` -------------------------------- ### Running Simple Integration Example Source: https://github.com/uutils/coreutils/blob/main/fuzz/uufuzz/README.md Command to run the simple integration testing example using cargo. ```bash cargo run --example simple_integration ``` -------------------------------- ### Install Coreutils on Gentoo Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Installs the uutils-coreutils package on Gentoo using emerge. ```shell emerge -pv sys-apps/uutils-coreutils ``` -------------------------------- ### Install and activate SELinux on Debian/Ubuntu Source: https://github.com/uutils/coreutils/wiki/Supporting-SELinux-in-the-coreutils Install necessary SELinux packages and activate SELinux using `selinux-activate`. Verify the status with `sestatus`. ```bash sudo apt install selinux-basics selinux-policy-default auditd sudo selinux-activate sudo reboot sestatus ``` -------------------------------- ### Install uutils with GNU Make, skipping completions and manpages Source: https://github.com/uutils/coreutils/blob/main/README.md Installs uutils using GNU Make while skipping shell completions and manpages. Set COMPLETIONS and MANPAGES to 'n' to disable their installation. ```shell make COMPLETIONS=n MANPAGES=n install ``` -------------------------------- ### Running Pipe Input Example Source: https://github.com/uutils/coreutils/blob/main/fuzz/uufuzz/README.md Command to run the pipe input handling example using cargo. ```bash cargo run --example pipe_input ``` -------------------------------- ### Running Complex Integration Example Source: https://github.com/uutils/coreutils/blob/main/fuzz/uufuzz/README.md Command to run the complex integration testing example, which demonstrates file descriptor handling issues, using cargo. ```bash cargo run --example integration_testing ``` -------------------------------- ### Install LLVM Tools for Code Coverage Source: https://github.com/uutils/coreutils/blob/main/DEVELOPMENT.md Install the 'llvm-tools-preview' component using rustup, which is necessary for generating code coverage reports locally. ```shell rustup component add llvm-tools-preview ``` -------------------------------- ### Basic Example: Comparing echo Implementations Source: https://github.com/uutils/coreutils/blob/main/fuzz/uufuzz/README.md This example demonstrates how to use uufuzz to compare a custom 'echo' implementation against the GNU version. It covers running both implementations and comparing their results. ```rust use std::ffi::OsString; use uufuzz::{generate_and_run_uumain, run_gnu_cmd, compare_result}; // Your utility's main function fn my_echo_main(args: std::vec::IntoIter) -> i32 { // Implementation here 0 } // Test against GNU implementation let args = vec![OsString::from("echo"), OsString::from("hello")]; // Run your implementation let rust_result = generate_and_run_uumain(&args, my_echo_main, None); // Run GNU implementation let gnu_result = run_gnu_cmd("echo", &args[1..], false, None).unwrap(); // Compare results compare_result("echo", "hello", None, &rust_result, &gnu_result, true); ``` -------------------------------- ### Install Coreutils on NixOS Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Installs the uutils-coreutils package on NixOS using nix-env. ```shell nix-env -iA nixos.uutils-coreutils ``` -------------------------------- ### Rust Benchmark Example with Divan Source: https://github.com/uutils/coreutils/blob/main/docs/src/performance.md Write benchmarks using the Divan framework. This example demonstrates benchmarking the 'expand' utility with varying numbers of lines, using helper functions for data generation and execution. ```rust use divan::{Bencher, black_box}; use uu_expand::uumain; use uucore::benchmark::{create_test_file, run_util_function, text_data}; #[divan::bench(args = [10_000, 100_000])] fn bench_expand(bencher: Bencher, num_lines: usize) { let data = text_data::generate_ascii_data(num_lines); let temp_dir = tempfile::tempdir().unwrap(); let file_path = create_test_file(&data, temp_dir.path()); bencher.bench(|| { black_box(run_util_function(uumain, &[file_path.to_str().unwrap()])); }); } fn main() { divan::main(); } ``` -------------------------------- ### Install uutils with GNU Make and custom prefix directory Source: https://github.com/uutils/coreutils/blob/main/README.md Installs uutils using GNU Make to a custom parent directory. The PREFIX variable specifies the installation path. DESTDIR is also supported for staging. ```shell make PREFIX=/my/path install ``` -------------------------------- ### Install uutils-coreutils with Scoop on Windows Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Use this command to install the package using the Scoop package manager on Windows. ```shell scoop install uutils-coreutils ``` -------------------------------- ### Running Basic Echo Example Source: https://github.com/uutils/coreutils/blob/main/fuzz/uufuzz/README.md Command to run the basic echo differential comparison example using cargo. ```bash cargo run --example basic_echo ``` -------------------------------- ### Install uutils-coreutils with Winget on Windows Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Use this command to install the package using the Winget package manager on Windows. ```shell winget install uutils.coreutils ``` -------------------------------- ### Install rust-coreutils with pkg on FreeBSD Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Use this command to install the package using the pkg package manager on FreeBSD. ```shell pkg install rust-coreutils ``` -------------------------------- ### Install Coreutils on OpenMandriva Lx Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Installs the uutils-coreutils package on OpenMandriva Lx using dnf. ```shell dnf install uutils-coreutils ``` -------------------------------- ### Install utilities with GNU Make Source: https://github.com/uutils/coreutils/wiki/Home Commands to install uutils using GNU Make with various configuration options like prefixing, multicall binaries, and directory selection. ```bash $ make install ``` ```bash $ sudo -E make install ``` ```bash $ make SKIP_UTILS='UTILITY_1 UTILITY_2' install ``` ```bash $ make UTILS='UTILITY_1 UTILITY_2' install ``` ```bash $ make PROG_PREFIX=PREFIX_GOES_HERE install ``` ```bash $ make MULTICALL=y install ``` ```bash # DESTDIR is also supported $ make PREFIX=/my/path install ``` -------------------------------- ### Install uutils with Cargo Source: https://github.com/uutils/coreutils/blob/main/README.md Installs uutils using Cargo. Ensure you have Rust and Cargo installed. This command installs the utilities into Cargo's bin directory. ```shell cargo install --path . --locked ``` -------------------------------- ### Install Coreutils on Fedora Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Installs the uutils-coreutils package on Fedora. After installation, you may need to add the coreutils binary directory to your PATH. ```shell dnf install uutils-coreutils # To use it: export PATH=/usr/libexec/uutils-coreutils:$PATH ``` -------------------------------- ### Install Coreutils on Arch Linux Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Installs the uutils-coreutils package on Arch Linux using pacman. ```shell pacman -S uutils-coreutils ``` -------------------------------- ### Install and run samply Source: https://github.com/uutils/coreutils/blob/main/src/uu/rm/BENCHMARKING.md Commands to install and execute the samply profiler for generating flamegraphs. ```bash cargo install samply ``` ```bash samply record target/release/coreutils rm -rf ../linux ``` -------------------------------- ### Install specific uutils with GNU Make Source: https://github.com/uutils/coreutils/blob/main/README.md Installs only a few specified utilities using GNU Make. Use the UTILS variable to list the desired utilities. ```shell make UTILS='UTILITY_1 UTILITY_2' install ``` -------------------------------- ### Install manpage for ls Source: https://github.com/uutils/coreutils/blob/main/README.md Installs the manpage for the 'ls' utility to the standard manpages directory. This command redirects the output of 'uudoc' to the appropriate file. ```bash uudoc manpage ls > /usr/local/share/man/man1/ls.1 ``` -------------------------------- ### Install Xcode Command Line Tools on macOS Source: https://github.com/uutils/coreutils/blob/main/DEVELOPMENT.md Install the C compiler and linker required for development on macOS. ```shell xcode-select --install ``` -------------------------------- ### Install Coreutils with Cargo (Windows) Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Use this command to install the uutils-coreutils package from crates.io for Windows systems. ```shell cargo install coreutils --features windows --locked ``` -------------------------------- ### Install Coreutils on Manjaro Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Installs the uutils-coreutils package on Manjaro using either pacman or pamac. ```shell pacman -S uutils-coreutils # or pamac install uutils-coreutils ``` -------------------------------- ### Install Coreutils on RHEL/AlmaLinux/CENTOS Stream/Rocky Linux/EPEL 9 Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Installs the uutils-coreutils package on RHEL-based systems with EPEL 9. This includes installing the EPEL repository first, then the coreutils, and finally updating the PATH. ```shell # Install EPEL 9 - Specific For RHEL please check codeready-builder-for-rhel-9 First then install epel dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm -y # Install Core Utils dnf install uutils-coreutils # To use it: export PATH=/usr/libexec/uutils-coreutils:$PATH ``` -------------------------------- ### Install GNU Coreutils and Gsed on FreeBSD Source: https://github.com/uutils/coreutils/blob/main/DEVELOPMENT.md Install necessary GNU packages on FreeBSD for testing purposes. ```shell pkg install coreutils gsed ``` -------------------------------- ### Install uutils Coreutils with Cargo Source: https://github.com/uutils/coreutils/wiki/Home Installs the uutils binaries into Cargo's bin folder (e.g., `$HOME/.cargo/bin`). This command is used after building with Cargo. ```bash $ cargo install --path . ``` -------------------------------- ### Fluent Syntax Example Source: https://github.com/uutils/coreutils/blob/main/docs/src/l10n.md Example of Fluent syntax including variables and plural rules. ```fluent id-greeting = Hello, world! welcome = Welcome, { $name }! count-files = You have { $count -> [one] { $count } file *[other] { $count } files } ``` -------------------------------- ### Build with Cargo (SELinux Features) Source: https://github.com/uutils/coreutils/blob/main/README.md Builds uutils with SELinux-specific features. Requires libselinux and libclang to be installed. ```shell cargo build --release --features unix,feat_selinux ``` -------------------------------- ### Install Homebrew Formulas on macOS Source: https://github.com/uutils/coreutils/blob/main/DEVELOPMENT.md Install essential GNU utilities and development tools using Homebrew. ```shell brew install \ coreutils \ autoconf \ gettext \ texinfo \ xz \ automake \ gnu-sed \ m4 \ bison \ pre-commit \ findutils ``` -------------------------------- ### Install uutils with GNU Make using sudo Source: https://github.com/uutils/coreutils/blob/main/README.md Installs uutils using GNU Make with superuser privileges. The -E flag is required when using sudo with make. ```shell sudo -E make install ``` -------------------------------- ### Install Coreutils on Alpine Linux Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Installs the uutils-coreutils package on Alpine Linux. Requires the 'edge' repository. ```shell apk update uutils-coreutils ``` -------------------------------- ### Install Coreutils with Cargo (Unix-like) Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Use this command to install the uutils-coreutils package from crates.io for Unix-like systems. ```shell cargo install coreutils --features unix --locked ``` -------------------------------- ### Execute ls via the multi-call binary Source: https://github.com/uutils/coreutils/blob/main/docs/src/multicall.md Example of running the ls utility with the -l flag using the multi-call binary. ```shell coreutils ls -l ``` -------------------------------- ### Install uutils multicall binary with GNU Make Source: https://github.com/uutils/coreutils/blob/main/README.md Installs the multicall binary using GNU Make. Set the MULTICALL variable to 'y' to enable this feature. ```shell make MULTICALL=y install ``` -------------------------------- ### Install uutils with GNU Make, skipping utilities Source: https://github.com/uutils/coreutils/blob/main/README.md Installs uutils using GNU Make, excluding specified utilities. Use the SKIP_UTILS variable to list utilities to omit. ```shell make SKIP_UTILS='UTILITY_1 UTILITY_2' install ``` -------------------------------- ### Install bash completion for ls Source: https://github.com/uutils/coreutils/blob/main/README.md Installs the bash completion script for the 'ls' utility to the standard bash completion directory. This command redirects the output of 'uudoc' to the appropriate file. ```shell uudoc completion ls bash > /usr/local/share/bash-completion/completions/ls.bash ``` -------------------------------- ### Example with Pipe Input Source: https://github.com/uutils/coreutils/blob/main/fuzz/uufuzz/README.md This snippet shows how to handle pipe input when comparing implementations. It passes string data to both the custom and GNU 'cat' commands. ```rust let pipe_input = "test data"; let rust_result = generate_and_run_uumain(&args, my_cat_main, Some(pipe_input)); let gnu_result = run_gnu_cmd("cat", &args[1..], false, Some(pipe_input)).unwrap(); compare_result("cat", "", Some(pipe_input), &rust_result, &gnu_result, true); ``` -------------------------------- ### Install uudoc binary for shell completions Source: https://github.com/uutils/coreutils/blob/main/README.md Installs the 'uudoc' binary using Cargo, which is required for generating shell completions. Ensure you have the 'uudoc' feature enabled. ```shell cargo install --bin uudoc --features uudoc --path . ``` -------------------------------- ### Install uutils-coreutils with Homebrew on macOS Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Use this command to install the package using the Homebrew package manager on macOS. ```shell brew install uutils-coreutils ``` -------------------------------- ### Documenting Rust Components with Rustdoc Source: https://github.com/uutils/coreutils/blob/main/CONTRIBUTING.md Follow rustdoc's guidelines for documenting code components. Ensure documentation provides useful information beyond just repeating the function name, and include a copy-pasteable code example. ```rust /// [short sentence explaining what it is] /// /// [more detailed explanation] /// /// [at least one code example that users can copy/paste to try it] /// /// [even more advanced explanations if necessary] ``` -------------------------------- ### Build Coreutils from AUR (Arch User Repository) Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Builds the uutils-coreutils package from the AUR. This involves cloning the repository, navigating into the directory, and then using makepkg to build and install. ```shell git clone https://aur.archlinux.org/uutils-coreutils-git --depth=1 cd uutils-coreutils-git makepkg -si ``` -------------------------------- ### Clone and Navigate to Repository Source: https://github.com/uutils/coreutils/blob/main/README.md Before building, clone the repository and navigate into the coreutils directory. ```shell git clone https://github.com/uutils/coreutils cd coreutils ``` -------------------------------- ### Install Coreutils on Debian Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Installs the rust-coreutils package on Debian. After installation, you may need to add the coreutils binary directory to your PATH. ```shell apt install rust-coreutils # To use it: export PATH=/usr/lib/cargo/bin/coreutils:$PATH ``` -------------------------------- ### Integration Testing Example Source: https://github.com/uutils/coreutils/blob/main/fuzz/uufuzz/README.md This Rust test function demonstrates using uufuzz within a standard test suite to verify the functionality of a 'sort' command implementation against its GNU counterpart. ```rust #[test] fn test_basic_functionality() { let args = vec![OsString::from("sort"), OsString::from("-n")]; let input = "3\n1\n2\n"; let rust_result = generate_and_run_uumain(&args, sort_main, Some(input)); let gnu_result = run_gnu_cmd("sort", &args[1..], false, Some(input)).unwrap(); assert_eq!(rust_result.stdout, gnu_result.stdout); assert_eq!(rust_result.exit_code, gnu_result.exit_code); } ``` -------------------------------- ### Fuzzing Testing with libFuzzer Source: https://github.com/uutils/coreutils/blob/main/fuzz/uufuzz/README.md This example shows how to integrate uufuzz with libFuzzer for differential fuzzing. It generates random arguments and compares the utility's output against the GNU version. ```rust #![no_main] use libfuzzer_sys::fuzz_target; use uufuzz::*; fuzz_target!(|_data: &[u8]| { let args = generate_test_args(); let rust_result = generate_and_run_uumain(&args, my_utility_main, None); let gnu_result = run_gnu_cmd("utility", &args[1..], false, None).unwrap(); compare_result("utility", &format!("{:?}", args), None, &rust_result, &gnu_result, true); }); ``` -------------------------------- ### Build with Cargo (Optimized Size) Source: https://github.com/uutils/coreutils/blob/main/README.md Builds the core set of uutils with optimizations for binary size using Cargo. ```shell cargo build --profile=release-small ``` -------------------------------- ### Install uutils-coreutils with Conda Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Use this command to install the package using the Conda package manager. ```shell conda install -c conda-forge uutils-coreutils ``` -------------------------------- ### Build GNU Coreutils with SELinux Enabled Source: https://github.com/uutils/coreutils/blob/main/DEVELOPMENT.md Build the GNU coreutils with SELinux support enabled. ```shell env SELINUX_ENABLED=1 bash util/build-gnu.sh ``` -------------------------------- ### Build the cp utility Source: https://github.com/uutils/coreutils/blob/main/src/uu/cp/BENCHMARKING.md Compile the cp utility in release mode before running benchmarks. ```shell cargo build --release -p uu_cp ``` -------------------------------- ### Clone the uutils Coreutils repository Source: https://github.com/uutils/coreutils/wiki/Home Before building, clone the repository using Git. This command fetches the entire project to your local machine. ```bash $ git clone https://github.com/uutils/coreutils $ cd coreutils ``` -------------------------------- ### Build GNU Coreutils with Release Optimizations Source: https://github.com/uutils/coreutils/blob/main/DEVELOPMENT.md Build the GNU coreutils with release optimizations enabled for performance comparison. ```shell env PROFILE=release bash util/build-gnu.sh ``` -------------------------------- ### Build coreutils with SELinux support Source: https://github.com/uutils/coreutils/wiki/Supporting-SELinux-in-the-coreutils Use the `--features feat_selinux` flag with `cargo build` to include SELinux capabilities. Ensure `--no-default-features` is used if you only want SELinux and not other default features. ```bash cargo build -p uu_id --no-default-features --features feat_selinux ``` ```bash cargo build -p uu_id --no-default-features ``` -------------------------------- ### Build all available utilities with GNU Make Source: https://github.com/uutils/coreutils/wiki/Home Builds all available utilities using GNU Make. This is a simple command to compile the entire suite. ```bash $ make ``` -------------------------------- ### Build Binary in Release Mode Source: https://github.com/uutils/coreutils/blob/main/docs/src/performance.md Build your binary in release mode for accurate performance measurements. The 'profiling' profile is recommended as it compiles in release mode with debug symbols. ```bash cargo build --features unix --profile profiling ``` -------------------------------- ### Install coreutils-uutils with MacPorts on macOS Source: https://github.com/uutils/coreutils/blob/main/docs/src/installation.md Use this command to install the package using the MacPorts package manager on macOS. ```shell port install coreutils-uutils ``` -------------------------------- ### Define short options with arguments Source: https://github.com/uutils/coreutils/blob/main/docs/src/extensions.md Demonstrates the supported syntax for passing arguments to short options in uutils. ```bash $ ls -w 80 $ ls -w80 ``` ```bash $ ls -w=80 ``` -------------------------------- ### Build specific uutils with Cargo (Features) Source: https://github.com/uutils/coreutils/wiki/Home Manually specify which utilities to build by listing them as features. This is useful for creating a minimal binary with only the required tools. ```bash $ cargo build --features "base32 cat echo rm" --no-default-features ``` -------------------------------- ### Build GNU and Rust Coreutils Source: https://github.com/uutils/coreutils/blob/main/CONTRIBUTING.md Build both GNU and Rust coreutils for comparison. This is a prerequisite for testing and improving GNU compatibility. ```bash bash util/build-gnu.sh ``` -------------------------------- ### Build `uu_sum` in Release Mode Source: https://github.com/uutils/coreutils/blob/main/src/uu/sum/BENCHMARKING.md Build the `uu_sum` utility in release mode for optimized performance. This is a prerequisite for accurate benchmarking. ```shell cargo build --release --package uu_sum ``` -------------------------------- ### Uninstall uutils with Cargo Source: https://github.com/uutils/coreutils/blob/main/README.md Use this command to uninstall uutils if it was installed using Cargo. ```shell cargo uninstall coreutils ``` -------------------------------- ### Build with GNU Make (Release) Source: https://github.com/uutils/coreutils/blob/main/README.md Builds all available utilities using GNU Make in release mode. ```shell make PROFILE=release ``` -------------------------------- ### Uninstall uutils Source: https://github.com/uutils/coreutils/wiki/Home Procedures for removing uutils installed via Cargo or GNU Make. ```bash $ cargo uninstall uutils ``` ```bash $ make uninstall ``` ```bash $ make PROG_PREFIX=PREFIX_GOES_HERE uninstall ``` ```bash $ make MULTICALL=y uninstall ``` ```bash # DESTDIR is also supported $ make PREFIX=/my/path uninstall ``` -------------------------------- ### Uninstall all utilities with GNU Make Source: https://github.com/uutils/coreutils/blob/main/README.md Use this command to uninstall all utilities when installed with GNU Make. ```shell make uninstall ``` -------------------------------- ### Create dircolors Test Fixtures Source: https://github.com/uutils/coreutils/blob/main/src/uu/dircolors/README.md Use these commands to generate expected output files for dircolors tests. Ensure the path to COREUTILS is correctly set. ```shell dircolors --print-database > /PATH_TO_COREUTILS/tests/fixtures/dircolors/internal.expected ``` ```shell dircolors --print-ls-colors > /PATH_TO_COREUTILS/tests/fixtures/dircolors/ls_colors.expected ``` ```shell dircolors -b > /PATH_TO_COREUTILS/tests/fixtures/dircolors/bash_def.expected ``` ```shell dircolors -c > /PATH_TO_COREUTILS/tests/fixtures/dircolors/csh_def.expected ``` -------------------------------- ### Build with GNU Make (Specific Utilities) Source: https://github.com/uutils/coreutils/blob/main/README.md Builds only a specified list of utilities using GNU Make. ```shell make UTILS='UTILITY_1 UTILITY_2' ``` -------------------------------- ### Generate shell completions Source: https://github.com/uutils/coreutils/wiki/Home Commands to generate and install shell completion scripts for specific utilities. ```bash cargo run completion ``` ```bash cargo run completion ls bash > /usr/local/share/bash-completion/completions/ls ``` -------------------------------- ### Invoke a utility using the multi-call binary Source: https://github.com/uutils/coreutils/blob/main/docs/src/multicall.md General syntax for executing a utility through the coreutils binary. ```shell coreutils [util] [util options] ``` -------------------------------- ### Uninstall the multicall binary with GNU Make Source: https://github.com/uutils/coreutils/blob/main/README.md Use this command to uninstall the multicall binary when installed with GNU Make. ```shell make MULTICALL=y uninstall ``` -------------------------------- ### Generate manpage for a utility Source: https://github.com/uutils/coreutils/blob/main/README.md Generates the manpage for a specified utility using the 'uudoc' binary. The output can be redirected to a file for installation. ```bash uudoc manpage ``` -------------------------------- ### Run All Tests with GNU Make Source: https://github.com/uutils/coreutils/blob/main/DEVELOPMENT.md Execute all available utility tests using the 'make test' command. ```shell make test ``` -------------------------------- ### Run Cargo Tests with Nextest Source: https://github.com/uutils/coreutils/blob/main/DEVELOPMENT.md Utilize Nextest for faster test execution, especially on multi-core systems. Requires Nextest installation. ```shell cargo nextest run --features unix --no-fail-fast ``` -------------------------------- ### Build uu_split release binary Source: https://github.com/uutils/coreutils/blob/main/src/uu/split/BENCHMARKING.md Build the `uu_split` binary in release mode for performance testing. ```bash cargo build --release -p uu_split ``` -------------------------------- ### Cargo.toml dependencies Source: https://github.com/uutils/coreutils/blob/main/src/uu/sort/BENCHMARKING.md The `Cargo.toml` file specifies the `rand` crate as a dependency, version 0.10.0, which is used for generating random numbers in the Rust example. ```toml [dependencies] rand = "0.10.0" ``` -------------------------------- ### Build seq binary Source: https://github.com/uutils/coreutils/blob/main/src/uu/seq/BENCHMARKING.md Build the seq binary using the release profile. ```shell cargo build --release -p uu_seq ``` -------------------------------- ### Compare with GNU sort Source: https://github.com/uutils/coreutils/blob/main/src/uu/sort/BENCHMARKING.md Compare the performance of `coreutils sort` with GNU `sort` using `hyperfine`. Ensure GNU sort is installed and accessible as `sort`. ```bash hyperfine "target/release/coreutils sort shuffled_numbers_si.txt -h -o output.txt" "sort shuffled_numbers_si.txt -h -o output.txt" ``` -------------------------------- ### Pull Request Title Example Source: https://github.com/uutils/coreutils/blob/main/CONTRIBUTING.md When creating a pull request, make the title descriptive by including the utility and the problem solved, rather than just a ticket number. ```git ls: fix version sort order ``` -------------------------------- ### Build basenc with release profile Source: https://github.com/uutils/coreutils/blob/main/src/uu/basenc/BENCHMARKING.md Build the `uu_basenc` package using the release profile for optimized performance. This command is essential for benchmarking the optimized binary. ```Shell cargo build --package uu_basenc --profile release ``` -------------------------------- ### Get uutils basenc commit hash Source: https://github.com/uutils/coreutils/blob/main/src/uu/basenc/BENCHMARKING.md Retrieve the latest commit hash for the uutils `basenc` implementation. This is used to identify the specific version being benchmarked. ```Shell ❯ git rev-list HEAD | coreutils head -n 1 -- - ``` -------------------------------- ### Build individual utilities with Cargo Source: https://github.com/uutils/coreutils/wiki/Home Builds each utility as an individual binary package. Use the `--package` option to specify which utilities to compile. ```bash $ cargo build -p uu_base32 -p uu_cat -p uu_echo -p uu_rm ``` -------------------------------- ### Download sample input file Source: https://github.com/uutils/coreutils/blob/main/src/uu/shuf/BENCHMARKING.md Use curl to download a sample input file from Gutenberg.org. This is useful for testing file shuffling. ```shell curl -o input.txt https://www.gutenberg.org/files/100/100-0.txt ``` -------------------------------- ### Build uutils Coreutils with Cargo (Platform-specific features) Source: https://github.com/uutils/coreutils/wiki/Home Builds expanded sets of uutils for a specific platform by enabling features. Use this to tailor the build to your operating system. ```bash $ cargo build --release --features macos # or ... $ cargo build --release --features windows # or ... $ cargo build --release --features unix ``` -------------------------------- ### Profile with Profiling Build and High Sampling Rate Source: https://github.com/uutils/coreutils/blob/main/docs/src/performance.md Profile your application using the 'profiling' build profile and a high sampling rate for detailed performance analysis. Redirecting output to /dev/null can be useful for profiling without saving large files. ```bash cargo build --profile profiling -p uu_ls samply record -r 10000 target/profiling/ls -lR /var .git .git .git > /dev/null ``` -------------------------------- ### Get GNU Core Utilities basenc version Source: https://github.com/uutils/coreutils/blob/main/src/uu/basenc/BENCHMARKING.md Display the version of the GNU Core Utilities `basenc` program. This helps in identifying the specific version used for comparison in benchmarks. ```Shell ❯ /usr/bin/basenc --version | coreutils head -n 1 -- - ``` -------------------------------- ### Benchmark wc vs uuwc with Hyperfine Source: https://github.com/uutils/coreutils/blob/main/src/uu/wc/BENCHMARKING.md Use `hyperfine` to compare the performance of `wc` and `uuwc` on various files and command options. This snippet shows the setup for generating a benchmark table. ```python import json import subprocess from tabulate import tabulate bins = ["wc", "uuwc"] files = ["moby64.txt", "odyssey256.txt", "25Mshortlines", "/usr/bin/docker"] cmds = [ "{cmd} {file}", "{cmd} -c {file}", "uucat {file} | {cmd} -c", "{cmd} -l {file}", "{cmd} -L {file}", "{cmd} -m {file}", "{cmd} -w {file}", "{cmd} -lwcmL {file}", ] table = [] for cmd in cmds: row = ["`" + cmd.format(cmd="wc", file="") + "`"] for file in files: subprocess.run( [ "hyperfine", cmd.format(cmd=bins[0], file=file), cmd.format(cmd=bins[1], file=file), "--export-json=out.json", ], check=True, ) with open("out.json") as f: res = json.load(f)["results"] row.append(round(res[0]["mean"] / res[1]["mean"], 4)) table.append(row) print(tabulate(table, [""] + files, tablefmt="github")) ``` -------------------------------- ### Three-Way Comparison Benchmark with Hyperfine Source: https://github.com/uutils/coreutils/blob/main/docs/src/performance.md Benchmark your implementation against the GNU version and a previous version of your implementation. Use the '--warmup' flag to ensure consistent results. ```bash hyperfine \ --warmup 3 \ "/usr/bin/ls -R ." \ "./target/profiling/coreutils.prev ls -R ." \ "./target/profiling/coreutils ls -R ." ``` ```bash hyperfine \ --warmup 3 \ -L ls /usr/bin/ls,\"./target/profiling/coreutils.prev ls\",\"./target/profiling/coreutils ls\" \ "{ls} -R ." ``` -------------------------------- ### Benchmark Base64 Encoding Performance with SIMD Source: https://github.com/uutils/coreutils/blob/main/src/uu/basenc/BENCHMARKING.md This command uses hyperfine to benchmark the performance of the standard /usr/bin/base64 against the SIMD-accelerated coreutils base64 implementation for encoding a large file. Ensure hyperfine is installed to run this benchmark. ```Shell ❯ hyperfine '/usr/bin/base64 /tmp/oneline_4G.txt' './target/release/coreutils base64 /tmp/oneline_4G.txt' -N --warmup 3 ``` -------------------------------- ### Compare with GNU ls using Hyperfine Source: https://github.com/uutils/coreutils/blob/main/src/uu/ls/BENCHMARKING.md Compare performance with GNU ls by running both commands with hyperfine. Assumes GNU ls is installed as `ls`. Ensure you run `cargo build --release` before benchmarking. ```bash hyperfine --warmup 2 "target/release/coreutils ls -al -R tree > /dev/null" "ls -al -R tree > /dev/null" ``` -------------------------------- ### Compare with GNU coreutils Source: https://github.com/uutils/coreutils/wiki/Home Commands to run local comparison tests against GNU coreutils. ```bash $ bash util/build-gnu.sh $ bash util/run-gnu-test.sh # To run a single test: $ bash util/run-gnu-test.sh tests/touch/not-owner.sh # for example ``` -------------------------------- ### Download test file Source: https://github.com/uutils/coreutils/blob/main/src/uu/head/BENCHMARKING.md Downloads the 'Complete Works of William Shakespeare' text file for benchmarking. ```shell curl -o shakespeare.txt https://www.gutenberg.org/files/100/100-0.txt ``` -------------------------------- ### Build uu_head binary Source: https://github.com/uutils/coreutils/blob/main/src/uu/head/BENCHMARKING.md Builds the `uu_head` binary in release mode for performance testing. ```shell cargo build --release -p uu_head ``` -------------------------------- ### Build with Cargo (Platform Features) Source: https://github.com/uutils/coreutils/blob/main/README.md Builds uutils with platform-specific features enabled. Ensure you are building on the target platform or have cross-compilation set up. ```shell cargo build --release --features windows ``` ```shell cargo build --release --features unix ``` ```shell cargo build --release --target wasm32-wasip1 --no-default-features --features feat_wasm ``` -------------------------------- ### Benchmark join with hyperfine Source: https://github.com/uutils/coreutils/blob/main/src/uu/join/BENCHMARKING.md Compare the performance of two different builds of the join utility using the hyperfine benchmarking tool. ```shell hyperfine -w 5 "/path/to/main/branch/build/join file1 file2" "/path/to/working/branch/build/join file1 file2" ```