<commit_before>#!/usr/bin/env bats
# Test if mkmimo shows reasonable throughput on corner cases
load test_helpers

@test "a single slow consumer should not hurt overall throughput (takes 5s)" {
    expected_throughput=100000000  # 100MB/s
    nsecs=5
    nbytes=$(
        mkmimo_throughput \
            timeout=${nsecs}s \
            num_producer_fast=10 num_producer_slow=0 \
            num_consumer_fast=0 num_consumer_slow=1 \
            producer_slow_throughput=ignored \
            consumer_slow_throughput=${expected_throughput} \
            2>&1 | grep ' bytes' | awk '{print $1}' | tr '\n' +
        echo 0
    )
    throughput=$(bc <<<"$nbytes / $nsecs")
    throughputSatisfactionPercentExpr="100 * $throughput / $expected_throughput"
    echo $throughputSatisfactionPercentExpr
    throughputSatisfactionPercent=$(bc <<<"$throughputSatisfactionPercentExpr")
    [[ $throughputSatisfactionPercent -ge 80 ]]
}

@test "slow consumer should not hurt fast consumer's throughput (takes 5-20s)" {
    expected_throughput=1000000000  # 1GB/s
    slow_throughput=4k
    nsecs=5
    let nbytes=$(
        timeout $(($nsecs * 4)) \
        mkmimo_throughput \
            timeout=${nsecs}s \
            num_producer_fast=10 num_producer_slow=0 \
            num_consumer_fast=1 num_consumer_slow=1 \
            producer_slow_throughput=ignored \
            consumer_fast_throughput=${expected_throughput} \
            consumer_slow_throughput=${slow_throughput} \
            2>&1 | grep ' bytes' | awk '{print $1}' | tr '\n' +
        echo 0
    )
    throughput=$(bc <<<"$nbytes / $nsecs")
    throughputSatisfactionPercentExpr="100 * $throughput / $expected_throughput"
    echo $throughputSatisfactionPercentExpr
    throughputSatisfactionPercent=$(bc <<<"$throughputSatisfactionPercentExpr")
    [[ $throughputSatisfactionPercent -ge 80 ]]
}<commit_msg>Skips throughput tests if pv isn't present<commit_after>#!/usr/bin/env bats
# Test if mkmimo shows reasonable throughput on corner cases
load test_helpers

@test "a single slow consumer should not hurt overall throughput (takes 5s)" {
    type pv || skip "pv unavailable"
    expected_throughput=100000000  # 100MB/s
    nsecs=5
    nbytes=$(
        mkmimo_throughput \
            timeout=${nsecs}s \
            num_producer_fast=10 num_producer_slow=0 \
            num_consumer_fast=0 num_consumer_slow=1 \
            producer_slow_throughput=ignored \
            consumer_slow_throughput=${expected_throughput} \
            2>&1 | grep ' bytes' | awk '{print $1}' | tr '\n' +
        echo 0
    )
    throughput=$(bc <<<"$nbytes / $nsecs")
    throughputSatisfactionPercentExpr="100 * $throughput / $expected_throughput"
    echo $throughputSatisfactionPercentExpr
    throughputSatisfactionPercent=$(bc <<<"$throughputSatisfactionPercentExpr")
    [[ $throughputSatisfactionPercent -ge 80 ]]
}

@test "slow consumer should not hurt fast consumer's throughput (takes 5-20s)" {
    type pv || skip "pv unavailable"
    expected_throughput=1000000000  # 1GB/s
    slow_throughput=4k
    nsecs=5
    let nbytes=$(
        timeout $(($nsecs * 4)) \
        mkmimo_throughput \
            timeout=${nsecs}s \
            num_producer_fast=10 num_producer_slow=0 \
            num_consumer_fast=1 num_consumer_slow=1 \
            producer_slow_throughput=ignored \
            consumer_fast_throughput=${expected_throughput} \
            consumer_slow_throughput=${slow_throughput} \
            2>&1 | grep ' bytes' | awk '{print $1}' | tr '\n' +
        echo 0
    )
    throughput=$(bc <<<"$nbytes / $nsecs")
    throughputSatisfactionPercentExpr="100 * $throughput / $expected_throughput"
    echo $throughputSatisfactionPercentExpr
    throughputSatisfactionPercent=$(bc <<<"$throughputSatisfactionPercentExpr")
    [[ $throughputSatisfactionPercent -ge 80 ]]
}
{'fraction_non_alphanumeric': 0.10492059359541786, 'fraction_numerical': 0.030721166362926322, 'mean_word_length': 3.0656084656084657, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4202363', 'n_tokens_mistral': 1296, 'n_tokens_neox': 1106, 'n_words': 240}