<commit_before><commit_msg>add benchmark script<commit_after>#!/bin/bash

echo "run this from inside a directory that has the mt-index-cat binary"
echo "before running this, make sure you run the following command and you saw the 'now doing realtime' message"
cat <<EOF
fakemetrics -carbon-tcp-address localhost:2003 -statsd-addr localhost:8125 -shard-org -keys-per-org 100 -speedup 200 -stop-at-now -offset 1h && echo "now doing realtime" && fakemetrics -carbon-tcp-address localhost:2003 -statsd-addr localhost:8125 -shard-org -keys-per-org 100
EOF

echo "and verify http://localhost:3000/dashboard/db/fake-metrics-data"
echo "press any key to continue"
read


function run () {
	local title="$1"
	local port="$2"
	local target="$3"
	local from="$4"
	local rate="$5"
	local duration="$6"
	local sleep="$7"

	echo ">>>> $title"
	./mt-index-cat -prefix 'some.id' -max-age 0 cass -hosts localhost:9042 "GET http://localhost:$port/render?target=$target&format=json&from=-$from\nX-Org-Id: 1\n\n" | vegeta attack -rate $rate -duration $duration | vegeta report
	sleep $sleep
	echo
}


run '1A: MT simple series requests'                      6060 '{{.Name}}'                      1h 10   50s 10s
run '1B: graphite simple series requests'                8080 '{{.Name}}'                      1h 10   50s 10s

run '2A MT sumSeries(patterns.*) (no proxying)'          6060 'sumSeries({{.Name | pattern}})' 1h 250  25s 5s
run '2B same but lower load since graphite cant do much' 6060 'sumSeries({{.Name | pattern}})' 1h 5    25s 5s
run '2C graphite sumSeries(patterns.*)'                  8080 'sumSeries({{.Name | pattern}})' 1h 5    50s 10s

run '3A MT load needing proxying'                        6060 'aliasByNode({{.Name}})'         1h 5    50s 10s
run '3B graphite directly to see proxying overhead'      8080 'aliasByNode({{.Name}})'         1h 5    50s 10s
{'fraction_non_alphanumeric': 0.12816370490037696, 'fraction_numerical': 0.06569736133548734, 'mean_word_length': 2.9871244635193133, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5443204', 'n_tokens_mistral': 698, 'n_tokens_neox': 590, 'n_words': 205}