|
1 | 1 | { writeShellScriptBin, psrecord, writers, python3Packages } : |
2 | 2 |
|
3 | 3 | let |
4 | | - toMarkdown = |
| 4 | + psrecordToMd = |
5 | 5 | writers.writePython3 "psrecord-to-md" |
6 | 6 | { |
7 | 7 | libraries = [ python3Packages.pandas python3Packages.tabulate ]; |
|
35 | 35 |
|
36 | 36 | df.to_markdown(sys.stdout, index=False, tablefmt="github") |
37 | 37 | ''; |
| 38 | + |
| 39 | + csvToMd = |
| 40 | + writers.writePython3 "csv-to-md" |
| 41 | + { |
| 42 | + libraries = [ python3Packages.pandas python3Packages.tabulate ]; |
| 43 | + } |
| 44 | + '' |
| 45 | + import sys |
| 46 | + import pandas as pd |
| 47 | +
|
| 48 | + pd.read_csv(sys.stdin) \ |
| 49 | + .fillna("") \ |
| 50 | + .convert_dtypes() \ |
| 51 | + .to_markdown(sys.stdout, index=False, floatfmt='.0f') |
| 52 | + ''; |
| 53 | + |
38 | 54 | in |
39 | 55 |
|
40 | 56 | writeShellScriptBin "net-loadtest" '' |
41 | 57 | set -euo pipefail |
42 | 58 |
|
43 | | - net-with-nginx xpg psql -c "call wait_for_many_gets()" > /dev/null & |
| 59 | + reqs="" |
| 60 | + batch_size_opt="" |
| 61 | +
|
| 62 | + load_dir=test/load |
| 63 | + mkdir -p $load_dir |
| 64 | + echo "*" >> $load_dir/.gitignore |
| 65 | +
|
| 66 | + record_result=$load_dir/psrecord.md |
| 67 | + query_result=$load_dir/query_out.md |
| 68 | +
|
| 69 | + query_csv=$load_dir/query.csv |
| 70 | + record_log=$load_dir/psrecord.log |
| 71 | +
|
| 72 | + if [ -n "''${1:-}" ]; then |
| 73 | + reqs="$1" |
| 74 | + fi |
| 75 | +
|
| 76 | + if [ -n "''${2:-}" ]; then |
| 77 | + batch_size_opt="-c pg_net.batch_size=$2" |
| 78 | + fi |
| 79 | +
|
| 80 | + net-with-nginx xpg --options "-c log_min_messages=WARNING $batch_size_opt" \ |
| 81 | + psql -c "call wait_for_many_gets($reqs)" -c "\pset format csv" -c "\o $query_csv" -c "select * from pg_net_stats" > /dev/null & |
44 | 82 |
|
45 | 83 | # wait for process to start so we can capture it with psrecord |
46 | 84 | sleep 2 |
47 | 85 |
|
48 | | - record_log=psrecord.log |
49 | | - record_result=psrecord.md |
50 | | -
|
51 | 86 | ${psrecord}/bin/psrecord $(cat build-17/bgworker.pid) --interval 1 --log "$record_log" > /dev/null |
52 | 87 |
|
53 | | - cat $record_log | ${toMarkdown} > $record_result |
| 88 | + echo -e "## Loadtest results\n" |
| 89 | + cat $query_csv | ${csvToMd} |
54 | 90 |
|
55 | | - echo "generated $record_result" |
| 91 | + echo -e "\n\n## Loadtest elapsed seconds vs CPU/MEM\n" |
| 92 | + cat $record_log | ${psrecordToMd} |
56 | 93 | '' |
0 commit comments