<commit_before>#!/usr/bin/env bash

set -e

PORT=9876
HOST=localhost
LIMIT=1000000

if ! $( netstat -an | egrep -q "tcp.*:$PORT.*LISTEN" ); then
    echo "First start boostcached (I can't find it at $PORT port)"
    exit 1
fi

function get_machine_info()
{
    echo "CPU info"
    awk '{if ($0 == "") { exit; } print "\t" $0}' /proc/cpuinfo
}

function run_test_client()
{
    local FMT_STRING=$1

    echo "Testing '$FMT_STRING'"

    START=$(date +%s)
    COUNT=$(gawk "
    BEGIN {
        serverConnection = \"/inet/tcp/0/$HOST/$PORT\"
        count=0
        limit=$LIMIT
        fmt_string=\"$FMT_STRING\r\n\"

        for (i = 0; i < limit; ++i) {
            printf fmt_string, i, i |& serverConnection
            ++count
            serverConnection |& getline
            # We do not need to print output test data
            # print \$0
        }

        close(service)
        print count
    }
    ")
    END=$(date +%s)
    ESTIMATE=$((END - START))
    # Queries per second
    QPS=$((COUNT / ESTIMATE))

    echo "Estimate $ESTIMATE sec ($QPS qps)"
}

get_machine_info
run_test_client "HSET %i_key %i_value"
run_test_client "HGET %i_key"<commit_msg>[benchmarks] one_connection: test HDEL, ARGET, ARSET commands too.<commit_after>#!/usr/bin/env bash

set -e

PORT=9876
HOST=localhost
LIMIT=1000000

if ! $( netstat -an | egrep -q "tcp.*:$PORT.*LISTEN" ); then
    echo "First start boostcached (I can't find it at $PORT port)"
    exit 1
fi

function get_machine_info()
{
    echo "CPU info"
    awk '{if ($0 == "") { exit; } print "\t" $0}' /proc/cpuinfo
}

function run_test_client()
{
    local FMT_STRING=$1

    echo "Testing '$FMT_STRING'"

    START=$(date +%s)
    COUNT=$(gawk "
    BEGIN {
        serverConnection = \"/inet/tcp/0/$HOST/$PORT\"
        count=0
        limit=$LIMIT
        fmt_string=\"$FMT_STRING\r\n\"

        for (i = 0; i < limit; ++i) {
            printf fmt_string, i, i |& serverConnection
            ++count
            serverConnection |& getline
            # We do not need to print output test data
            # print \$0
        }

        close(service)
        print count
    }
    ")
    END=$(date +%s)
    ESTIMATE=$((END - START))
    # Queries per second
    QPS=$((COUNT / ESTIMATE))

    echo "Estimate $ESTIMATE sec ($QPS qps)"
}

get_machine_info

# Hash table
run_test_client "HSET %i_key %i_value"
run_test_client "HGET %i_key"
run_test_client "HDEL %i_key"

# Avl tree
run_test_client "ARSET %i_key %i_value"
run_test_client "ARGET %i_key"
{'fraction_non_alphanumeric': 0.13910969793322733, 'fraction_numerical': 0.015103338632750398, 'mean_word_length': 2.3785234899328858, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '3801263', 'n_tokens_mistral': 925, 'n_tokens_neox': 880, 'n_words': 236}