# Too tired to write any script,
# just gonna do a gnuplot instead.
set terminal pdfcairo size 4in, 6in
set output "plot.pdf"

set style data histograms
set style histogram rowstacked
set style fill solid 0.2 border -1
set key above noenhanced
set boxwidth 0.66

set autoscale   # Scale axes automatically

set xtics auto
set yrange [0:100]
set xlabel "Commands"
set ylabel "Percentage of Average Latency (%)"

set title \
    "Redis: -O2; SET|GET; 2x KVM; virtio NIC; Preemptive" \
    noenhanced

plot "data.dat" \
       using ($8 / $2 * 100):xtic(1)        title 'afterSleep', \
    "" using (($6 - $7) / $2 * 100)         title 'beforeSleep', \
    "" using ($7 / $2 * 100)                title '_writeToClient', \
    "" using (($2 - $3 - $6 - $8) / $2 * 100) \
        title '<TCP Transmission>' lc rgb "#8F8F8F", \
    "" using (($3 - $4) / $2 * 100)         title 'connSocketEventHandler', \
    "" using (($4 - $5) / $2 * 100)         title 'processCommand', \
    "" using ($5 / $2 * 100)                title '[sg]etCommand'
