NixOS / nixfmt

The official (but not yet stable) formatter for Nix code
https://nixfmt.serokell.io
Mozilla Public License 2.0
936 stars 41 forks source link

Add a bench suite #58

Open kirelagin opened 4 years ago

piegamesde commented 1 year ago

What is a "bench suite"?

Lucus16 commented 1 year ago

A set of benchmarks used to detect performance improvements and regressions.

dasJ commented 2 months ago

Turns out I know far too little about GH actions to add this into @infinisil's workflow for PRs so my proposal is:

For the second item, I hacked together this script:

#!/usr/bin/env bash

set -euo pipefail

{
    echo '['
    while IFS= read -r f; do
        if [[ -s "${f}" ]]; then
            echo -n '('
            cat "${f}"
            echo ')'
        fi
    done <<< "$(find . -type f -name '*.nix')"
    echo ']'
} | { command time -v nixfmt > /dev/null; } 2>&1

Which for me returns:

        Command being timed: "nixfmt"
        User time (seconds): 132.66
        System time (seconds): 12.59
        Percent of CPU this job got: 79%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 3:01.82
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 21199452
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 20
        Minor (reclaiming a frame) page faults: 5479701
        Voluntary context switches: 325823
        Involuntary context switches: 5360
        Swaps: 0
        File system inputs: 1403584
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0

Formatting a lot of small files in the (probably) largest nix-code repo and formatting a very huge file is hopefully a good enough indicator.