#!/bin/bash # Transactions per second for large lists read/write plotter using gnuplot # What do I want to plot? # 1. How long to write 100K entries? # - netconf / restconf # - list / leaf-list # 2. How long to read 100K entries? # - netconf/ restconf # - list / leaf-list # 3. How long to commit 100K entries? (netconf) # - list / leaf-list # 4. In database 100K entries. How many read operations per second? # - netconf/ restconf # - list / leaf-list # 5. 100K entries. How many write operations per second? # - netconf / restconf # - list / leaf-list # 6. 100K entries. How may delete operations per second? # - netconf / restconf # - list / leaf-list # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi #max=2000 # Nr of db entries #step=200 #reqs=500 # Global variables APPNAME=example cfg=$dir/plot-conf.xml fyang=$dir/plot.yang fconfig=$dir/config # For memcheck # clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf" # clixon_netconf="valgrind --tool=callgrind clixon_netconf clixon_netconf=clixon_netconf cat < $fyang module scaling{ yang-version 1.1; namespace "urn:example:clixon"; prefix sc; container x { list y { key "a"; leaf a { type string; } leaf b { type string; } } leaf-list c { type string; } } } EOF cat < $cfg $cfg $dir /usr/local/share/clixon scaling /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/example/$APPNAME.pidfile false $dir false EOF # Run function # args: # where mode is one of: # readlist writelist restreadlist restwritelist runfn(){ nr=$1 # Number of entries in DB reqs=$2 operation=$3 # echo "runfn nr=$nr reqs=$reqs mode=$mode" # new "generate config with $nr list entries" echo -n "replace" > $fconfig for (( i=0; i<$nr; i++ )); do case $mode in readlist|writelist|restreadlist|restwritelist) echo -n "$i$i" >> $fconfig ;; writeleaflist) echo -n "$i" >> $fconfig ;; esac done echo "]]>]]>" >> $fconfig # new "netconf write $nr entry to backend" expecteof_file "$clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^]]>]]>$" case $mode in readlist) # new "netconf GET list $reqs" time -p for (( i=0; i<$reqs; i++ )); do rnd=$(( ( RANDOM % $nr ) )) echo "]]>]]>" done | $clixon_netconf -qf $cfg -y $fyang > /dev/null ;; writelist) # new "netconf WRITE list $reqs" time -p for (( i=0; i<$reqs; i++ )); do rnd=$(( ( RANDOM % $nr ) )) echo "$rnd$rnd]]>]]>" done | $clixon_netconf -qf $cfg -y $fyang > /dev/null ;; restreadlist) # new "restconf GET list $reqs" time -p for (( i=0; i<$reqs; i++ )); do rnd=$(( ( RANDOM % $nr ) )) curl -sSG http://localhost/restconf/data/scaling:x/y=$rnd > /dev/null done ;; writeleaflist) # new "netconf GET leaf-list $reqs" time -p for (( i=0; i<$reqs; i++ )); do rnd=$(( ( RANDOM % $nr ) )) echo "$rnd]]>]]>" done | $clixon_netconf -qf $cfg -y $fyang > /dev/null ;; esac # new "discard test" expecteof "$clixon_netconf -qf $cfg -y $fyang" "]]>]]>" "^]]>]]>$" } # Step # args: stepfn(){ i=$1 reqs=$2 mode=$3 >&2 echo "stepfn $mode: i=$i reqs=$reqs" echo -n "" > $fconfig t=$(TEST=%e runfn $i $reqs $mode 2>&1 | awk '/real/ {print $2}') #TEST=%e runfn $i $reqs $mode 2>&1 # t is time in secs of $reqs -> transactions per second. $reqs p=$(echo "$reqs/$t" | bc -lq) # p is transactions per second. # write to gnuplot file: $dir/$mode echo "$i $p" >> $dir/$mode } # Run once #args: once(){ # Input Parameters step=$1 reqs=$2 max=$3 echo "oncefn step=$step reqs=$reqs max=$max" new "test params: -f $cfg -y $fyang" if [ $BE -ne 0 ]; then new "kill old backend" sudo clixon_backend -zf $cfg -y $fyang if [ $? -ne 0 ]; then err fi new "start backend -s init -f $cfg -y $fyang" start_backend -s init -f $cfg -y $fyang fi new "kill old restconf daemon" sudo pkill -u www-data -f "/www-data/clixon_restconf" new "start restconf daemon" start_restconf -f $cfg -y $fyang new "waiting" sleep $RCWAIT new "Intial steps as start" for (( i=10; i<=$step; i=i+10 )); do stepfn $i $reqs readlist stepfn $i $reqs writelist stepfn $i $reqs restreadlist stepfn $i $reqs writeleaflist done rnd=$(( ( RANDOM % $step ) )) echo "curl -sSG http://localhost/restconf/data/scaling:x/y=$rnd" curl -sSG http://localhost/restconf/data/scaling:x/y=$rnd exit new "Actual steps" for (( i=$step; i<=$max; i=i+$step )); do stepfn $i $reqs readlist stepfn $i $reqs writelist stepfn $i $reqs restreadlist stepfn $i $reqs writeleaflist done new "Kill restconf daemon" stop_restconf if [ $BE -ne 0 ]; then new "Kill backend" # Check if premature kill pid=`pgrep -u root -f clixon_backend` if [ -z "$pid" ]; then err "backend already dead" fi # kill backend stop_backend -f $cfg fi } # step=200 reqs=500 max=2000 once 200 500 1000 gnuplot -persist <