More benchmarking.

More benchmarking.

set terminal svg size 1000, 500
set datafile separator ","
set datafile commentschars "//"
set xtics norotate
set style fill solid
set yrange[0:]
set key off
set boxwidth 0.8
set style histogram clustered gap 3 title
set style data histograms
set bmargin 3

set key right outside
set ylabel "Avg. performance [cycles/byte]"
set yrange [0:16]

set title "EverCrypt Hash Performance (message size 65536 bytes)"
set output 'bench_meta_hash_evercrypt.svg'
plot \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-default-gcc-7/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-7", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-no-asm-gcc-7/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-7", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-default-gcc-8/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-8", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-no-asm-gcc-8/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-8", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-default-clang-7/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-7", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-no-asm-clang-7/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-7", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-default-clang-8/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-8", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-no-asm-clang-8/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-8"

set title "OpenSSL Hash Performance (message size 65536 bytes)"
set output 'bench_meta_hash_openssl.svg'
plot \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-default-gcc-7/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-7", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-no-asm-gcc-7/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-7", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-default-gcc-8/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-8", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-no-asm-gcc-8/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-8", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-default-clang-7/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-7", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-no-asm-clang-7/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-7", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-default-clang-8/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-8", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-no-asm-clang-8/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-8"

set key right outside
set ylabel "Avg. performance [cycles/byte]"
set yrange [0:2]

set title "EverCrypt AEAD Performance (message size 65536 bytes)"
set output 'bench_meta_aead_evercrypt.svg'
plot \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-default-gcc-7/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-7", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-no-asm-gcc-7/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-7", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-default-gcc-8/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-8", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-no-asm-gcc-8/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-8", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-default-clang-7/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-7", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-no-asm-clang-7/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-7", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-default-clang-8/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-8", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-no-asm-clang-8/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-8"

set title "OpenSSL AEAD Performance (message size 65536 bytes)"
set output 'bench_meta_aead_openssl.svg'
plot \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-default-gcc-7/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-7", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-no-asm-gcc-7/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-7", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-default-gcc-8/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-8", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-no-asm-gcc-8/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-8", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-default-clang-7/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-7", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-no-asm-clang-7/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-7", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-default-clang-8/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-8", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-no-asm-clang-8/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-8"

set ylabel "Avg. performance [cycles/byte]"
unset yrange

set title "Ed25519 Performance (message size 65536 bytes)"
set output 'bench_meta_ed25519.svg'
plot \
  'evercrypt-openssl-default-gcc-7/bench_ed25519_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-7", \
  'evercrypt-openssl-no-asm-gcc-7/bench_ed25519_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-7", \
  'evercrypt-openssl-default-gcc-8/bench_ed25519_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-8", \
  'evercrypt-openssl-no-asm-gcc-8/bench_ed25519_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-8", \
  'evercrypt-openssl-default-clang-7/bench_ed25519_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-7", \
  'evercrypt-openssl-no-asm-clang-7/bench_ed25519_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-7", \
  'evercrypt-openssl-default-clang-8/bench_ed25519_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-8", \
  'evercrypt-openssl-no-asm-clang-8/bench_ed25519_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-8"

set ylabel "Avg. performance [cycles/derivation]"
unset yrange

set title "Curve25519 Performance"
set output 'bench_meta_curve25519.svg'
plot \
  'evercrypt-openssl-default-gcc-7/bench_curve25519.csv' using 'Avg':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-7", \
  'evercrypt-openssl-no-asm-gcc-7/bench_curve25519.csv' using 'Avg':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-7", \
  'evercrypt-openssl-default-gcc-8/bench_curve25519.csv' using 'Avg':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-8", \
  'evercrypt-openssl-no-asm-gcc-8/bench_curve25519.csv' using 'Avg':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-8", \
  'evercrypt-openssl-default-clang-7/bench_curve25519.csv' using 'Avg':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-7", \
  'evercrypt-openssl-no-asm-clang-7/bench_curve25519.csv' using 'Avg':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-7", \
  'evercrypt-openssl-default-clang-8/bench_curve25519.csv' using 'Avg':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-8", \
  'evercrypt-openssl-no-asm-clang-8/bench_curve25519.csv' using 'Avg':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-8"

set terminal svg size 1000, 500
set datafile separator ","
set datafile commentschars "//"
set xtics norotate
set style fill solid
set yrange[0:]
set key off
set boxwidth 0.8
set style histogram clustered gap 3 title
set style data histograms
set bmargin 3

set key right outside
set ylabel "Avg. performance [cycles/byte]"
set yrange [0:16]

set title "EverCrypt Hash Performance (message size 65536 bytes)"
set output 'bench_meta_hash_evercrypt.svg'
plot \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-default-gcc-7/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-7", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-no-asm-gcc-7/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-7", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-default-gcc-8/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-8", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-no-asm-gcc-8/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-8", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-default-clang-7/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-7", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-no-asm-clang-7/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-7", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-default-clang-8/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-8", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-no-asm-clang-8/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-8"

set title "OpenSSL Hash Performance (message size 65536 bytes)"
set output 'bench_meta_hash_openssl.svg'
plot \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-default-gcc-7/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-7", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-no-asm-gcc-7/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-7", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-default-gcc-8/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-8", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-no-asm-gcc-8/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-8", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-default-clang-7/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-7", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-no-asm-clang-7/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-7", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-default-clang-8/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-8", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-no-asm-clang-8/bench_hash_all_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-8"

set key right outside
set ylabel "Avg. performance [cycles/byte]"
set yrange [0:30]

set title "EverCrypt AEAD Performance (message size 65536 bytes)"
set output 'bench_meta_aead_evercrypt.svg'
plot \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-default-gcc-7/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-7", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-no-asm-gcc-7/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-7", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-default-gcc-8/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-8", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-no-asm-gcc-8/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-8", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-default-clang-7/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-7", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-no-asm-clang-7/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-7", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-default-clang-8/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-8", \
  '< grep -e "^\"EverCrypt" -e "^\"Provider" evercrypt-openssl-no-asm-clang-8/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-8"

set title "OpenSSL AEAD Performance (message size 65536 bytes)"
set output 'bench_meta_aead_openssl.svg'
plot \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-default-gcc-7/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-7", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-no-asm-gcc-7/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-7", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-default-gcc-8/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-8", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-no-asm-gcc-8/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-8", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-default-clang-7/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-7", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-no-asm-clang-7/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-7", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-default-clang-8/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-8", \
  '< grep -e "^\"OpenSSL" -e "^\"Provider" evercrypt-openssl-no-asm-clang-8/bench_aead_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-8"

set ylabel "Avg. performance [cycles/byte]"
unset yrange

set title "Ed25519 Performance (message size 65536 bytes)"
set output 'bench_meta_ed25519.svg'
plot \
  'evercrypt-openssl-default-gcc-7/bench_ed25519_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-7", \
  'evercrypt-openssl-no-asm-gcc-7/bench_ed25519_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-7", \
  'evercrypt-openssl-default-gcc-8/bench_ed25519_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-8", \
  'evercrypt-openssl-no-asm-gcc-8/bench_ed25519_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-8", \
  'evercrypt-openssl-default-clang-7/bench_ed25519_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-7", \
  'evercrypt-openssl-no-asm-clang-7/bench_ed25519_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-7", \
  'evercrypt-openssl-default-clang-8/bench_ed25519_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-8", \
  'evercrypt-openssl-no-asm-clang-8/bench_ed25519_65536.csv' using 'Avg Cycles/Byte':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-8"

set ylabel "Avg. performance [cycles/derivation]"
unset yrange

set title "Curve25519 Performance"
set output 'bench_meta_curve25519.svg'
plot \
  'evercrypt-openssl-default-gcc-7/bench_curve25519.csv' using 'Avg':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-7", \
  'evercrypt-openssl-no-asm-gcc-7/bench_curve25519.csv' using 'Avg':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-7", \
  'evercrypt-openssl-default-gcc-8/bench_curve25519.csv' using 'Avg':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-gcc-8", \
  'evercrypt-openssl-no-asm-gcc-8/bench_curve25519.csv' using 'Avg':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-gcc-8", \
  'evercrypt-openssl-default-clang-7/bench_curve25519.csv' using 'Avg':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-7", \
  'evercrypt-openssl-no-asm-clang-7/bench_curve25519.csv' using 'Avg':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-7", \
  'evercrypt-openssl-default-clang-8/bench_curve25519.csv' using 'Avg':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-default-clang-8", \
  'evercrypt-openssl-no-asm-clang-8/bench_curve25519.csv' using 'Avg':xticlabels(strcol('Algorithm')) title "evercrypt-openssl-no-asm-clang-8"


Plot file cleanup.

Plot file cleanup.

MPARM = 1
NPARM = 2
KPARM = 3
FLOPS = 8

HIM = -1
HIN = HIM
HIK = HIM
MN = 23
PEAK = 0 #985.6

BASENAME = "smm-test"
FILENAME = system("sh -c \"echo ${FILENAME}\"")
if (FILENAME eq "") {
  FILENAME = BASENAME.".pdf"
}

FILECOUNT = 1 # initial file number
# MULTI =-1: multiple files; no titles
# MULTI = 0: multiple files with titles
# MULTI = 1: single file with titles
MULTI = system("sh -c \"echo ${MULTI}\"")
if (MULTI eq "") {
  MULTI = 1
}

stats BASENAME.".dat" using (column(MPARM)*column(NPARM)*column(KPARM)) nooutput; MNK = STATS_stddev**(1.0/3.0)
stats BASENAME.".dat" using (log(column(FLOPS))) nooutput; GEO = sprintf("%.1f", exp(STATS_sum/STATS_records))
stats BASENAME.".dat" using FLOPS nooutput; MED = sprintf("%.1f", STATS_median)
stats BASENAME.".dat" using NPARM nooutput; XN = int(STATS_max)

MAX(A, B) = A < B ? B : A
IX(I1, J1, NJ) = int(MAX(I1 - 1, 0) * NJ + MAX(J1 - 1, 0))
I1(IX, NJ) = int(IX / NJ) + 1
J1(IX, NJ) = int(IX) % NJ + 1

set table BASENAME."-avg.dat"
plot BASENAME.".dat" using (IX(column(MPARM), column(NPARM), XN)):FLOPS smooth unique
unset table
set table BASENAME."-cdf.dat"
plot BASENAME.".dat" using FLOPS:(1.0) smooth cumulative
unset table
stats BASENAME."-cdf.dat" using (("".strcol(3)."" eq "i")?($2):(1/0)) nooutput; FREQSUM = STATS_max

if (MULTI==1) {
  set output FILENAME
}

FILEEXT = system("sh -c \"echo ".FILENAME." | sed 's/.\\+\\.\\(.\\+\\)/\\1/'\"")
set terminal FILEEXT
set termoption enhanced
#set termoption font ",12"
save_encoding = GPVAL_ENCODING
set encoding utf8

reset
if (MULTI<=0) { set output "".FILECOUNT."-".FILENAME; FILECOUNT = FILECOUNT + 1 }
if (MULTI>-1) { set title "Performance" }
set origin -0.03, 0
set pm3d interpolate 0, 0
#set colorbox horizontal user origin 0, 0.1 size 1, 0.1
set autoscale fix
if (0<HIM) { set xrange [*:HIM] }
if (0<HIN) { set yrange [*:HIN] }
if (0<HIK) { set zrange [*:HIK] }
if (0>HIM) { set xrange [*:MNK] }
if (0>HIN) { set xrange [*:MNK] }
if (0>HIK) { set xrange [*:MNK] }
set xlabel "M"
set ylabel "N" offset -3.0
set zlabel "K" offset 1.0
set ticslevel 0
set cblabel "GFLOP/s" offset 1.5
set format x "%g"; set format y "%g"; set format z "%g"; set format cb "%g"
splot BASENAME.".dat" using MPARM:NPARM:KPARM:FLOPS notitle with points pointtype 7 linetype palette

reset
if (MULTI<=0) { set output "".FILECOUNT."-".FILENAME; FILECOUNT = FILECOUNT + 1 }
if (MULTI>-1) { set title "Performance (K-Average)" }
set origin -0.02, 0
set dgrid3d #9, 9
set pm3d interpolate 0, 0 map
set autoscale fix
set xlabel "M"
set ylabel "N" offset -1.5
set cblabel "GFLOP/s" offset 0.5
set format x "%g"; set format y "%g"; set format cb "%g"
set mxtics 2
splot BASENAME."-avg.dat" using (("".strcol(3)."" eq "i")?(I1($1, XN)):(1/0)):(("".strcol(3)."" eq "i")?(J1($1, XN)):(1/0)):2 notitle with pm3d

reset
if (MULTI<=0) { set output "".FILECOUNT."-".FILENAME; FILECOUNT = FILECOUNT + 1 }
if (MULTI>-1) {
  set title "Performance (CDF)"
  set xlabel "Probability\n\nGeo. Mean: ".GEO." GFLOP/s  Median: ".MED." GFLOP/s"
} else {
  set xlabel "Probability"
}
set ylabel "GFLOP/s"
set format x "%g%%"
set format y "%g"
set fit quiet
f(x) = b * x + a
fit f(x) BASENAME."-cdf.dat" using (("".strcol(3)."" eq "i")?(100*$2/FREQSUM):(1/0)):1 via a, b
g(x) = (x - a) / b
x = 0.5 * (100 + MAX(0, g(0)))
h(x) = d * x + c
fit [x-10.0:x+10.0] h(x) BASENAME."-cdf.dat" using (("".strcol(3)."" eq "i")?(100*$2/FREQSUM):(1/0)):1 via c, d
set arrow 1 from x, h(x) to x, 0
set label 1 sprintf("%.1f%%", x) at x, 0.5 * h(x) left offset 1
set arrow 2 from x, h(x) to 0, h(x)
set label 2 sprintf("%.1f GFLOP/s", h(x)) at 0.5 * x, h(x) centre offset 0, 1
set autoscale fix
set xrange [0:100]
set yrange [0:*]
plot BASENAME."-cdf.dat" using (("".strcol(3)."" eq "i")?(100*$2/FREQSUM):(1/0)):1 notitle with lines

if (0 < PEAK) {
  reset
  if (MULTI<=0) { set output "".FILECOUNT."-".FILENAME; FILECOUNT = FILECOUNT + 1 }
  if (MULTI>-1) { set title "Performance and Efficiency" }
  set xlabel "(M N K)^{-1/3}"
  set ylabel "Efficiency"
  set y2label "GFLOP/s"
  set y2tics
  set ytics nomirror
  set format x "%g"; set format y "%g%%"
  set mxtics 2
  set mytics 2
  set my2tics 2
  set autoscale fix
  set yrange [0:100]
  set y2range [0:PEAK]
  plot BASENAME.".dat" using (floor((column(MPARM)*column(NPARM)*column(KPARM))**(1.0/3.0)+0.5)):(100.0*column(FLOPS)/PEAK) notitle smooth sbezier with points pointtype 7 pointsize 0.5
}

MPARM = 1
NPARM = 2
KPARM = 3
MSIZE = 7
FLOPS = 8

HIM = -1
HIN = HIM
HIK = HIM
MN = 23
PEAK = 0 #985.6

BASENAME = "smm-test"
FILENAME = system("sh -c \"echo ${FILENAME}\"")
if (FILENAME eq "") {
  FILENAME = BASENAME.".pdf"
}

FILECOUNT = 1 # initial file number
# MULTI =-1: multiple files; no titles
# MULTI = 0: multiple files with titles
# MULTI = 1: single file with titles
MULTI = system("sh -c \"echo ${MULTI}\"")
if (MULTI eq "") {
  MULTI = 1
}

stats BASENAME.".dat" using (column(MPARM)*column(NPARM)*column(KPARM)) nooutput; MNK = STATS_stddev**(1.0/3.0)
stats BASENAME.".dat" using (log(column(FLOPS))) nooutput; GEO = sprintf("%.1f", exp(STATS_sum/STATS_records))
stats BASENAME.".dat" using FLOPS nooutput; MED = sprintf("%.1f", STATS_median)
stats BASENAME.".dat" using NPARM nooutput; XN = int(STATS_max)

MAX(A, B) = A < B ? B : A
IX(I1, J1, NJ) = int(MAX(I1 - 1, 0) * NJ + MAX(J1 - 1, 0))
I1(IX, NJ) = int(IX / NJ) + 1
J1(IX, NJ) = int(IX) % NJ + 1

set table BASENAME."-avg.dat"
plot BASENAME.".dat" using (IX(column(MPARM), column(NPARM), XN)):FLOPS smooth unique
unset table
set table BASENAME."-cdf.dat"
plot BASENAME.".dat" using FLOPS:(1.0) smooth cumulative
unset table
stats BASENAME."-cdf.dat" using (("".strcol(3)."" eq "i")?($2):(1/0)) nooutput; FREQSUM = STATS_max

if (MULTI==1) {
  set output FILENAME
}

FILEEXT = system("sh -c \"echo ".FILENAME." | sed 's/.\\+\\.\\(.\\+\\)/\\1/'\"")
set terminal FILEEXT
set termoption enhanced
#set termoption font ",12"
save_encoding = GPVAL_ENCODING
set encoding utf8

reset
if (MULTI<=0) { set output "".FILECOUNT."-".FILENAME; FILECOUNT = FILECOUNT + 1 }
if (MULTI>-1) { set title "Performance" }
set origin -0.03, 0
set pm3d interpolate 0, 0
#set colorbox horizontal user origin 0, 0.1 size 1, 0.1
set autoscale fix
if (0<HIM) { set xrange [*:HIM] }
if (0<HIN) { set yrange [*:HIN] }
if (0<HIK) { set zrange [*:HIK] }
if (0>HIM) { set xrange [*:MNK] }
if (0>HIN) { set xrange [*:MNK] }
if (0>HIK) { set xrange [*:MNK] }
set xlabel "M"
set ylabel "N" offset -3.0
set zlabel "K" offset 1.0
set ticslevel 0
set cblabel "GFLOP/s" offset 1.5
set format x "%g"; set format y "%g"; set format z "%g"; set format cb "%g"
splot BASENAME.".dat" using MPARM:NPARM:KPARM:FLOPS notitle with points pointtype 7 linetype palette

reset
if (MULTI<=0) { set output "".FILECOUNT."-".FILENAME; FILECOUNT = FILECOUNT + 1 }
if (MULTI>-1) { set title "Performance (K-Average)" }
set origin -0.02, 0
set dgrid3d #9, 9
set pm3d interpolate 0, 0 map
set autoscale fix
set xlabel "M"
set ylabel "N" offset -1.5
set cblabel "GFLOP/s" offset 0.5
set format x "%g"; set format y "%g"; set format cb "%g"
set mxtics 2
splot BASENAME."-avg.dat" using (("".strcol(3)."" eq "i")?(I1($1, XN)):(1/0)):(("".strcol(3)."" eq "i")?(J1($1, XN)):(1/0)):2 notitle with pm3d

reset
if (MULTI<=0) { set output "".FILECOUNT."-".FILENAME; FILECOUNT = FILECOUNT + 1 }
if (MULTI>-1) {
  set title "Performance (CDF)"
  set xlabel "Probability\n\nGeo. Mean: ".GEO." GFLOP/s  Median: ".MED." GFLOP/s"
} else {
  set xlabel "Probability"
}
set ylabel "GFLOP/s"
set format x "%g%%"
set format y "%g"
set fit quiet
f(x) = b * x + a
fit f(x) BASENAME."-cdf.dat" using (("".strcol(3)."" eq "i")?(100*$2/FREQSUM):(1/0)):1 via a, b
g(x) = (x - a) / b
x = 0.5 * (100 + MAX(0, g(0)))
h(x) = d * x + c
fit [x-10.0:x+10.0] h(x) BASENAME."-cdf.dat" using (("".strcol(3)."" eq "i")?(100*$2/FREQSUM):(1/0)):1 via c, d
set arrow 1 from x, h(x) to x, 0
set label 1 sprintf("%.1f%%", x) at x, 0.5 * h(x) left offset 1
set arrow 2 from x, h(x) to 0, h(x)
set label 2 sprintf("%.1f GFLOP/s", h(x)) at 0.5 * x, h(x) centre offset 0, 1
set autoscale fix
set xrange [0:100]
set yrange [0:*]
plot BASENAME."-cdf.dat" using (("".strcol(3)."" eq "i")?(100*$2/FREQSUM):(1/0)):1 notitle with lines

if (0 < PEAK) {
  reset
  if (MULTI<=0) { set output "".FILECOUNT."-".FILENAME; FILECOUNT = FILECOUNT + 1 }
  if (MULTI>-1) { set title "Performance and Efficiency" }
  set xlabel "(M N K)^{-1/3}"
  set ylabel "Efficiency"
  set y2label "GFLOP/s"
  set y2tics
  set ytics nomirror
  set format x "%g"; set format y "%g%%"
  set mxtics 2
  set mytics 2
  set my2tics 2
  set autoscale fix
  set yrange [0:100]
  set y2range [0:PEAK]
  plot BASENAME.".dat" using (floor((column(MPARM)*column(NPARM)*column(KPARM))**(1.0/3.0)+0.5)):(100.0*column(FLOPS)/PEAK) notitle smooth sbezier with points pointtype 7 pointsize 0.5
}


update

update

# Tested with gnuplot 4.6 patchlevel 6

set print "-"
FN_IN = system("echo $FN_IN")
COL_IDX_0 = system("echo $COL_IDX_0")
COL_IDX_1 = system("echo $COL_IDX_1")
FN_OUT = system("echo $FN_OUT")
LEGEND_LABELS = system("echo $LEGEND_LABELS")
LABEL_Y_0 = system("echo $LABEL_Y_0")
LABEL_Y_1 = system("echo $LABEL_Y_1")
Y_MAX = system("echo $Y_MAX")
Y_TICS_INTERVAL = system("echo $Y_TICS_INTERVAL")

#print (sprintf("c_lat: %s", c_lat))
# Convert string to int
#   http://stackoverflow.com/questions/9739315/how-to-convert-string-to-number-in-gnuplot
#c_lat=c_lat+0

c_x       = 0               # column(c_x)/1000.0, when c_x=5 is throughput
COL_IDX_0 = COL_IDX_0 + 0	# Convert string to int
COL_IDX_1 = COL_IDX_1 + 0	# Convert string to int
c_sat     = 12              # Saturated (overloaded)

# Get min and max values
#set terminal unknown
#X_MIN=GPVAL_DATA_X_MIN

terminal_size_x=3.5
terminal_size_y=0.5 * terminal_size_x
set terminal pdfcairo enhanced size (terminal_size_x)in, (terminal_size_y)in
set output FN_OUT

set multiplot layout 1,2 title "Disk utilization (%)" offset 0,-0.15

#set tmargin at screen 0.60
set bmargin at screen 0.240
#set lmargin at screen 0.2290
#set rmargin at screen 0.990

set xlabel "Req rate (x 10000 W reqs / simulation time min)" offset 10.7,0
set ylabel LABEL_Y_0 offset 1,0

set border (1 + 2) back lc rgb "#808080"
set xtics nomirror scale 0.5,0 tc rgb "#808080" autofreq 0,2
set ytics nomirror scale 0.5,0 tc rgb "#808080" autofreq 0,Y_TICS_INTERVAL

colors="#FF0000 #0000FF #00BB00 #DD00DD #00A0A0 #606060 #8A2BE2 #DAA520 #000000"

set xrange [0:11]
set yrange [0:Y_MAX]

# Legend
y1=125
y2=y1+10

x0=14
x2=9
legend_label_x(i) = \
(i==1 ? x0-x2 : \
(i==2 ? x0 : \
x0+x2 \
))

legend_arrow_len_half = 1.5
legend_arrow_dot_height_half = 0.5

legend_label2(w) = \
(w eq "ES" ? "EBS SSD only" : \
(w eq "EM" ? "EBS Magnetic only" : \
(w eq "LS" ? "Local SSD only" : \
(w eq "LSES" ? "LS + ES" : \
(w eq "LSEM" ? "LS + EM" : \
"unexpected" \
)))))
legend_label1(i) = legend_label2(word(LEGEND_LABELS, i))

do for [i=1:3] {
set label legend_label1(i) at legend_label_x(i), y1 center font ",10" tc rgb word(colors, i)
set arrow from legend_label_x(i)-legend_arrow_len_half,y2 to legend_label_x(i)+legend_arrow_len_half,y2 nohead lc rgb word(colors, i)
# This doesn't work. Because it is out of the plot range?
#set obj circle at legend_label_x(i),y2 size 4 fc rgb word(colors, i) fs solid 1.0 front;
set arrow from legend_label_x(i),y2+legend_arrow_dot_height_half to legend_label_x(i),y2-legend_arrow_dot_height_half nohead lw 3 lc rgb word(colors, i)
}

lw1=2

plot \
for [i=1:words(FN_IN)] word(FN_IN, i) u (column(c_x)):(column(c_sat) <= 1 ? column(COL_IDX_0) : 1/0) w lp pt 7 ps 0.15 lc rgb word(colors, i) not, \
for [i=1:words(FN_IN)] word(FN_IN, i) u (column(c_x)):(column(c_sat) >= 1 ? column(COL_IDX_0) : 1/0) w l lc rgb word(colors, i) lt 0 lw lw1 not, \
for [i=1:words(FN_IN)] word(FN_IN, i) u (column(c_x)):(column(c_sat) >= 1 ? column(COL_IDX_0) : 1/0) w p pt 6 ps 0.2 lc rgb word(colors, i) not

unset label
unset arrow
unset obj
set ylabel LABEL_Y_1 offset 1,0

plot \
for [i=1:words(FN_IN)] word(FN_IN, i) u (column(c_x)):(column(c_sat) <= 1 ? column(COL_IDX_1) : 1/0) w lp pt 7 ps 0.15 lc rgb word(colors, i) not, \
for [i=1:words(FN_IN)] word(FN_IN, i) u (column(c_x)):(column(c_sat) >= 1 ? column(COL_IDX_1) : 1/0) w l lc rgb word(colors, i) lt 0 lw lw1 not, \
for [i=1:words(FN_IN)] word(FN_IN, i) u (column(c_x)):(column(c_sat) >= 1 ? column(COL_IDX_1) : 1/0) w p pt 6 ps 0.2 lc rgb word(colors, i) not

# Tested with gnuplot 4.6 patchlevel 6

set print "-"
FN_IN = system("echo $FN_IN")
COL_IDX_0 = system("echo $COL_IDX_0")
COL_IDX_1 = system("echo $COL_IDX_1")
FN_OUT = system("echo $FN_OUT")
LEGEND_LABELS = system("echo $LEGEND_LABELS")
LABEL_Y_0 = system("echo $LABEL_Y_0")
LABEL_Y_1 = system("echo $LABEL_Y_1")
Y_MAX = system("echo $Y_MAX")
Y_TICS_INTERVAL = system("echo $Y_TICS_INTERVAL")

#print (sprintf("c_lat: %s", c_lat))
# Convert string to int
#   http://stackoverflow.com/questions/9739315/how-to-convert-string-to-number-in-gnuplot
#c_lat=c_lat+0

c_x       = 0               # column(c_x)/1000.0, when c_x=5 is throughput
COL_IDX_0 = COL_IDX_0 + 0	# Convert string to int
COL_IDX_1 = COL_IDX_1 + 0	# Convert string to int
c_sat     = 12              # Saturated (overloaded)

# Get min and max values
#set terminal unknown
#X_MIN=GPVAL_DATA_X_MIN

terminal_size_x=3.5
terminal_size_y=0.5 * terminal_size_x
set terminal pdfcairo enhanced size (terminal_size_x)in, (terminal_size_y)in
set output FN_OUT

set multiplot layout 1,2 title "Disk utilization (%)" offset 0,-0.15

#set tmargin at screen 0.60
set bmargin at screen 0.240
#set lmargin at screen 0.2290
#set rmargin at screen 0.990

set xlabel "Req rate (x 10000 W reqs / simulation time min)" offset 10.7,0
set ylabel LABEL_Y_0 offset 1,0

set border (1 + 2) back lc rgb "#808080"
set xtics nomirror scale 0.5,0 tc rgb "#808080" autofreq 0,2
set ytics nomirror scale 0.5,0 tc rgb "#808080" autofreq 0,Y_TICS_INTERVAL

colors="#FF0000 #0000FF #00BB00 #DD00DD #00A0A0 #606060 #8A2BE2 #DAA520 #000000"

set xrange [0:11]
set yrange [0:Y_MAX]

# Legend
x4=14
x5=8

y1=125
y2=y1+10

legend_label_x(i) = \
(i==1 ? x4-x5 : \
(i==2 ? x4 : \
x4+x5 \
))

legend_arrow_len_half = 1.5
legend_arrow_dot_height_half = 0.5

legend_label2(w) = \
(w eq "ES" ? "EBS SSD only" : \
(w eq "EM" ? "EBS Magnetic only" : \
(w eq "LS" ? "Local SSD only" : \
(w eq "LSES" ? "LS + ES" : \
(w eq "LSEM" ? "LS + EM" : \
"unexpected" \
)))))
legend_label1(i) = legend_label2(word(LEGEND_LABELS, i))

#set label word(LEGEND_LABELS, i) at legend_label_x(i), y1 center font ",10" tc rgb word(colors, i);

do for [i=1:3] {
set label legend_label1(i) at legend_label_x(i), y1 center font ",10" tc rgb word(colors, i)
set arrow from legend_label_x(i)-legend_arrow_len_half,y2 to legend_label_x(i)+legend_arrow_len_half,y2 nohead lc rgb word(colors, i)
# This doesn't work. Because it is out of the plot range?
#set obj circle at legend_label_x(i),y2 size 4 fc rgb word(colors, i) fs solid 1.0 front;
set arrow from legend_label_x(i),y2+legend_arrow_dot_height_half to legend_label_x(i),y2-legend_arrow_dot_height_half nohead lw 3 lc rgb word(colors, i)
}

lw1=2

plot \
for [i=1:words(FN_IN)] word(FN_IN, i) u (column(c_x)):(column(c_sat) <= 1 ? column(COL_IDX_0) : 1/0) w lp pt 7 ps 0.15 lc rgb word(colors, i) not, \
for [i=1:words(FN_IN)] word(FN_IN, i) u (column(c_x)):(column(c_sat) >= 1 ? column(COL_IDX_0) : 1/0) w l lc rgb word(colors, i) lt 0 lw lw1 not, \
for [i=1:words(FN_IN)] word(FN_IN, i) u (column(c_x)):(column(c_sat) >= 1 ? column(COL_IDX_0) : 1/0) w p pt 6 ps 0.2 lc rgb word(colors, i) not

unset label
unset arrow
unset obj
set ylabel LABEL_Y_1 offset 1,0

plot \
for [i=1:words(FN_IN)] word(FN_IN, i) u (column(c_x)):(column(c_sat) <= 1 ? column(COL_IDX_1) : 1/0) w lp pt 7 ps 0.15 lc rgb word(colors, i) not, \
for [i=1:words(FN_IN)] word(FN_IN, i) u (column(c_x)):(column(c_sat) >= 1 ? column(COL_IDX_1) : 1/0) w l lc rgb word(colors, i) lt 0 lw lw1 not, \
for [i=1:words(FN_IN)] word(FN_IN, i) u (column(c_x)):(column(c_sat) >= 1 ? column(COL_IDX_1) : 1/0) w p pt 6 ps 0.2 lc rgb word(colors, i) not


Update http_headers_v.plt

Update http_headers_v.plt

:- begin_tests(http_headers_v).
:- use_module(http_headers_v).

test(http_headers_list_obj_bug1) :-

   List = [ 'Location' = 'http : //www . facebook . com/unsupportedbrowser',
            'P3P' = 'CP= " Facebook   does   not   have   a   P3P   policy .   Learn   why   here :   http : //fb . me/p3p "',
            'X-Content-Type-Options' = nosniff,
            'X-Frame-Options' = 'DENY',
            'Set-Cookie' = 'datr=KEqyTzuMCfz1GhP8w26-BZg7 ;   expires=Thu ,   15-May-2014   12 : 20 : 56   GMT ;   path=/ ;   domain= . facebook . com ;   httponly',
            'Set-Cookie' = 'lsd=AVqm9Avf ;   path=/ ;   domain= . facebook . com',
            'Content-Type' = 'text/html ;   charset=utf-8',
            'X-FB-Debug' = 'f+bKUUtzin/3WCNVE3tWLoNB0ksWI1iaPqSmhhrIdpk=',
            'Date' = 'Tue ,   15   May   2012   12 : 20 : 56   GMT',
            'Content-Length' = '0',
            'Connection' = close
          ],
   http_headers_list_obj(List, _).

test(list_to_http_headers_v1) :-

   Headers = [date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              transfer_encoding = chunked],
   Headers_Ref = ['Date' = 'Tue, 03 Apr 2012 19:32:50 GMT',
                  'Transfer-Encoding' = chunked],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_general_headers_v, http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   assertion(Headers2 == Headers_Ref).

test(list_to_http_headers_v2) :-

   Headers = ['DatE' = 'Tue, 03 Apr 2012 19:32:50 GMT',
              'Transfer-Encoding' = chunked],
   Headers_Ref = ['Date' = 'Tue, 03 Apr 2012 19:32:50 GMT',
                  'Transfer-Encoding' = chunked],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_general_headers_v, http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   assertion(Headers2 == Headers_Ref).

test(list_to_http_headers_v_functor_form) :-

   Headers = [date('Tue, 03 Apr 2012 19:32:50 GMT'),
              transfer_encoding(chunked)],
   Headers_Ref = ['Date' ='Tue, 03 Apr 2012 19:32:50 GMT',
                  'Transfer-Encoding' = chunked],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_general_headers_v, http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   assertion(Headers2 == Headers_Ref).

test(list_to_http_headers_v_functor_form2) :-

   Headers = ['DatE'('Tue, 03 Apr 2012 19:32:50 GMT'),
              'Transfer-Encoding'(chunked)],
   Headers_Ref = ['Date' ='Tue, 03 Apr 2012 19:32:50 GMT',
                  'Transfer-Encoding' = chunked],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_general_headers_v, http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   assertion(Headers2 == Headers_Ref).

test(list_to_http_request_headers_v1) :-

   Headers = [date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              accept = 'text/html',
              host = 'kogorta.dp.ua',
              transfer_encoding = chunked
              ],
   Headers_Ref = ['Date' ='Tue, 03 Apr 2012 19:32:50 GMT',
                  'Accept' = 'text/html',
                  'Host' = 'kogorta.dp.ua',
                  'Transfer-Encoding' = chunked
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_request_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1).

test(list_to_http_request_headers_v2) :-

   Headers = [accept = 'text/html',
              date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              host = 'kogorta.dp.ua',
              transfer_encoding = chunked
              ],
   Headers_Ref = ['Accept' = 'text/html',
                  'Date' ='Tue, 03 Apr 2012 19:32:50 GMT',
                  'Host' = 'kogorta.dp.ua',
                  'Transfer-Encoding' = chunked
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_request_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1).

test(list_to_http_response_headers_v) :-

   Headers = [date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              location = 'http://kogorta.dp.ua/'
              ],
   Headers_Ref = ['Date' = 'Tue, 03 Apr 2012 19:32:50 GMT',
                  'Location' = 'http://kogorta.dp.ua/'
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_response_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1).

test(list_to_http_invalid_mixed_headers_v) :-

   Headers = [date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              host = 'kogorta.dp.ua',
              location = 'http://kogorta.dp.ua/',
              transfer_encoding = chunked
              ],
   Headers_Ref = ['Date' ='Tue, 03 Apr 2012 19:32:50 GMT',
                  'Host' = 'kogorta.dp.ua',
                  'Location' = 'http://kogorta.dp.ua/',
                  'Transfer-Encoding' = chunked
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [
             http_invalid_mixed_headers_v,
             http_invalid_headers_v,
             http_response_headers_v,
             http_request_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1).

test(list_to_http_invalid_bulk_headers_v1) :-

   Headers = [bulk1 = 1, '' = 3],
   Headers_Ref = ['Bulk1' = 1, '' = 3],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [
             http_invalid_bulk_headers_v,
             http_invalid_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1),
   obj_field(Obj, '@bulk', Bulk_Rev),
   reverse(Bulk_Rev, Bulk),
   assertion(Bulk // body =^= Headers).

test(list_to_http_invalid_bulk_headers_v2) :-

   Headers = [date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              bulk1 = 1,
              transfer_encoding = chunked],
   Headers_Ref = ['Date' ='Tue, 03 Apr 2012 19:32:50 GMT',
                  'Bulk1' = 1,
                  'Transfer-Encoding' = chunked],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [
             http_invalid_bulk_headers_v,
             http_invalid_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers20, Obj),
   msort(Headers20, Headers2),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1),
   obj_field(Obj, '@bulk', Bulk_Rev),
   reverse(Bulk_Rev, Bulk),
   assertion(Bulk // body =^= [bulk1 = 1]).

test(list_to_http_invalid_bulk_headers_v3) :-

   Headers = [date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              accept = 'text/html',
              host = 'kogorta.dp.ua',
              transfer_encoding = chunked,
              bulk1 = 1
              ],
   Headers_Ref = ['Date' = 'Tue, 03 Apr 2012 19:32:50 GMT',
                  'Accept' = 'text/html',
                  'Host' = 'kogorta.dp.ua',
                  'Transfer-Encoding' = chunked,
                  'Bulk1' = 1
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [
             http_invalid_bulk_headers_v,
             http_invalid_headers_v,
             http_request_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers20, Obj),
   msort(Headers20, Headers2),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1),
   obj_field(Obj, '@bulk', Bulk_Rev),
   reverse(Bulk_Rev, Bulk),
   assertion(Bulk // body =^= [bulk1 = 1]).

test(list_to_http_invalid_bulk_headers_v4) :-

   Headers = [bulk1 = 1,
              date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              accept = 'text/html',
              host = 'kogorta.dp.ua',
              transfer_encoding = chunked
              ],
   Headers_Ref = ['Bulk1' = 1,
                  'Date' = 'Tue, 03 Apr 2012 19:32:50 GMT',
                  'Accept' = 'text/html',
                  'Host' = 'kogorta.dp.ua',
                  'Transfer-Encoding' = chunked
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [
             http_invalid_bulk_headers_v,
             http_invalid_headers_v,
             http_request_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers20, Obj),
   msort(Headers20, Headers2),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1),
   obj_field(Obj, '@bulk', Bulk_Rev),
   reverse(Bulk_Rev, Bulk),
   assertion(Bulk // body =^= [bulk1 = 1]).

test(list_to_http_invalid_bulk_headers_v5) :-

   Headers = [bulk1 = 1,
              date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              bulk2 = 2,
              host = 'kogorta.dp.ua',
              bulk3 = 3,
              location = 'http://kogorta.dp.ua/',
              bulk4 = 4,
              transfer_encoding = chunked,
              bulk5 = 5
              ],
   Headers_Ref = ['Bulk1' = 1,
                  'Date' = 'Tue, 03 Apr 2012 19:32:50 GMT',
                  'Bulk2' = 2,
                  'Host' = 'kogorta.dp.ua',
                  'Bulk3' = 3,
                  'Location' = 'http://kogorta.dp.ua/',
                  'Bulk4' = 4,
                  'Transfer-Encoding' = chunked,
                  'Bulk5' = 5
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [
             http_invalid_bulk_headers_v,
             http_invalid_mixed_headers_v,
             http_invalid_headers_v,
             http_response_headers_v,
             http_request_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers20, Obj),
   msort(Headers20, Headers2),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1),
   obj_field(Obj, '@bulk', Bulk_Rev),
   reverse(Bulk_Rev, Bulk),
   assertion(Bulk // body =^=
            [bulk1 = 1, bulk2 = 2, bulk3 = 3,
             bulk4 = 4, bulk5 = 5
            ]).

test(list_to_http_invalid_bulk_headers_v6) :-

   Headers = [date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              bulk1 = 1,
              bulk2 = 2,
              host = 'kogorta.dp.ua',
              bulk3 = 3,
              location = 'http://kogorta.dp.ua/',
              bulk4 = 4,
              transfer_encoding = chunked,
              bulk5 = 5
              ],
   Headers_Ref = ['Date' = 'Tue, 03 Apr 2012 19:32:50 GMT',
                  'Bulk1' = 1,
                  'Bulk2' = 2,
                  'Host' = 'kogorta.dp.ua',
                  'Bulk3' = 3,
                  'Location' = 'http://kogorta.dp.ua/',
                  'Bulk4' = 4,
                  'Transfer-Encoding' = chunked,
                  'Bulk5' = 5
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [
             http_invalid_bulk_headers_v,
             http_invalid_mixed_headers_v,
             http_invalid_headers_v,
             http_response_headers_v,
             http_request_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers20, Obj),
   msort(Headers20, Headers2),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1),
   obj_field(Obj, '@bulk', Bulk_Rev),
   reverse(Bulk_Rev, Bulk),
   assertion(Bulk // body =^=
            [bulk1 = 1, bulk2 = 2, bulk3 = 3,
             bulk4 = 4, bulk5 = 5
            ]).

test(list_to_http_invalid_bulk_headers_v7) :-

   Headers = [
              date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              host = 'kogorta.dp.ua',
              location = 'http://kogorta.dp.ua/',
              bulk1 = 1,
              bulk2 = 2,
              bulk3 = 3,
              bulk4 = 4,
              transfer_encoding = chunked,
              bulk5 = 5
              ],
   Headers_Ref = [
                  'Date' = 'Tue, 03 Apr 2012 19:32:50 GMT',
                  'Host' = 'kogorta.dp.ua',
                  'Location' = 'http://kogorta.dp.ua/',
                  'Bulk1' = 1,
                  'Bulk2' = 2,
                  'Bulk3' = 3,
                  'Bulk4' = 4,
                  'Transfer-Encoding' = chunked,
                  'Bulk5' = 5
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [
             http_invalid_bulk_headers_v,
             http_invalid_mixed_headers_v,
             http_invalid_headers_v,
             http_response_headers_v,
             http_request_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers20, Obj),
   msort(Headers20, Headers2),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1),
   obj_field(Obj, '@bulk', Bulk_Rev),
   reverse(Bulk_Rev, Bulk),
   assertion(Bulk // body =^=
            [bulk1 = 1, bulk2 = 2, bulk3 = 3,
             bulk4 = 4, bulk5 = 5
            ]).

test(repeated_headers1) :-

   Headers = [accept_language = en,
              accept_language = ru
              ],
   Headers_Ref = ['Accept-Language' = en,
                  'Accept-Language' = ru
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_request_headers_v, http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   assertion(Headers2 == Headers_Ref).

test(repeated_headers2) :-

   Headers = [accept_language = 'en, ru'],
   Headers_Ref = ['Accept-Language' = 'en, ru'],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_request_headers_v, http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   assertion(Headers2 == Headers_Ref).

test(repeated_headers3) :-

   Headers = [accept_language = [en, ru]],
   Headers_Ref = ['Accept-Language' = [en, ru]],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_request_headers_v, http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   assertion(Headers2 == Headers_Ref).

:- end_tests(http_headers_v).

:- begin_tests(http_headers_v).
:- use_module(http_headers_v).

test(http_headers_list_obj_bug1) :-

   List = [ 'Location' = 'http : //www . facebook . com/unsupportedbrowser',
            'P3P' = 'CP= " Facebook   does   not   have   a   P3P   policy .   Learn   why   here :   http : //fb . me/p3p "',
            'X-Content-Type-Options' = nosniff,
            'X-Frame-Options' = 'DENY',
            'Set-Cookie' = 'datr=KEqyTzuMCfz1GhP8w26-BZg7 ;   expires=Thu ,   15-May-2014   12 : 20 : 56   GMT ;   path=/ ;   domain= . facebook . com ;   httponly',
            'Set-Cookie' = 'lsd=AVqm9Avf ;   path=/ ;   domain= . facebook . com',
            'Content-Type' = 'text/html ;   charset=utf-8',
            'X-FB-Debug' = 'f+bKUUtzin/3WCNVE3tWLoNB0ksWI1iaPqSmhhrIdpk=',
            'Date' = 'Tue ,   15   May   2012   12 : 20 : 56   GMT',
            'Content-Length' = '0',
            'Connection' = close
          ],
   http_headers_list_obj(List, _).

test(list_to_http_headers_v1) :-

   Headers = [date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              transfer_encoding = chunked],
   Headers_Ref = ['Date' = 'Tue, 03 Apr 2012 19:32:50 GMT',
                  'Transfer-Encoding' = chunked],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_general_headers_v, http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   assertion(Headers2 == Headers_Ref).

test(list_to_http_headers_v2) :-

   Headers = ['DatE' = 'Tue, 03 Apr 2012 19:32:50 GMT',
              'Transfer-Encoding' = chunked],
   Headers_Ref = ['Date' = 'Tue, 03 Apr 2012 19:32:50 GMT',
                  'Transfer-Encoding' = chunked],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_general_headers_v, http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   assertion(Headers2 == Headers_Ref).

test(list_to_http_headers_v_functor_form) :-

   Headers = [date('Tue, 03 Apr 2012 19:32:50 GMT'),
              transfer_encoding(chunked)],
   Headers_Ref = ['Date' ='Tue, 03 Apr 2012 19:32:50 GMT',
                  'Transfer-Encoding' = chunked],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_general_headers_v, http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   assertion(Headers2 == Headers_Ref).

test(list_to_http_headers_v_functor_form2) :-

   Headers = ['DatE'('Tue, 03 Apr 2012 19:32:50 GMT'),
              'Transfer-Encoding'(chunked)],
   Headers_Ref = ['Date' ='Tue, 03 Apr 2012 19:32:50 GMT',
                  'Transfer-Encoding' = chunked],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_general_headers_v, http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   assertion(Headers2 == Headers_Ref).

test(list_to_http_request_headers_v1) :-

   Headers = [date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              accept = 'text/html',
              host = 'kogorta.dp.ua',
              transfer_encoding = chunked
              ],
   Headers_Ref = ['Date' ='Tue, 03 Apr 2012 19:32:50 GMT',
                  'Accept' = 'text/html',
                  'Host' = 'kogorta.dp.ua',
                  'Transfer-Encoding' = chunked
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_request_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1).

test(list_to_http_request_headers_v2) :-

   Headers = [accept = 'text/html',
              date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              host = 'kogorta.dp.ua',
              transfer_encoding = chunked
              ],
   Headers_Ref = ['Accept' = 'text/html',
                  'Date' ='Tue, 03 Apr 2012 19:32:50 GMT',
                  'Host' = 'kogorta.dp.ua',
                  'Transfer-Encoding' = chunked
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_request_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1).

test(list_to_http_response_headers_v) :-

   Headers = [date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              location = 'http://kogorta.dp.ua/'
              ],
   Headers_Ref = ['Date' = 'Tue, 03 Apr 2012 19:32:50 GMT',
                  'Location' = 'http://kogorta.dp.ua/'
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_response_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1).

test(list_to_http_invalid_mixed_headers_v) :-

   Headers = [date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              host = 'kogorta.dp.ua',
              location = 'http://kogorta.dp.ua/',
              transfer_encoding = chunked
              ],
   Headers_Ref = ['Date' ='Tue, 03 Apr 2012 19:32:50 GMT',
                  'Host' = 'kogorta.dp.ua',
                  'Location' = 'http://kogorta.dp.ua/',
                  'Transfer-Encoding' = chunked
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [
             http_invalid_mixed_headers_v,
             http_invalid_headers_v,
             http_response_headers_v,
             http_request_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1).

test(list_to_http_invalid_bulk_headers_v1) :-

   Headers = [bulk1 = 1, '' = 3],
   Headers_Ref = ['Bulk1' = 1, '' = 3],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [
             http_invalid_bulk_headers_v,
             http_invalid_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1),
   obj_field(Obj, '@bulk', Bulk_Rev),
   reverse(Bulk_Rev, Bulk),
   assertion(Bulk == Headers).

test(list_to_http_invalid_bulk_headers_v2) :-

   Headers = [date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              bulk1 = 1,
              transfer_encoding = chunked],
   Headers_Ref = ['Date' ='Tue, 03 Apr 2012 19:32:50 GMT',
                  'Bulk1' = 1,
                  'Transfer-Encoding' = chunked],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [
             http_invalid_bulk_headers_v,
             http_invalid_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers20, Obj),
   msort(Headers20, Headers2),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1),
   obj_field(Obj, '@bulk', Bulk_Rev),
   reverse(Bulk_Rev, Bulk),
   assertion(Bulk == [bulk1 = 1]).

test(list_to_http_invalid_bulk_headers_v3) :-

   Headers = [date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              accept = 'text/html',
              host = 'kogorta.dp.ua',
              transfer_encoding = chunked,
              bulk1 = 1
              ],
   Headers_Ref = ['Date' = 'Tue, 03 Apr 2012 19:32:50 GMT',
                  'Accept' = 'text/html',
                  'Host' = 'kogorta.dp.ua',
                  'Transfer-Encoding' = chunked,
                  'Bulk1' = 1
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [
             http_invalid_bulk_headers_v,
             http_invalid_headers_v,
             http_request_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers20, Obj),
   msort(Headers20, Headers2),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1),
   obj_field(Obj, '@bulk', Bulk_Rev),
   reverse(Bulk_Rev, Bulk),
   assertion(Bulk == [bulk1 = 1]).

test(list_to_http_invalid_bulk_headers_v4) :-

   Headers = [bulk1 = 1,
              date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              accept = 'text/html',
              host = 'kogorta.dp.ua',
              transfer_encoding = chunked
              ],
   Headers_Ref = ['Bulk1' = 1,
                  'Date' = 'Tue, 03 Apr 2012 19:32:50 GMT',
                  'Accept' = 'text/html',
                  'Host' = 'kogorta.dp.ua',
                  'Transfer-Encoding' = chunked
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [
             http_invalid_bulk_headers_v,
             http_invalid_headers_v,
             http_request_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers20, Obj),
   msort(Headers20, Headers2),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1),
   obj_field(Obj, '@bulk', Bulk_Rev),
   reverse(Bulk_Rev, Bulk),
   assertion(Bulk == [bulk1 = 1]).

test(list_to_http_invalid_bulk_headers_v5) :-

   Headers = [bulk1 = 1,
              date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              bulk2 = 2,
              host = 'kogorta.dp.ua',
              bulk3 = 3,
              location = 'http://kogorta.dp.ua/',
              bulk4 = 4,
              transfer_encoding = chunked,
              bulk5 = 5
              ],
   Headers_Ref = ['Bulk1' = 1,
                  'Date' = 'Tue, 03 Apr 2012 19:32:50 GMT',
                  'Bulk2' = 2,
                  'Host' = 'kogorta.dp.ua',
                  'Bulk3' = 3,
                  'Location' = 'http://kogorta.dp.ua/',
                  'Bulk4' = 4,
                  'Transfer-Encoding' = chunked,
                  'Bulk5' = 5
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [
             http_invalid_bulk_headers_v,
             http_invalid_mixed_headers_v,
             http_invalid_headers_v,
             http_response_headers_v,
             http_request_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers20, Obj),
   msort(Headers20, Headers2),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1),
   obj_field(Obj, '@bulk', Bulk_Rev),
   reverse(Bulk_Rev, Bulk),
   assertion(Bulk ==
            [bulk1 = 1, bulk2 = 2, bulk3 = 3,
             bulk4 = 4, bulk5 = 5
            ]).

test(list_to_http_invalid_bulk_headers_v6) :-

   Headers = [date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              bulk1 = 1,
              bulk2 = 2,
              host = 'kogorta.dp.ua',
              bulk3 = 3,
              location = 'http://kogorta.dp.ua/',
              bulk4 = 4,
              transfer_encoding = chunked,
              bulk5 = 5
              ],
   Headers_Ref = ['Date' = 'Tue, 03 Apr 2012 19:32:50 GMT',
                  'Bulk1' = 1,
                  'Bulk2' = 2,
                  'Host' = 'kogorta.dp.ua',
                  'Bulk3' = 3,
                  'Location' = 'http://kogorta.dp.ua/',
                  'Bulk4' = 4,
                  'Transfer-Encoding' = chunked,
                  'Bulk5' = 5
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [
             http_invalid_bulk_headers_v,
             http_invalid_mixed_headers_v,
             http_invalid_headers_v,
             http_response_headers_v,
             http_request_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers20, Obj),
   msort(Headers20, Headers2),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1),
   obj_field(Obj, '@bulk', Bulk_Rev),
   reverse(Bulk_Rev, Bulk),
   assertion(Bulk ==
            [bulk1 = 1, bulk2 = 2, bulk3 = 3,
             bulk4 = 4, bulk5 = 5
            ]).

test(list_to_http_invalid_bulk_headers_v7) :-

   Headers = [
              date = 'Tue, 03 Apr 2012 19:32:50 GMT',
              host = 'kogorta.dp.ua',
              location = 'http://kogorta.dp.ua/',
              bulk1 = 1,
              bulk2 = 2,
              bulk3 = 3,
              bulk4 = 4,
              transfer_encoding = chunked,
              bulk5 = 5
              ],
   Headers_Ref = [
                  'Date' = 'Tue, 03 Apr 2012 19:32:50 GMT',
                  'Host' = 'kogorta.dp.ua',
                  'Location' = 'http://kogorta.dp.ua/',
                  'Bulk1' = 1,
                  'Bulk2' = 2,
                  'Bulk3' = 3,
                  'Bulk4' = 4,
                  'Transfer-Encoding' = chunked,
                  'Bulk5' = 5
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [
             http_invalid_bulk_headers_v,
             http_invalid_mixed_headers_v,
             http_invalid_headers_v,
             http_response_headers_v,
             http_request_headers_v,
             http_general_headers_v,
             http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers20, Obj),
   msort(Headers20, Headers2),
   sort(Headers_Ref, Headers1),
   assertion(Headers2 == Headers1),
   obj_field(Obj, '@bulk', Bulk_Rev),
   reverse(Bulk_Rev, Bulk),
   assertion(Bulk ==
            [bulk1 = 1, bulk2 = 2, bulk3 = 3,
             bulk4 = 4, bulk5 = 5
            ]).

test(repeated_headers1) :-

   Headers = [accept_language = en,
              accept_language = ru
              ],
   Headers_Ref = ['Accept-Language' = en,
                  'Accept-Language' = ru
                 ],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_request_headers_v, http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   assertion(Headers2 == Headers_Ref).

test(repeated_headers2) :-

   Headers = [accept_language = 'en, ru'],
   Headers_Ref = ['Accept-Language' = 'en, ru'],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_request_headers_v, http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   assertion(Headers2 == Headers_Ref).

test(repeated_headers3) :-

   Headers = [accept_language = [en, ru]],
   Headers_Ref = ['Accept-Language' = [en, ru]],
   http_headers_list_obj(Headers, Obj),
   obj_parents(Obj, Parents),
   assertion(Parents ==
            [http_request_headers_v, http_headers_v,
             object_v, object_base_v]),
   http_headers_list_obj(Headers2, Obj),
   assertion(Headers2 == Headers_Ref).

:- end_tests(http_headers_v).


ranging

ranging

#!/usr/bin/env gnuplot

# graph of CPU load

# datafile
ifname = "/tmp/sql13.csv"
ofname = "/tmp/lnxdiagd/site/img/day13.png"

# ******************************************************* General settings *****
# set terminal png font "Vera" 11 size 640,480
set terminal png truecolor enhanced font "Vera" 10 size 640,304
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid front
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
set timestamp 'created: %Y-%m-%d %H:%M' bottom

# ************************************************************* Statistics *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifname using 2 name "X" nooutput
X_min = X_min + utc_offset - 946684800
X_max = X_max + utc_offset - 946684800

stats ifname using 7 name "upY" nooutput
Y_max = upY_max * 1.1

stats ifname using 6 name "dnY" nooutput
Y_min = dnY_max * -1.1

# ************************************************************* Functions ******
# determine delta data
delta(x) = ( xD = x - old_x, old_x = x, xD < 0 ? 0 : xD)
old_x = NaN

# ****************************************************************** Title *****
set title "Network Usage (eth0)"

# ***************************************************************** X-axis *****
set xlabel "Date/Time"       # X-axis label
set xdata time               # Define that data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xtics rotate by 40 right
set xrange [ X_min : X_max ]

# ***************************************************************** Y-axis *****
set ylabel "Usage []"
set yrange [:100]
set autoscale y
set format y "%3.0s %c"
set yrange [ Y_min : Y_max ]

# **************************************************************** Y2-axis *****
# set y2label "Load"
# set autoscale y2
# set y2tics border

# ***************************************************************** Legend *****
set key outside bottom center horizontal box
set key samplen .2
set key reverse Left

# ***************************************************************** Output *****
# set arrow from graph 0,graph 0 to graph 0,graph 1 nohead lc rgb "red" front
# set arrow from graph 1,graph 0 to graph 1,graph 1 nohead lc rgb "green" front
set object 1 rect from screen 0,0 to screen 1,1 behind
set object 1 rect fc rgb "#eeeeee" fillstyle solid 1.0 noborder
set object 2 rect from graph 0,0 to graph 1,1 behind
set object 2 rect fc rgb "#ffffff" fillstyle solid 1.0 noborder
set output ofname

# ***** PLOT *****
set style data boxes
set style fill transparent solid 0.05 noborder

plot ifname \
       using ($2+utc_offset):(delta($6)*-1*8/60) title "Download (eth0)" fc rgb "#33bb0000"  \
  , '' using ($2+utc_offset):(delta($7)*8/60)    title "Upload   (eth0)" fc rgb "#330000bb" \

#!/usr/bin/env gnuplot

# graph of CPU load

# datafile
ifname = "/tmp/sql13.csv"
ofname = "/tmp/lnxdiagd/site/img/day13.png"

# ******************************************************* General settings *****
# set terminal png font "Vera" 11 size 640,480
set terminal png truecolor enhanced font "Vera" 10 size 640,304
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid front
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
set timestamp 'created: %Y-%m-%d %H:%M' bottom

# ************************************************************* Statistics *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifname using 2 name "X" nooutput
X_min = X_min + utc_offset - 946684800
X_max = X_max + utc_offset - 946684800

stats ifname using 7 name "upY" nooutput
Y_max = upY_max * 1.1

stats ifname using 8 name "dnY" nooutput
Y_min = dnY_max * -1.1

# ************************************************************* Functions ******
# determine delta data
delta(x) = ( xD = x - old_x, old_x = x, xD < 0 ? 0 : xD)
old_x = NaN

# ****************************************************************** Title *****
set title "Network Usage (eth0)"

# ***************************************************************** X-axis *****
set xlabel "Date/Time"       # X-axis label
set xdata time               # Define that data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xtics rotate by 40 right
set xrange [ Y_min : Y_max ]

# ***************************************************************** Y-axis *****
set ylabel "Usage []"
set yrange [:100]
set autoscale y
set format y "%3.0s %c"

# **************************************************************** Y2-axis *****
# set y2label "Load"
# set autoscale y2
# set y2tics border

# ***************************************************************** Legend *****
set key outside bottom center horizontal box
set key samplen .2
set key reverse Left

# ***************************************************************** Output *****
# set arrow from graph 0,graph 0 to graph 0,graph 1 nohead lc rgb "red" front
# set arrow from graph 1,graph 0 to graph 1,graph 1 nohead lc rgb "green" front
set object 1 rect from screen 0,0 to screen 1,1 behind
set object 1 rect fc rgb "#eeeeee" fillstyle solid 1.0 noborder
set object 2 rect from graph 0,0 to graph 1,1 behind
set object 2 rect fc rgb "#ffffff" fillstyle solid 1.0 noborder
set output ofname

# ***** PLOT *****
set style data boxes
set style fill transparent solid 0.05 noborder

plot ifname \
       using ($2+utc_offset):(delta($6)*-1*8/60) title "Download (eth0)" fc rgb "#33bb0000"  \
  , '' using ($2+utc_offset):(delta($7)*8/60)    title "Upload   (eth0)" fc rgb "#330000bb" \


optimisation

optimisation


debug scaling

debug scaling

#!/usr/bin/env gnuplot

# graph of memory usage

# datafiles
ifnameh = "/tmp/lnxdiagd/mysql4gnuplot/sql14h.csv"
ifnamed = "/tmp/lnxdiagd/mysql4gnuplot/sql14d.csv"
ifnamew = "/tmp/lnxdiagd/mysql4gnuplot/sql14w.csv"
set output  "/tmp/lnxdiagd/site/img/day14.png"

# ******************************************************* General settings *****
set terminal png enhanced font "Vera,9" size 1280,320
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid front
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
if (GPVAL_VERSION == 4.6) {epoch_compensate = 946684800} else {if (GPVAL_VERSION == 5.0) {epoch_compensate = 0}}
# Positions of split between graphs
LMARG = 0.06
LMPOS = 0.40
MRPOS = 0.73
RMARG = 0.94

min(x,y) = (x < y) ? x : y
max(x,y) = (x > y) ? x : y

# ********************************************************* Statistics (R) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnameh using 1 name "X" nooutput
Xh_min = X_min + utc_offset - epoch_compensate
Xh_max = X_max + utc_offset - epoch_compensate

# stats to be calculated here of column 11 (Swap memory used)
stats ifnameh using 6 name "Yh" nooutput

# ********************************************************* Statistics (M) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamed using 1 name "X" nooutput
Xd_min = X_min + utc_offset - epoch_compensate
Xd_max = X_max + utc_offset - epoch_compensate

# stats to be calculated here of column 11 (Swap memory used)
stats ifnamed using 6 name "Yd" nooutput

# ********************************************************* Statistics (L) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamew using 1 name "X" nooutput
Xw_min = X_min + utc_offset - epoch_compensate
Xw_max = X_max + utc_offset - epoch_compensate

# stats to be calculated here of column 11 (Swap memory used)
stats ifnamew using 6 name "Yw" nooutput

Ymax = max(max(Yd_max, Yh_max), Yw_max) * -1

set multiplot layout 1, 3 title "Memory Usage ".strftime("( %Y-%m-%dT%H:%M:%S )", time(0)+utc_offset)

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       LEFT PLOT: past week
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past week"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%a %d"            # Display time in 24 hour notation on the X axis
set xrange [ Xw_min : Xw_max ]

# ***************************************************************** Y-axis *****
set ylabel "Usage [%]"
set yrange [ Ymax : ]
set format y "%4.0s%c"

# ***************************************************************** Legend *****
set key opaque box inside top left
set key samplen 0.1
set key reverse horizontal Left
set key maxcols 4

# ***************************************************************** Output *****
# set arrow from graph 0,graph 0 to graph 0,graph 1 nohead lc rgb "red" front
# set arrow from graph 1,graph 0 to graph 1,graph 1 nohead lc rgb "green" front
#set object 1 rect from screen 0,0 to screen 1,1 behind
#set object 1 rect fc rgb "#eeeeee" fillstyle solid 1.0 noborder
#set object 2 rect from graph 0,0 to graph 1,1 behind
#set object 2 rect fc rgb "#ffffff" fillstyle solid 1.0 noborder

set lmargin at screen LMARG
set rmargin at screen LMPOS

# ***** PLOT *****
set style data boxes
set style fill solid noborder

plot ifnamew \
      using ($1+utc_offset):($2+$3+$4+$5) title "free"    fc rgb "#229922"  \
  ,'' using ($1+utc_offset):($2+$3+$4)    title "cached"  fc "yellow"       \
  ,'' using ($1+utc_offset):($2+$3)       title "buffers" fc "blue"         \
  ,'' using ($1+utc_offset):2             title "used"    fc rgb "#bb0000"  \
  ,'' using ($1+utc_offset):($6*-1)       title "swap"    fc rgb "#ee0000"  \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                     MIDDLE PLOT:  past day
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past day"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xd_min : Xd_max ]

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set yrange [ Ymax : ]

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set lmargin at screen LMPOS+0.001
set rmargin at screen MRPOS

# ***** PLOT *****
plot ifnamed \
      using ($1+utc_offset):($2+$3+$4+$5) fc rgb "#229922"  \
  ,'' using ($1+utc_offset):($2+$3+$4)    fc "yellow"       \
  ,'' using ($1+utc_offset):($2+$3)       fc "blue"         \
  ,'' using ($1+utc_offset):2             fc rgb "#bb0000"  \
  ,'' using ($1+utc_offset):($6*-1)       fc rgb "#ee0000"  \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      RIGHT PLOT: past hour
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past hour"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xh_min : Xh_max ]
set xtics textcolor rgb "red"

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set yrange [ Ymax : ]

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set lmargin at screen MRPOS+0.001
set rmargin at screen RMARG

# ***** PLOT *****
plot ifnameh \
      using ($1+utc_offset):($2+$3+$4+$5) fc rgb "#229922"  \
  ,'' using ($1+utc_offset):($2+$3+$4)    fc "yellow"       \
  ,'' using ($1+utc_offset):($2+$3)       fc "blue"         \
  ,'' using ($1+utc_offset):2             fc rgb "#bb0000"  \
  ,'' using ($1+utc_offset):($6*-1)      fc rgb "#ee0000"  \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                 FINALIZING
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

unset multiplot

#!/usr/bin/env gnuplot

# graph of memory usage

# datafiles
ifnameh = "/tmp/lnxdiagd/mysql4gnuplot/sql14h.csv"
ifnamed = "/tmp/lnxdiagd/mysql4gnuplot/sql14d.csv"
ifnamew = "/tmp/lnxdiagd/mysql4gnuplot/sql14w.csv"
set output  "/tmp/lnxdiagd/site/img/day14.png"

# ******************************************************* General settings *****
set terminal png enhanced font "Vera,9" size 1280,320
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid front
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
if (GPVAL_VERSION == 4.6) {epoch_compensate = 946684800} else {if (GPVAL_VERSION == 5.0) {epoch_compensate = 0}}
# Positions of split between graphs
LMARG = 0.06
LMPOS = 0.40
MRPOS = 0.73
RMARG = 0.94

min(x,y) = (x < y) ? x : y
max(x,y) = (x > y) ? x : y

# ********************************************************* Statistics (R) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnameh using 1 name "X" nooutput
Xh_min = X_min + utc_offset - epoch_compensate
Xh_max = X_max + utc_offset - epoch_compensate

# stats to be calculated here of column 11 (Swap memory used)
stats ifnameh using 6 name "Yh" nooutput

# ********************************************************* Statistics (M) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamed using 1 name "X" nooutput
Xd_min = X_min + utc_offset - epoch_compensate
Xd_max = X_max + utc_offset - epoch_compensate

# stats to be calculated here of column 11 (Swap memory used)
stats ifnameh using 6 name "Yd" nooutput

# ********************************************************* Statistics (L) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamew using 1 name "X" nooutput
Xw_min = X_min + utc_offset - epoch_compensate
Xw_max = X_max + utc_offset - epoch_compensate

# stats to be calculated here of column 11 (Swap memory used)
stats ifnameh using 6 name "Yw" nooutput

Ymax = max(max(Yd_max, Yh_max), Yw_max) * -1

set multiplot layout 1, 3 title "Memory Usage ".strftime("( %Y-%m-%dT%H:%M:%S )", time(0)+utc_offset)

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       LEFT PLOT: past week
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past week"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%a %d"            # Display time in 24 hour notation on the X axis
set xrange [ Xw_min : Xw_max ]

# ***************************************************************** Y-axis *****
set ylabel "Usage [%]"
set yrange [ Ymax : ]
set format y "%4.0s%c"

# ***************************************************************** Legend *****
set key opaque box inside top left
set key samplen 0.1
set key reverse horizontal Left
set key maxcols 4

# ***************************************************************** Output *****
# set arrow from graph 0,graph 0 to graph 0,graph 1 nohead lc rgb "red" front
# set arrow from graph 1,graph 0 to graph 1,graph 1 nohead lc rgb "green" front
#set object 1 rect from screen 0,0 to screen 1,1 behind
#set object 1 rect fc rgb "#eeeeee" fillstyle solid 1.0 noborder
#set object 2 rect from graph 0,0 to graph 1,1 behind
#set object 2 rect fc rgb "#ffffff" fillstyle solid 1.0 noborder

set lmargin at screen LMARG
set rmargin at screen LMPOS

# ***** PLOT *****
set style data boxes
set style fill solid noborder

plot ifnamew \
      using ($1+utc_offset):($2+$3+$4+$5) title "free"    fc rgb "#229922"  \
  ,'' using ($1+utc_offset):($2+$3+$4)    title "cached"  fc "yellow"       \
  ,'' using ($1+utc_offset):($2+$3)       title "buffers" fc "blue"         \
  ,'' using ($1+utc_offset):2             title "used"    fc rgb "#bb0000"  \
  ,'' using ($1+utc_offset):($6*-1)       title "swap"    fc rgb "#ee0000"  \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                     MIDDLE PLOT:  past day
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past day"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xd_min : Xd_max ]

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set yrange [ Ymax : ]

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set lmargin at screen LMPOS+0.001
set rmargin at screen MRPOS

# ***** PLOT *****
plot ifnamed \
      using ($1+utc_offset):($2+$3+$4+$5) fc rgb "#229922"  \
  ,'' using ($1+utc_offset):($2+$3+$4)    fc "yellow"       \
  ,'' using ($1+utc_offset):($2+$3)       fc "blue"         \
  ,'' using ($1+utc_offset):2             fc rgb "#bb0000"  \
  ,'' using ($1+utc_offset):($6*-1)       fc rgb "#ee0000"  \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      RIGHT PLOT: past hour
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past hour"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xh_min : Xh_max ]
set xtics textcolor rgb "red"

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set yrange [ Ymax : ]

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set lmargin at screen MRPOS+0.001
set rmargin at screen RMARG

# ***** PLOT *****
plot ifnameh \
      using ($1+utc_offset):($2+$3+$4+$5) fc rgb "#229922"  \
  ,'' using ($1+utc_offset):($2+$3+$4)    fc "yellow"       \
  ,'' using ($1+utc_offset):($2+$3)       fc "blue"         \
  ,'' using ($1+utc_offset):2             fc rgb "#bb0000"  \
  ,'' using ($1+utc_offset):($6*-1)      fc rgb "#ee0000"  \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                 FINALIZING
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

unset multiplot