use column 3

use column 3

#!/usr/bin/env gnuplot

# graph of temperature

# datafile
ifnameh = "/tmp/domod/mysql/sql21h.csv"
ifnamed = "/tmp/domod/mysql/sql21d.csv"
ifnamew = "/tmp/domod/mysql/sql21w.csv"
set output ofname = "/tmp/domod/site/img/day21.png"

# ******************************************************* General settings *****
set terminal png truecolor enhanced font "Vera" 9 size 1280,320
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
# Positions of split between graphs
LMPOS = 0.40
MRPOS = 0.75

# ********************************************************* Statistics (R) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnameh using 2 name "X" nooutput

Xh_min = X_min + utc_offset - 946684800
Xh_max = X_max + utc_offset - 946684800

# stats to be calculated here for Y-axes
#stats ifnameh using 3 name "Y" nooutput
#Yh_min = Y_min * 0.90
#Yh_max = Y_max * 1.10

# ********************************************************* Statistics (M) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamed using 2 name "X" nooutput

Xd_min = X_min + utc_offset - 946684800
Xd_max = X_max + utc_offset - 946684800

# stats to be calculated here for Y-axes
#stats ifnamed using 3 name "Y" nooutput
#Yd_min = Y_min * 0.90
#Yd_max = Y_max * 1.10

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

# stats for Y-axis
stats ifnamew using 3 name "Y" nooutput
Yw_min = Y_min -1
Yw_max = Y_max +1

set multiplot layout 1, 3 title "Temperature (DS18B20) -=- ".strftime("%Y-%m-%d %H:%M", time(0))

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       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 "Temperature [degC]"
set yrange [ Yw_min : Yw_max ]

# ***************************************************************** Legend *****
set key inside top left horizontal box
set key samplen 1
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 rmargin at screen LMPOS

# ***** PLOT *****
plot ifnamew \
      using ($2+utc_offset):3 title " Temperature [degC]" with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                     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 [ Yw_min : Yw_max ]

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

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

# ***** PLOT *****
plot ifnamed \
      using ($2+utc_offset):3 with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      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 ]

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

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

# ***************************************************************** Output *****
set lmargin at screen MRPOS+0.001
set rmargin -1

# ***** PLOT *****
plot ifnameh \
      using ($2+utc_offset):3 with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

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

unset multiplot

#!/usr/bin/env gnuplot

# graph of temperature

# datafile
ifnameh = "/tmp/domod/mysql/sql21h.csv"
ifnamed = "/tmp/domod/mysql/sql21d.csv"
ifnamew = "/tmp/domod/mysql/sql21w.csv"
set output ofname = "/tmp/domod/site/img/day21.png"

# ******************************************************* General settings *****
set terminal png truecolor enhanced font "Vera" 9 size 1280,320
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
# Positions of split between graphs
LMPOS = 0.40
MRPOS = 0.75

# ********************************************************* Statistics (R) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnameh using 2 name "X" nooutput

Xh_min = X_min + utc_offset - 946684800
Xh_max = X_max + utc_offset - 946684800

# stats to be calculated here for Y-axes
#stats ifnameh using 4 name "Y" nooutput
#Yh_min = Y_min * 0.90
#Yh_max = Y_max * 1.10

# ********************************************************* Statistics (M) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamed using 2 name "X" nooutput

Xd_min = X_min + utc_offset - 946684800
Xd_max = X_max + utc_offset - 946684800

# stats to be calculated here for Y-axes
#stats ifnamed using 4 name "Y" nooutput
#Yd_min = Y_min * 0.90
#Yd_max = Y_max * 1.10

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

# stats for Y-axis
stats ifnamew using 4 name "Y" nooutput
Yw_min = Y_min -1
Yw_max = Y_max +1

set multiplot layout 1, 3 title "Temperature (DS18B20) -=- ".strftime("%Y-%m-%d %H:%M", time(0))

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       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 "Temperature [degC]"
set yrange [ Yw_min : Yw_max ]

# ***************************************************************** Legend *****
set key inside top left horizontal box
set key samplen 1
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 rmargin at screen LMPOS

# ***** PLOT *****
plot ifnamew \
      using ($2+utc_offset):4 title " Temperature [degC]" with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                     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 [ Yw_min : Yw_max ]

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

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

# ***** PLOT *****
plot ifnamed \
      using ($2+utc_offset):4 with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      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 ]

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

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

# ***************************************************************** Output *****
set lmargin at screen MRPOS+0.001
set rmargin -1

# ***** PLOT *****
plot ifnameh \
      using ($2+utc_offset):4 with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

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

unset multiplot


Dynamic color setting.

Dynamic color setting.

### TODO: 2014_income_vs_expenses.dat -> 2014 / income_vs_expenses = year for a group of
### histograms / plottitle
### plot setup
#set terminal pngcairo transparent enhanced font "inconsolata,10" fontscale 1.0 size 500, 350
set terminal pngcairo size 800,600 enhanced font 'Liberation Mono,10' background "#002b36"
set output 'test.png'

STARTCOL=2
ENDCOL=4
GAPSIZE=5
NCOL=ENDCOL-STARTCOL+1
BOXWIDTH=1./(GAPSIZE+NCOL)
COLORS = "red green gray"

#set border 3 front linetype -1 linewidth 1.000
set boxwidth BOXWIDTH absolute
set style fill solid 1.00 border lt -1
set grid nopolar
set grid noxtics nomxtics ytics nomytics noztics nomztics \
 nox2tics nomx2tics noy2tics nomy2tics nocbtics nomcbtics
set grid layerdefault linetype 0 linewidth 1.000,  linetype 0 linewidth 1.000
set xzeroaxis linetype 0 linewidth 1.000
set yzeroaxis linetype 0 linewidth 1.000
set zzeroaxis linetype 0 linewidth 1.000

### legend
set key bmargin center horizontal Left reverse noenhanced autotitles columnhead nobox

### Set tics and histograms
set style histogram clustered gap 4 title  offset character 2, 0.25, 0
set datafile missing '-'
set style data histograms
set xtics border in scale 0,0 nomirror rotate by -45  offset character 0, 0, 0 autojustify
set xtics  norangelimit font ",8"
set xtics   ()
set ytics border in scale 0,0 mirror norotate  offset character 0, 0, 0 autojustify
set ztics border in scale 0,0 nomirror norotate  offset character 0, 0, 0 autojustify
set cbtics border in scale 0,0 mirror norotate  offset character 0, 0, 0 autojustify
set rtics axis in scale 0,0 nomirror norotate  offset character 0, 0, 0 autojustify

# TODO: the below text is variable
set title "income\_vs\_expenses\n(Extra info here?)"
# TODO: the below text is variable
#set xlabel "(Note: )"
set xlabel  offset character 0, -2, 0 font "" textcolor lt -1 norotate
# TODO: the below text is variable
set ylabel "Value (EUR)"
x = 0.0
i = 23
### the plot
## Last datafile plotted: "data.dat"
#plot newhistogram "Northern Europe", 'data.dat' using "Sweden":xtic(1) t col, '' u "Denmark" t col, '' u "Norway" t col, newhistogram "Southern Europe", '' u "Greece":xtic(1) t col, '' u "Romania" t col, '' u "Yugoslavia" t col, newhistogram "British Isles", '' u "Ireland":xtic(1) t col, '' u "United_Kingdom" t col
# TODO: the below texts and colors are variable
#plot 'test.dat' using "income":xtic(1) t col lc "#586e75", '' u "expenses" t col lc "#cb4b16", '' u "difference" t col lc "#93a1a1"
#plot 'test.dat' using "income":xtic(1) t col lc "green", '' u "expenses" t col lc "red", '' u "difference" t col lc "gray"
#plot for [COL=STARTCOL:ENDCOL] 'test.dat' using COL:xtic(1) t col lc "green", '' u  t col lc "red", '' u "difference" t col lc "gray"
plot for [COL=STARTCOL:ENDCOL] 'test.dat' u COL:xtic(1) w histogram title columnheader(COL) lc rgb word(COLORS, COL), \
    for [COL=STARTCOL:ENDCOL] 'test.dat' u (column(0)+BOXWIDTH*(COL-STARTCOL+GAPSIZE/2+1)-0.5):COL:COL notitle w labels

### TODO: 2014_income_vs_expenses.dat -> 2014 / income_vs_expenses = year for a group of
### histograms / plottitle
### plot setup
#set terminal pngcairo transparent enhanced font "inconsolata,10" fontscale 1.0 size 500, 350
set terminal pngcairo size 800,600 enhanced font 'Liberation Mono,10' background "#002b36"
set output 'test.png'

STARTCOL=2
ENDCOL=4
GAPSIZE=5
NCOL=ENDCOL-STARTCOL+1
BOXWIDTH=1./(GAPSIZE+NCOL)

#set border 3 front linetype -1 linewidth 1.000
set boxwidth BOXWIDTH absolute
set style fill solid 1.00 border lt -1
set grid nopolar
set grid noxtics nomxtics ytics nomytics noztics nomztics \
 nox2tics nomx2tics noy2tics nomy2tics nocbtics nomcbtics
set grid layerdefault linetype 0 linewidth 1.000,  linetype 0 linewidth 1.000
set xzeroaxis linetype 0 linewidth 1.000
set yzeroaxis linetype 0 linewidth 1.000
set zzeroaxis linetype 0 linewidth 1.000

### legend
set key bmargin center horizontal Left reverse noenhanced autotitles columnhead nobox

### Set tics and histograms
set style histogram clustered gap 4 title  offset character 2, 0.25, 0
set datafile missing '-'
set style data histograms
set xtics border in scale 0,0 nomirror rotate by -45  offset character 0, 0, 0 autojustify
set xtics  norangelimit font ",8"
set xtics   ()
set ytics border in scale 0,0 mirror norotate  offset character 0, 0, 0 autojustify
set ztics border in scale 0,0 nomirror norotate  offset character 0, 0, 0 autojustify
set cbtics border in scale 0,0 mirror norotate  offset character 0, 0, 0 autojustify
set rtics axis in scale 0,0 nomirror norotate  offset character 0, 0, 0 autojustify

# TODO: the below text is variable
set title "income\_vs\_expenses\n(Extra info here?)"
# TODO: the below text is variable
#set xlabel "(Note: )"
set xlabel  offset character 0, -2, 0 font "" textcolor lt -1 norotate
# TODO: the below text is variable
set ylabel "Value (EUR)"
x = 0.0
i = 23
### the plot
## Last datafile plotted: "data.dat"
#plot newhistogram "Northern Europe", 'data.dat' using "Sweden":xtic(1) t col, '' u "Denmark" t col, '' u "Norway" t col, newhistogram "Southern Europe", '' u "Greece":xtic(1) t col, '' u "Romania" t col, '' u "Yugoslavia" t col, newhistogram "British Isles", '' u "Ireland":xtic(1) t col, '' u "United_Kingdom" t col
# TODO: the below texts and colors are variable
#plot 'test.dat' using "income":xtic(1) t col lc "#586e75", '' u "expenses" t col lc "#cb4b16", '' u "difference" t col lc "#93a1a1"
#plot 'test.dat' using "income":xtic(1) t col lc "green", '' u "expenses" t col lc "red", '' u "difference" t col lc "gray"
#plot for [COL=STARTCOL:ENDCOL] 'test.dat' using COL:xtic(1) t col lc "green", '' u  t col lc "red", '' u "difference" t col lc "gray"
plot for [COL=STARTCOL:ENDCOL] 'test.dat' u COL:xtic(1) w histogram title columnheader(COL), \
    for [COL=STARTCOL:ENDCOL] 'test.dat' u (column(0)+BOXWIDTH*(COL-STARTCOL+GAPSIZE/2+1)-0.5):COL:COL notitle w labels


Tests.

Tests.

:- include(misc(common)).

:- begin_tests('bson_decoder:bson_to_term/2').

test('empty doc', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0 % End of top doc.
    ],
    Expected =
    [
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('valid utf8', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x02, % String tag.
            0xc3,0xa4, 0, % Ename, "ä\0".
            6,0,0,0, % String's byte length, incl. nul.
            0xc3,0xa4, 0, 0xc3,0xa4, 0, % String data, "ä\0ä\0".
        0 % End of top doc.
    ],
    Expected =
    [
        'ä': 'ä\0ä'
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('nuls not allowed in ename', [throws(bson_error(_))]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x02, % String tag.
            0xc3,0xa4, 0, 0xc3,0xa4, 0, % Ename, "ä\0ä\0".
            3,0,0,0, % String's byte length, incl. nul.
            0xc3,0xa4, 0, % String data, "ä\0".
        0 % End of top doc.
    ],
    bson_decoder:bson_to_term(Bson, _Got).

test('int32 positive', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x10, % Int32 tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            32,0,0,0, % Int32 data, 32.
        0 % End of top doc.
    ],
    Expected =
    [
        hello: 32
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('int32 negative', [true(Got == Expected)]) :-
    Bson =
    [
        16,0,0,0, % Length of top doc.
        0x10, % Int32 tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            0xE0,0xFF,0xFF,0xFF, % Int32 data, -32.
        0 % End of top doc.
    ],
    Expected =
    [
        hello: -32
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('int64 positive', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x12, % Int64 tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            32,0,0,0, 0,0,0,0, % Int64 data, 32.
        0 % End of top doc.
    ],
    Expected =
    [
        hello: 32
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('int64 negative', [true(Got == Expected)]) :-
    Bson =
    [
        20,0,0,0, % Length of top doc.
        0x12, % Int64 tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, % Int64 data, -32.
        0 % End of top doc.
    ],
    Expected =
    [
        hello: -32
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('float', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x01, % Double tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            51,51,51,51, 51,51,20,64, % Double data, 5.05.
        0 % End of top doc.
    ],
    Expected =
    [
        hello: 5.05
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('embedded doc', [true(Got == Expected)]) :-
    Bson =
    [
        49,0,0,0, % Length of top doc.
        0x03, % Embedded doc tag.
            66,83,79,78, 0, % Ename "BSON\0".
            38,0,0,0, % Length of embedded doc (array).
            0x02, % String tag.
                48, 0, % Ename, index 0 ("0\0").
                8,0,0,0, % String's byte length, incl. nul.
                97,119,101,115,111,109,101, 0, % String data, "awesome\0".
            0x01, % Double tag.
                49, 0, % Ename, index 1 ("1\0").
                51,51,51,51,51,51,20,64, % Double 8-byte data, 5.05.
            0x10, % Int32 tag.
                50, 0, % Ename, index 2 ("2\0").
                194,7,0,0, % Int32 data, 1986.
            0, % End of embedded doc (array).
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON':
            [
                '0': 'awesome',
                '1': 5.05,
                '2': 1986
            ]
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('embedded array', [true(Got == Expected)]) :-
    Bson =
    [
        49,0,0,0, % Length of top doc.
        0x04, % Array tag.
            66,83,79,78, 0, % Ename "BSON\0".
            38,0,0,0, % Length of embedded doc (array).
            0x02, % String tag.
                48, 0, % Ename, index 0 ("0\0").
                8,0,0,0, % String's byte length, incl. nul.
                97,119,101,115,111,109,101, 0, % String data, "awesome\0".
            0x01, % Double tag.
                49, 0, % Ename, index 1 ("1\0").
                51,51,51,51,51,51,20,64, % Double 8-byte data, 5.05.
            0x10, % Int32 tag.
                50, 0, % Ename, index 2 ("2\0").
                194,7,0,0, % Int32 data, 1986.
            0, % End of embedded doc (array).
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON':
            [
                '0': 'awesome',
                '1': 5.05,
                '2': 1986
            ]
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('binary, generic', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x05, % Binary tag.
            66,83,79,78, 0, % Ename "BSON\0".
            5,0,0,0, % Length of binary data.
            0x00, % Subtype generic (default).
            0,1,2,1,0, % Binary data.
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON': binary(generic, [0,1,2,1,0])
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('binary, function', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x05, % Binary tag.
            66,83,79,78, 0, % Ename "BSON\0".
            5,0,0,0, % Length of binary data.
            0x01, % Subtype function.
            0,1,2,1,0, % Binary data.
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON': binary(function, [0,1,2,1,0])
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('binary, old generic', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x05, % Binary tag.
            66,83,79,78, 0, % Ename "BSON\0".
            5,0,0,0, % Length of binary data.
            0x02, % Subtype old generic.
            0,1,2,1,0, % Binary data.
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON': binary(old_generic, [0,1,2,1,0])
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('binary, uuid', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x05, % Binary tag.
            66,83,79,78, 0, % Ename "BSON\0".
            5,0,0,0, % Length of binary data.
            0x03, % Subtype UUID.
            0,1,2,1,0, % Binary data.
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON': binary(uuid, [0,1,2,1,0])
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('binary, md5', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x05, % Binary tag.
            66,83,79,78, 0, % Ename "BSON\0".
            5,0,0,0, % Length of binary data.
            0x05, % Subtype MD5.
            0,1,2,1,0, % Binary data.
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON': binary(md5, [0,1,2,1,0])
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('binary, user defined', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x05, % Binary tag.
            66,83,79,78, 0, % Ename "BSON\0".
            5,0,0,0, % Length of binary data.
            0x80, % Subtype user defined.
            0,1,2,1,0, % Binary data.
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON': binary(user_defined, [0,1,2,1,0])
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('binary, user defined', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x07, % ObjectID tag.
            66,83,79,78, 0, % Ename "BSON\0".
            0x47,0xcc,0x67,0x09, % ObjectID, time.
            0x34,0x75,0x06,      % ObjectID, machine.
            0x1e,0x3d,           % ObjectID, pid.
            0x95,0x36,0x9d,      % ObjectID, inc.
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON': object_id('47cc67093475061e3d95369d')
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('js', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x0D, % JS tag.
            106,115, 0, % Ename "js\0".
            9,0,0,0, % String's byte length, incl. nul.
            99,111,100,101,32,46,46,46, 0, % String data, "code ...\0".
        0 % End of top doc.
    ],
    Expected =
    [
        js: js('code ...')
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('js with scope', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x0F, % JS with scope tag.
            106,115, 0, % Ename "js\0".
            6,6,6,6, % int xxx
            9,0,0,0, % String's byte length, incl. nul.
            99,111,100,101,32,46,46,46, 0, % String data, "code ...\0".
                xxx_not_impl,0,0,0, % Length of embedded doc.
                0x10, % Int32 tag
                    104,101,108,108,111, 0, % Ename "hello\0".
                    32,0,0,0, % Int32 data, 32.
                0, % End of embedded doc.
        0 % End of top doc.
    ],
    Expected =
    [
        js: js('code ...', ['hello':32])
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('undefined', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x06, % Undefined tag.
            104,101,108,108,111, 0, % Ename "hello\0".
        0 % End of top doc.
    ],
    Expected =
    [
        hello: undefined
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('boolean true', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x08, % Boolean tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            1, % Boolean data, true.
        0 % End of top doc.
    ],
    Expected =
    [
        hello: true
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('boolean false', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x08, % Boolean tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            0, % Boolean data, false.
        0 % End of top doc.
    ],
    Expected =
    [
        hello: false
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('utc datetime', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x09, % UTC datetime tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            0,0,0,0, 0,0,0,0, % UTC datetime data, 0. XXX better
        0 % End of top doc.
    ],
    Expected =
    [
        hello: utc(0)
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('boolean invalid', [throws(bson_error(invalid_boolean))]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x08, % Boolean tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            2, % Boolean data, INVALID.
        0 % End of top doc.
    ],
    bson_decoder:bson_to_term(Bson, _Got).

test('null', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x0A, % Null tag.
            104,101,108,108,111, 0, % Ename "hello\0".
        0 % End of top doc.
    ],
    Expected =
    [
        hello: null
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('regex', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x0B, % Regex tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            97, 0,  % Regex pattern, "a\0".
            105, 0, % Regex options, "i\0".
        0 % End of top doc.
    ],
    Expected =
    [
        hello: regex('a','i')
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('db pointer', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x0C, % DBPointer tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            2,0,0,0, % String's byte length, incl. nul.
            97, 0, % String data, "a\0".
            0x47,0xcc,0x67,0x09, % ObjectID, time.
            0x34,0x75,0x06,      % ObjectID, machine.
            0x1e,0x3d,           % ObjectID, pid.
            0x95,0x36,0x9d,      % ObjectID, inc.
        0 % End of top doc.
    ],
    Expected =
    [
        hello: db_pointer('a', '47cc67093475061e3d95369d')
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('symbol', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x0E, % Symbol tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            5,0,0,0, % String's byte length, incl. nul.
            97,116,111,109, 0, % String data, "atom\0".
        0 % End of top doc.
    ],
    Expected =
    [
        hello: symbol(atom)
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('mongostamp', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x11, % Mongostamp tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            0,0,0,0, 0,0,0,0, % Int64 mongostamp data, 0.
        0 % End of top doc.
    ],
    Expected =
    [
        hello: mongostamp(0)
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('min', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0xFF, % Min key tag.
            104,101,108,108,111, 0, % Ename "hello\0".
        0 % End of top doc.
    ],
    Expected =
    [
        hello: min
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('max', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x7F, % Max key tag.
            104,101,108,108,111, 0, % Ename "hello\0".
        0 % End of top doc.
    ],
    Expected =
    [
        hello: max
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('invalid bson, missing terminating nul', [throws(bson_error(invalid))]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x10, % Int32 tag
            104,101,108,108,111, 0, % Ename "hello\0".
            32,0,0,0 % Int32 data, 32.
        % Missing nul at end-of-doc.
    ],
    bson_decoder:bson_to_term(Bson, _Got).

:- end_tests('bson_decoder:bson_to_term/2').

:- include(misc(common)).

:- begin_tests('bson_decoder:bson_to_term/2').

test('empty doc', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0 % End of top doc.
    ],
    Expected =
    [
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('valid utf8', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x02, % String tag.
            0xc3,0xa4, 0, % Ename, "ä\0".
            6,0,0,0, % String's byte length, incl. nul.
            0xc3,0xa4, 0, 0xc3,0xa4, 0, % String data, "ä\0ä\0".
        0 % End of top doc.
    ],
    Expected =
    [
        'ä': 'ä\0ä'
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('nuls not allowed in ename', [throws(bson_error(_))]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x02, % String tag.
            0xc3,0xa4, 0, 0xc3,0xa4, 0, % Ename, "ä\0ä\0".
            3,0,0,0, % String's byte length, incl. nul.
            0xc3,0xa4, 0, % String data, "ä\0".
        0 % End of top doc.
    ],
    bson_decoder:bson_to_term(Bson, _Got).

test('int32', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x10, % Int32 tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            32,0,0,0, % Int32 data, 32.
        0 % End of top doc.
    ],
    Expected =
    [
        hello: 32
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('int64', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x12, % Int64 tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            32,0,0,0, 0,0,0,0, % Int64 data, 32.
        0 % End of top doc.
    ],
    Expected =
    [
        hello: 32
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('float', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x01, % Double tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            51,51,51,51, 51,51,20,64, % Double data, 5.05.
        0 % End of top doc.
    ],
    Expected =
    [
        hello: 5.05
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('embedded doc', [true(Got == Expected)]) :-
    Bson =
    [
        49,0,0,0, % Length of top doc.
        0x03, % Embedded doc tag.
            66,83,79,78, 0, % Ename "BSON\0".
            38,0,0,0, % Length of embedded doc (array).
            0x02, % String tag.
                48, 0, % Ename, index 0 ("0\0").
                8,0,0,0, % String's byte length, incl. nul.
                97,119,101,115,111,109,101, 0, % String data, "awesome\0".
            0x01, % Double tag.
                49, 0, % Ename, index 1 ("1\0").
                51,51,51,51,51,51,20,64, % Double 8-byte data, 5.05.
            0x10, % Int32 tag.
                50, 0, % Ename, index 2 ("2\0").
                194,7,0,0, % Int32 data, 1986.
            0, % End of embedded doc (array).
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON':
            [
                '0': 'awesome',
                '1': 5.05,
                '2': 1986
            ]
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('embedded array', [true(Got == Expected)]) :-
    Bson =
    [
        49,0,0,0, % Length of top doc.
        0x04, % Array tag.
            66,83,79,78, 0, % Ename "BSON\0".
            38,0,0,0, % Length of embedded doc (array).
            0x02, % String tag.
                48, 0, % Ename, index 0 ("0\0").
                8,0,0,0, % String's byte length, incl. nul.
                97,119,101,115,111,109,101, 0, % String data, "awesome\0".
            0x01, % Double tag.
                49, 0, % Ename, index 1 ("1\0").
                51,51,51,51,51,51,20,64, % Double 8-byte data, 5.05.
            0x10, % Int32 tag.
                50, 0, % Ename, index 2 ("2\0").
                194,7,0,0, % Int32 data, 1986.
            0, % End of embedded doc (array).
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON':
            [
                '0': 'awesome',
                '1': 5.05,
                '2': 1986
            ]
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('binary, generic', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x05, % Binary tag.
            66,83,79,78, 0, % Ename "BSON\0".
            5,0,0,0, % Length of binary data.
            0x00, % Subtype generic (default).
            0,1,2,1,0, % Binary data.
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON': binary(generic, [0,1,2,1,0])
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('binary, function', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x05, % Binary tag.
            66,83,79,78, 0, % Ename "BSON\0".
            5,0,0,0, % Length of binary data.
            0x01, % Subtype function.
            0,1,2,1,0, % Binary data.
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON': binary(function, [0,1,2,1,0])
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('binary, old generic', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x05, % Binary tag.
            66,83,79,78, 0, % Ename "BSON\0".
            5,0,0,0, % Length of binary data.
            0x02, % Subtype old generic.
            0,1,2,1,0, % Binary data.
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON': binary(old_generic, [0,1,2,1,0])
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('binary, uuid', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x05, % Binary tag.
            66,83,79,78, 0, % Ename "BSON\0".
            5,0,0,0, % Length of binary data.
            0x03, % Subtype UUID.
            0,1,2,1,0, % Binary data.
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON': binary(uuid, [0,1,2,1,0])
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('binary, md5', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x05, % Binary tag.
            66,83,79,78, 0, % Ename "BSON\0".
            5,0,0,0, % Length of binary data.
            0x05, % Subtype MD5.
            0,1,2,1,0, % Binary data.
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON': binary(md5, [0,1,2,1,0])
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('binary, user defined', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x05, % Binary tag.
            66,83,79,78, 0, % Ename "BSON\0".
            5,0,0,0, % Length of binary data.
            0x80, % Subtype user defined.
            0,1,2,1,0, % Binary data.
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON': binary(user_defined, [0,1,2,1,0])
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('binary, user defined', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x07, % ObjectID tag.
            66,83,79,78, 0, % Ename "BSON\0".
            0x47,0xcc,0x67,0x09, % ObjectID, time.
            0x34,0x75,0x06,      % ObjectID, machine.
            0x1e,0x3d,           % ObjectID, pid.
            0x95,0x36,0x9d,      % ObjectID, inc.
        0 % End of top doc.
    ],
    Expected =
    [
        'BSON': object_id('47cc67093475061e3d95369d')
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('js', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x0D, % JS tag.
            106,115, 0, % Ename "js\0".
            9,0,0,0, % String's byte length, incl. nul.
            99,111,100,101,32,46,46,46, 0, % String data, "code ...\0".
        0 % End of top doc.
    ],
    Expected =
    [
        js: js('code ...')
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('js with scope', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x0F, % JS with scope tag.
            106,115, 0, % Ename "js\0".
            6,6,6,6, % int xxx
            9,0,0,0, % String's byte length, incl. nul.
            99,111,100,101,32,46,46,46, 0, % String data, "code ...\0".
                xxx_not_impl,0,0,0, % Length of embedded doc.
                0x10, % Int32 tag
                    104,101,108,108,111, 0, % Ename "hello\0".
                    32,0,0,0, % Int32 data, 32.
                0, % End of embedded doc.
        0 % End of top doc.
    ],
    Expected =
    [
        js: js('code ...', ['hello':32])
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('undefined', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x06, % Undefined tag.
            104,101,108,108,111, 0, % Ename "hello\0".
        0 % End of top doc.
    ],
    Expected =
    [
        hello: undefined
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('boolean true', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x08, % Boolean tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            1, % Boolean data, true.
        0 % End of top doc.
    ],
    Expected =
    [
        hello: true
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('boolean false', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x08, % Boolean tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            0, % Boolean data, false.
        0 % End of top doc.
    ],
    Expected =
    [
        hello: false
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('utc datetime', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x09, % UTC datetime tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            0,0,0,0, 0,0,0,0, % UTC datetime data, 0. XXX better
        0 % End of top doc.
    ],
    Expected =
    [
        hello: utc(0)
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('boolean invalid', [throws(bson_error(invalid_boolean))]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x08, % Boolean tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            2, % Boolean data, INVALID.
        0 % End of top doc.
    ],
    bson_decoder:bson_to_term(Bson, _Got).

test('null', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x0A, % Null tag.
            104,101,108,108,111, 0, % Ename "hello\0".
        0 % End of top doc.
    ],
    Expected =
    [
        hello: null
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('regex', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x0B, % Regex tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            97, 0,  % Regex pattern, "a\0".
            105, 0, % Regex options, "i\0".
        0 % End of top doc.
    ],
    Expected =
    [
        hello: regex('a','i')
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('db pointer', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x0C, % DBPointer tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            2,0,0,0, % String's byte length, incl. nul.
            97, 0, % String data, "a\0".
            0x47,0xcc,0x67,0x09, % ObjectID, time.
            0x34,0x75,0x06,      % ObjectID, machine.
            0x1e,0x3d,           % ObjectID, pid.
            0x95,0x36,0x9d,      % ObjectID, inc.
        0 % End of top doc.
    ],
    Expected =
    [
        hello: db_pointer('a', '47cc67093475061e3d95369d')
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('symbol', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x0E, % Symbol tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            5,0,0,0, % String's byte length, incl. nul.
            97,116,111,109, 0, % String data, "atom\0".
        0 % End of top doc.
    ],
    Expected =
    [
        hello: symbol(atom)
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('mongostamp', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x11, % Mongostamp tag.
            104,101,108,108,111, 0, % Ename "hello\0".
            0,0,0,0, 0,0,0,0, % Int64 mongostamp data, 0.
        0 % End of top doc.
    ],
    Expected =
    [
        hello: mongostamp(0)
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('min', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0xFF, % Min key tag.
            104,101,108,108,111, 0, % Ename "hello\0".
        0 % End of top doc.
    ],
    Expected =
    [
        hello: min
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('max', [true(Got == Expected)]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x7F, % Max key tag.
            104,101,108,108,111, 0, % Ename "hello\0".
        0 % End of top doc.
    ],
    Expected =
    [
        hello: max
    ],
    bson_decoder:bson_to_term(Bson, Got).

test('invalid bson, missing terminating nul', [throws(bson_error(invalid))]) :-
    Bson =
    [
        xxx_not_impl,0,0,0, % Length of top doc.
        0x10, % Int32 tag
            104,101,108,108,111, 0, % Ename "hello\0".
            32,0,0,0 % Int32 data, 32.
        % Missing nul at end-of-doc.
    ],
    bson_decoder:bson_to_term(Bson, _Got).

:- end_tests('bson_decoder:bson_to_term/2').


3.0 iso .3

3.0 iso .3

#!/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 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

# ************************************************************* 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 [0: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 solid noborder
plot ifname \
       using ($2+utc_offset):(delta($6))     title "Download (eth0)" fc "red"  \
  , '' using ($2+utc_offset):(delta($7)*-1)  title "Upload   (eth0)" fc "blue" \

#!/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 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

# ************************************************************* 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 [0:100]
set autoscale y
set format y "%.3s %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 solid noborder
plot ifname \
       using ($2+utc_offset):(delta($6))     title "Download (eth0)" fc "red"  \
  , '' using ($2+utc_offset):(delta($7)*-1)  title "Upload   (eth0)" fc "blue" \


xtics color of right graph in red

xtics color of right graph in red

#!/usr/bin/env gnuplot

# graph of CPU temperature

# datafiles
ifnameh = "/tmp/lnxdiagd/mysql/sql11h.csv"
ifnamed = "/tmp/lnxdiagd/mysql/sql11d.csv"
ifnamew = "/tmp/lnxdiagd/mysql/sql11w.csv"
set output ofname = "/tmp/lnxdiagd/site/img/day11.png"

# ******************************************************* General settings *****
set terminal png truecolor enhanced font "Vera,9" size 1280,304
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
# Positions of split between graphs
LMPOS = 0.40
MRPOS = 0.75

# ********************************************************* Statistics (R) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnameh using 2 name "X" nooutput

Xh_min = X_min + utc_offset - 946684800
Xh_max = X_max + utc_offset - 946684800

# stats to be calculated here for Y-axes
#stats ifnameh using 4 name "Y" nooutput
#Yh_min = Y_min * 0.90
#Yh_max = Y_max * 1.10

# ********************************************************* Statistics (M) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamed using 2 name "X" nooutput

Xd_min = X_min + utc_offset - 946684800
Xd_max = X_max + utc_offset - 946684800

# stats to be calculated here for Y-axes
#stats ifnamed using 4 name "Y" nooutput
#Yd_min = Y_min * 0.90
#Yd_max = Y_max * 1.10

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

# stats for Y-axis
stats ifnamew using 4 name "Y" nooutput
Yw_min = Y_min -1
Yw_max = Y_max +1

set multiplot layout 1, 3 title "CPU Temperature"

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       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 "Temperature [degC]"
set yrange [ Yw_min : Yw_max ]

# ***************************************************************** Legend *****
set key inside top left horizontal box
set key samplen 1
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 rmargin at screen LMPOS

# ***** PLOT *****
plot ifnamew \
      using ($2+utc_offset):4 title " Temperature [degC]" with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                     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 ]
set xtics textcolor rgb "ccbb0000"

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

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

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

# ***** PLOT *****
plot ifnamed \
      using ($2+utc_offset):4 with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      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 ]

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

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

# ***************************************************************** Output *****
set lmargin at screen MRPOS+0.001
set rmargin -1

# ***** PLOT *****
plot ifnameh \
      using ($2+utc_offset):4 with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                 FINALIZING
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
set timestamp 'created: %Y-%m-%d %H:%M' bottom font "Vera,6"
unset multiplot

#!/usr/bin/env gnuplot

# graph of CPU temperature

# datafiles
ifnameh = "/tmp/lnxdiagd/mysql/sql11h.csv"
ifnamed = "/tmp/lnxdiagd/mysql/sql11d.csv"
ifnamew = "/tmp/lnxdiagd/mysql/sql11w.csv"
set output ofname = "/tmp/lnxdiagd/site/img/day11.png"

# ******************************************************* General settings *****
set terminal png truecolor enhanced font "Vera,9" size 1280,304
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
# Positions of split between graphs
LMPOS = 0.40
MRPOS = 0.75

# ********************************************************* Statistics (R) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnameh using 2 name "X" nooutput

Xh_min = X_min + utc_offset - 946684800
Xh_max = X_max + utc_offset - 946684800

# stats to be calculated here for Y-axes
#stats ifnameh using 4 name "Y" nooutput
#Yh_min = Y_min * 0.90
#Yh_max = Y_max * 1.10

# ********************************************************* Statistics (M) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamed using 2 name "X" nooutput

Xd_min = X_min + utc_offset - 946684800
Xd_max = X_max + utc_offset - 946684800

# stats to be calculated here for Y-axes
#stats ifnamed using 4 name "Y" nooutput
#Yd_min = Y_min * 0.90
#Yd_max = Y_max * 1.10

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

# stats for Y-axis
stats ifnamew using 4 name "Y" nooutput
Yw_min = Y_min -1
Yw_max = Y_max +1

set multiplot layout 1, 3 title "CPU Temperature"

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       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 "Temperature [degC]"
set yrange [ Yw_min : Yw_max ]

# ***************************************************************** Legend *****
set key inside top left horizontal box
set key samplen 1
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 rmargin at screen LMPOS

# ***** PLOT *****
plot ifnamew \
      using ($2+utc_offset):4 title " Temperature [degC]" with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                     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 [ Yw_min : Yw_max ]

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

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

# ***** PLOT *****
plot ifnamed \
      using ($2+utc_offset):4 with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      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 ]

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

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

# ***************************************************************** Output *****
set lmargin at screen MRPOS+0.001
set rmargin -1

# ***** PLOT *****
plot ifnameh \
      using ($2+utc_offset):4 with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                 FINALIZING
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
set timestamp 'created: %Y-%m-%d %H:%M' bottom font "Vera,6"
unset multiplot


Y scaling

Y scaling

#!/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" \

#!/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

# ************************************************************* 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 [0: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.1 noborder

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


20160124T1920

#!/usr/bin/env gnuplot

# graph of Room temperature

# ******************************************************* General settings *****
set terminal png font "Helvetica" 11 size 640,480
set datafile separator ';'
set datafile missing "NaN"   # Ignore missing values
set grid
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.

# ************************************************************* Statistics *****
# stats to be calculated here
fname = "/tmp/sql29.csv"
stats fname using 2 name "W" nooutput

W_min = W_min + utc_offset - 946684800
W_max = W_max + utc_offset - 946684800

# ****************************************************************** Title *****
set title "Wind Speed (Gilze-Rijen)"

# ***************************************************************** 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 [ W_min : W_max ]

# ***************************************************************** Y-axis *****
set ylabel "Windspeed [km/h]" # Title for Y-axis
#set yrange [10:20]
set autoscale y
set format y "%4.1f"

# **************************************************************** Y2-axis *****
#set y2label "Raw values [mV]" # Title for Y2-axis
#set autoscale y2
#set y2tics border         # place ticks on second Y2-axis

# ***************************************************************** Legend *****
# generate a legend which is placed underneath the plot
#set key outside bottom center box title "-=legend=-"
set key default
set key box
set key samplen .2
set key inside vertical
set key left top

# ***************************************************************** Output *****
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 "/tmp/again29.png"

kmh(x) = x * 3.6 # x in m/s -> km/h =>  * (3600 / 1000)

# ***** PLOT *****
plot "/tmp/sql29.csv"  using ($2+utc_offset):(kmh($3)) title "Windspeed [km/h]"      with impulses\

#points pt 5 ps 0.2\

#!/usr/bin/env gnuplot

# graph of Room temperature

# ******************************************************* General settings *****
set terminal png font "Helvetica" 11 size 640,480
set datafile separator ';'
set datafile missing "NaN"   # Ignore missing values
set grid
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.

# ************************************************************* Statistics *****
# stats to be calculated here
fname = "/tmp/sql29.csv"
stats fname using 2 name "W" nooutput

W_min = W_min + utc_offset - 946684800
W_max = W_max + utc_offset - 946684800

# ****************************************************************** Title *****
set title "Wind Speed (Gilze-Rijen)"

# ***************************************************************** 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 [ W_min : W_max ]

# ***************************************************************** Y-axis *****
set ylabel "Windspeed [km/h]" # Title for Y-axis
#set yrange [10:20]
set autoscale y
set format y "%4.1f"

# **************************************************************** Y2-axis *****
#set y2label "Raw values [mV]" # Title for Y2-axis
#set autoscale y2
#set y2tics border         # place ticks on second Y2-axis

# ***************************************************************** Legend *****
# generate a legend which is placed underneath the plot
#set key outside bottom center box title "-=legend=-"
set key default
set key box
set key samplen .2
set key inside vertical
set key left top

# ***************************************************************** Output *****
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 "/tmp/again29.png"

kmh(x) = x * 3.6 # x in m/s -> km/h =>  * (3600 / 1000)

# ***** PLOT *****
plot "/tmp/sql29.csv"  using ($2+utc_offset):(kmh($3)) title "Windspeed [km/h]"      with points pt 5 ps 0.2\


kdev: always adjust busybox prefix

kdev: always adjust busybox prefix

Signed-off-by: Erik Hugne <527d9b95423f3946c01de0ba884fdd8bb4a3759d@gmail.com>

#!/bin/sh
#Don't fiddle with users .config if there is one already
if [ -f ./busybox/.config ]; then
	echo "Using existing busybox config"
else
	make -C ./busybox defconfig
fi
#But busybox have a stupid CONFIG_PREFIX knob that we have to change
#at this stage
for arg in "$@"
do
    case "$arg" in
    --prefix=*)
	prefix=${arg#*=}/rootfs
	break
       ;;
    *) ;;
    esac
done
sed -i '/CONFIG_PREFIX/d' busybox/.config
echo CONFIG_PREFIX=\"$prefix\" >> ./busybox/.config
exit 0

#!/bin/sh
#Don't fiddle with users .config if there is one already
if [ -f ./busybox/.config ]; then
	echo "Using existing busybox config"
	exit 0
else
	make -C ./busybox defconfig
fi
#But busybox have a stupid CONFIG_PREFIX knob that we have to change
#at this stage
for arg in "$@"
do
    case "$arg" in
    --prefix=*)
	prefix=${arg#*=}/rootfs
	break
       ;;
    *) ;;
    esac
done
sed -i '/CONFIG_PREFIX/d' busybox/.config
echo CONFIG_PREFIX=\"$prefix\" >> ./busybox/.config
exit 0


[BUGFIX] Fix typo in gnuplot file.

[BUGFIX] Fix typo in gnuplot file.

set terminal 'pngcairo' size 1920, 1080
set output 'statistics.png'
set datafile separator ','
set font "Helvetica, 14"
set title "Average response time versus concurrency level" font "Helvetica, 24"
set xlabel 'Concurrency level (number of simultaneous users)' font "Helvetica, 14"
set ylabel 'Average response time (ms.)' font "Helvetica, 14"
set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 pi -1 ps 1.5
set pointintervalbox 3
set grid
set xrange [10:370]
set yrange [0:2000]
set xtics (0,20,40,60,80,100,120,140,160,180,200,220,240,260,280)
set ytics 500
set y2label "Error count"
set y2range [0:75]
set y2tics 10
set style line 2 lc rgb '#900000' lt 1 lw 2 pt 7 pi -1 ps 1.5
f(x) = a*x**b;
fit [50:100] f(x) "averages.csv" using 2:1 via a, b
g(x) = u*x**v;
fit g(x) "errorrate.csv" using 2:1 via u, v
plot "averages.csv" using 2:1 with linespoints ls 1 title 'Response time (y1)' axes x1y1, \
  "errorrate.csv" using 2:1 with linespoints ls 2 title "Error rate (y2)" axes x1y2, \
  f(x) with lines title sprintf('Response time trend f(x) = %.2f·x^{%.2f} (y1)',a, b), \
  g(x) with lines title sprintf('Error count trend f(x) = %.2g·x^{%.2g} (y2)',u, v) axes x1y2

set terminal 'pngcairo' size 1920, 1080
set output 'statistics.png'
set datafile separator ','
set font "Helvetica, 14"
set title "Average response time versus concurrency level" font "Helvetica, 24"
set xlabel 'Concurrency level (number of simultaneous users)' font "Helvetica, 14"
set ylabel 'Average response time (ms.)' font "Helvetica, 14"
set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 pi -1 ps 1.5
set pointintervalbox 3
set grid
set xrange [10:370]
set yrange [0:2000]
set xtics (0,20,40,60,80,100,120,140,160,180,200,220,240,260,280)
set ytics 500
set y2label "Error count"
set y2range [0:75]
set y2tics 10
set style line 2 lc rgb '#900000' lt 1 lw 2 pt 7 pi -1 ps 1.5
f(x) = a*x**b;
fit [50:100] f(x) "averages.csv" using 2:1 via a, b
g(x) = u*x**v;
fit g(x) "errorrate.csv" using 2:1 via u, v
plot "averages.csv" using 2:1 with linespoints ls 1 title 'Response time (y1)' axes x1y1, \
  "errorrate.csv" using 2:1 with linespoints ls 2 title "Error rate (y2)" axes x1y2, \
  f(x) with lines title sprintf('Response time trend f(x) = %.2f·x^{%.2f} (y2)',a, b), \
  g(x) with lines title sprintf('Error count trend f(x) = %.2g·x^{%.2g} (y2)',u, v) axes x1y2


Since we are collecting all of this data, we might as well graph it!

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@9807 91177308-0d34-0410-b5e6-96231b3b80d8

set terminal png

##------- Plot small Date vs LOC ----
set output "running_loc.png"
set xlabel "Date"
set ylabel "Lines of Code"
set xdata time
set timefmt "%Y-%m-%d:"
set format x "%b %d, %Y"

## Various labels for the graph
set label "Reoptimizer\n checkins" at "2003-02-18:", 114000
set label "Modulo Sched\n   checkin" at "2003-03-28:", 119500
set label "Reoptimizer\n checkins" at "2003-06-01:", 134000
set label "'dummy'\nfunction" at "2003-07-20:", 150000
set label "Reoptimizer\n removal" at "2003-08-10:", 132000

set size .75,.75
plot "running_loc.txt" using 1:2 title '' with lines, \
     "running_loc.txt" using 1:2 title "Date vs. Lines of Code" with lines

##------- Plot large Date vs LOC ----
set size 1.5,1.5
set output "running_loc_large.png"
plot "running_loc.txt" using 1:2 title '', \
     "running_loc.txt" using 1:2 title "Date vs. Lines of Code" with lines

# Delete all labels...
set nolabel

##------- Olden CBE performance ----

set size .75,.75
set output "running_Olden_cbe_time.png"
set ylabel "CBE compiled execution time"
plot "running_Olden_cbe_time.txt" u 1:2 t '' with lines, \
     "running_Olden_cbe_time.txt" u 1:2 t "bh" with lines, \
     "running_Olden_cbe_time.txt" u 1:3 t "bisort" with lines, \
     "running_Olden_cbe_time.txt" u 1:4 t "em3d" with lines, \
     "running_Olden_cbe_time.txt" u 1:5 t "health" with lines, \
     "running_Olden_cbe_time.txt" u 1:6 t "mst" with lines, \
     "running_Olden_cbe_time.txt" u 1:7 t "perimeter" with lines, \
     "running_Olden_cbe_time.txt" u 1:8 t "power" with lines, \
     "running_Olden_cbe_time.txt" u 1:9 t "treeadd" with lines, \
     "running_Olden_cbe_time.txt" u 1:10 t "tsp" with lines, \
     "running_Olden_cbe_time.txt" u 1:11 t "voronoi" \
   with lines

set size 1.5,1.5
set output "running_Olden_cbe_time_large.png"
plot "running_Olden_cbe_time.txt" u 1:2 t '' with lines, \
     "running_Olden_cbe_time.txt" u 1:2 t "bh" with lines, \
     "running_Olden_cbe_time.txt" u 1:3 t "bisort" with lines, \
     "running_Olden_cbe_time.txt" u 1:4 t "em3d" with lines, \
     "running_Olden_cbe_time.txt" u 1:5 t "health" with lines, \
     "running_Olden_cbe_time.txt" u 1:6 t "mst" with lines, \
     "running_Olden_cbe_time.txt" u 1:7 t "perimeter" with lines, \
     "running_Olden_cbe_time.txt" u 1:8 t "power" with lines, \
     "running_Olden_cbe_time.txt" u 1:9 t "treeadd" with lines, \
     "running_Olden_cbe_time.txt" u 1:10 t "tsp" with lines, \
     "running_Olden_cbe_time.txt" u 1:11 t "voronoi" \
   with lines

##------- Olden JIT performance ----

set size .75,.75
set output "running_Olden_jit_time.png"
set ylabel "JIT execution time"
plot "running_Olden_jit_time.txt" u 1:2 t '' with lines, \
     "running_Olden_jit_time.txt" u 1:2 t "bh" with lines, \
     "running_Olden_jit_time.txt" u 1:3 t "bisort" with lines, \
     "running_Olden_jit_time.txt" u 1:4 t "em3d" with lines, \
     "running_Olden_jit_time.txt" u 1:5 t "health" with lines, \
     "running_Olden_jit_time.txt" u 1:6 t "mst" with lines, \
     "running_Olden_jit_time.txt" u 1:7 t "perimeter" with lines, \
     "running_Olden_jit_time.txt" u 1:8 t "power" with lines, \
     "running_Olden_jit_time.txt" u 1:9 t "treeadd" with lines, \
     "running_Olden_jit_time.txt" u 1:10 t "tsp" with lines, \
     "running_Olden_jit_time.txt" u 1:11 t "voronoi" \
   with lines

set size 1.5,1.5
set output "running_Olden_jit_time_large.png"
plot "running_Olden_jit_time.txt" u 1:2 t '' with lines, \
     "running_Olden_jit_time.txt" u 1:2 t "bh" with lines, \
     "running_Olden_jit_time.txt" u 1:3 t "bisort" with lines, \
     "running_Olden_jit_time.txt" u 1:4 t "em3d" with lines, \
     "running_Olden_jit_time.txt" u 1:5 t "health" with lines, \
     "running_Olden_jit_time.txt" u 1:6 t "mst" with lines, \
     "running_Olden_jit_time.txt" u 1:7 t "perimeter" with lines, \
     "running_Olden_jit_time.txt" u 1:8 t "power" with lines, \
     "running_Olden_jit_time.txt" u 1:9 t "treeadd" with lines, \
     "running_Olden_jit_time.txt" u 1:10 t "tsp" with lines, \
     "running_Olden_jit_time.txt" u 1:11 t "voronoi" \
   with lines

##------- Olden LLC performance ----

set size .75,.75
set output "running_Olden_llc_time.png"
set ylabel "LLC compiled execution time"
plot "running_Olden_llc_time.txt" u 1:2 t '' with lines, \
     "running_Olden_llc_time.txt" u 1:2 t "bh" with lines, \
     "running_Olden_llc_time.txt" u 1:3 t "bisort" with lines, \
     "running_Olden_llc_time.txt" u 1:4 t "em3d" with lines, \
     "running_Olden_llc_time.txt" u 1:5 t "health" with lines, \
     "running_Olden_llc_time.txt" u 1:6 t "mst" with lines, \
     "running_Olden_llc_time.txt" u 1:7 t "perimeter" with lines, \
     "running_Olden_llc_time.txt" u 1:8 t "power" with lines, \
     "running_Olden_llc_time.txt" u 1:9 t "treeadd" with lines, \
     "running_Olden_llc_time.txt" u 1:10 t "tsp" with lines, \
     "running_Olden_llc_time.txt" u 1:11 t "voronoi" \
   with lines

set size 1.5,1.5
set output "running_Olden_llc_time_large.png"
plot "running_Olden_llc_time.txt" u 1:2 t '' with lines, \
     "running_Olden_llc_time.txt" u 1:2 t "bh" with lines, \
     "running_Olden_llc_time.txt" u 1:3 t "bisort" with lines, \
     "running_Olden_llc_time.txt" u 1:4 t "em3d" with lines, \
     "running_Olden_llc_time.txt" u 1:5 t "health" with lines, \
     "running_Olden_llc_time.txt" u 1:6 t "mst" with lines, \
     "running_Olden_llc_time.txt" u 1:7 t "perimeter" with lines, \
     "running_Olden_llc_time.txt" u 1:8 t "power" with lines, \
     "running_Olden_llc_time.txt" u 1:9 t "treeadd" with lines, \
     "running_Olden_llc_time.txt" u 1:10 t "tsp" with lines, \
     "running_Olden_llc_time.txt" u 1:11 t "voronoi" \
   with lines

##------- Olden optimizer time ----

set size .75,.75
set output "running_Olden_opt_time.png"
set ylabel "Time to run the optimizer"
plot "running_Olden_opt_time.txt" u 1:2 t '' with lines, \
     "running_Olden_opt_time.txt" u 1:2 t "bh" with lines, \
     "running_Olden_opt_time.txt" u 1:3 t "bisort" with lines, \
     "running_Olden_opt_time.txt" u 1:4 t "em3d" with lines, \
     "running_Olden_opt_time.txt" u 1:5 t "health" with lines, \
     "running_Olden_opt_time.txt" u 1:6 t "mst" with lines, \
     "running_Olden_opt_time.txt" u 1:7 t "perimeter" with lines, \
     "running_Olden_opt_time.txt" u 1:8 t "power" with lines, \
     "running_Olden_opt_time.txt" u 1:9 t "treeadd" with lines, \
     "running_Olden_opt_time.txt" u 1:10 t "tsp" with lines, \
     "running_Olden_opt_time.txt" u 1:11 t "voronoi" \
   with lines

set size 1.5,1.5
set output "running_Olden_opt_time_large.png"
plot "running_Olden_opt_time.txt" u 1:2 t '' with lines, \
     "running_Olden_opt_time.txt" u 1:2 t "bh" with lines, \
     "running_Olden_opt_time.txt" u 1:3 t "bisort" with lines, \
     "running_Olden_opt_time.txt" u 1:4 t "em3d" with lines, \
     "running_Olden_opt_time.txt" u 1:5 t "health" with lines, \
     "running_Olden_opt_time.txt" u 1:6 t "mst" with lines, \
     "running_Olden_opt_time.txt" u 1:7 t "perimeter" with lines, \
     "running_Olden_opt_time.txt" u 1:8 t "power" with lines, \
     "running_Olden_opt_time.txt" u 1:9 t "treeadd" with lines, \
     "running_Olden_opt_time.txt" u 1:10 t "tsp" with lines, \
     "running_Olden_opt_time.txt" u 1:11 t "voronoi" \
   with lines

##------- Machine code size ----

set size .75,.75
set output "running_Olden_machcode.png"
set ylabel "Program machine code size"
plot "running_Olden_machcode.txt" u 1:2 t '' with lines, \
     "running_Olden_machcode.txt" u 1:2 t "bh" with lines, \
     "running_Olden_machcode.txt" u 1:3 t "bisort" with lines, \
     "running_Olden_machcode.txt" u 1:4 t "em3d" with lines, \
     "running_Olden_machcode.txt" u 1:5 t "health" with lines, \
     "running_Olden_machcode.txt" u 1:6 t "mst" with lines, \
     "running_Olden_machcode.txt" u 1:7 t "perimeter" with lines, \
     "running_Olden_machcode.txt" u 1:8 t "power" with lines, \
     "running_Olden_machcode.txt" u 1:9 t "treeadd" with lines, \
     "running_Olden_machcode.txt" u 1:10 t "tsp" with lines, \
     "running_Olden_machcode.txt" u 1:11 t "voronoi" \
   with lines

set size 1.5,1.5
set output "running_Olden_machcode_large.png"
plot "running_Olden_machcode.txt" u 1:2 t '' with lines, \
     "running_Olden_machcode.txt" u 1:2 t "bh" with lines, \
     "running_Olden_machcode.txt" u 1:3 t "bisort" with lines, \
     "running_Olden_machcode.txt" u 1:4 t "em3d" with lines, \
     "running_Olden_machcode.txt" u 1:5 t "health" with lines, \
     "running_Olden_machcode.txt" u 1:6 t "mst" with lines, \
     "running_Olden_machcode.txt" u 1:7 t "perimeter" with lines, \
     "running_Olden_machcode.txt" u 1:8 t "power" with lines, \
     "running_Olden_machcode.txt" u 1:9 t "treeadd" with lines, \
     "running_Olden_machcode.txt" u 1:10 t "tsp" with lines, \
     "running_Olden_machcode.txt" u 1:11 t "voronoi" \
   with lines

##------- Bytecode size ----

set size .75,.75
set output "running_Olden_bytecode.png"
set ylabel "Program bytecode size"
plot "running_Olden_bytecode.txt" u 1:2 t '' with lines, \
     "running_Olden_bytecode.txt" u 1:2 t "bh" with lines, \
     "running_Olden_bytecode.txt" u 1:3 t "bisort" with lines, \
     "running_Olden_bytecode.txt" u 1:4 t "em3d" with lines, \
     "running_Olden_bytecode.txt" u 1:5 t "health" with lines, \
     "running_Olden_bytecode.txt" u 1:6 t "mst" with lines, \
     "running_Olden_bytecode.txt" u 1:7 t "perimeter" with lines, \
     "running_Olden_bytecode.txt" u 1:8 t "power" with lines, \
     "running_Olden_bytecode.txt" u 1:9 t "treeadd" with lines, \
     "running_Olden_bytecode.txt" u 1:10 t "tsp" with lines, \
     "running_Olden_bytecode.txt" u 1:11 t "voronoi" \
   with lines

set size 1.5,1.5
set output "running_Olden_bytecode_large.png"
plot "running_Olden_bytecode.txt" u 1:2 t '' with lines, \
     "running_Olden_bytecode.txt" u 1:2 t "bh" with lines, \
     "running_Olden_bytecode.txt" u 1:3 t "bisort" with lines, \
     "running_Olden_bytecode.txt" u 1:4 t "em3d" with lines, \
     "running_Olden_bytecode.txt" u 1:5 t "health" with lines, \
     "running_Olden_bytecode.txt" u 1:6 t "mst" with lines, \
     "running_Olden_bytecode.txt" u 1:7 t "perimeter" with lines, \
     "running_Olden_bytecode.txt" u 1:8 t "power" with lines, \
     "running_Olden_bytecode.txt" u 1:9 t "treeadd" with lines, \
     "running_Olden_bytecode.txt" u 1:10 t "tsp" with lines, \
     "running_Olden_bytecode.txt" u 1:11 t "voronoi" \
   with lines

set terminal png

##------- Plot small Date vs LOC ----
set output "running_loc.png"
set xlabel "Date" "TimesRoman,24"
set ylabel "Lines of Code" "TimesRoman,24"
set xdata time
set timefmt "%Y-%m-%d:"
set format x "%b %d, %Y"

## Various labels for the graph
set label "Reoptimizer\n checkins" at "2003-02-18:", 114000
set label "Modulo Sched\n   checkin" at "2003-03-28:", 119500
set label "Reoptimizer\n checkins" at "2003-06-01:", 134000
set label "'dummy'\nfunction" at "2003-07-20:", 150000
set label "Reoptimizer\n removal" at "2003-08-10:", 132000

set size .75,.75
plot "running_loc.txt" using 1:2 title '', \
     "running_loc.txt" using 1:2 title "Date vs. Lines of Code" with lines

##------- Plot large Date vs LOC ----
set size 1.5,1.5
set output "running_loc_large.png"
plot "running_loc.txt" using 1:2 title '', \
     "running_loc.txt" using 1:2 title "Date vs. Lines of Code" with lines

# Delete all labels...
set nolabel