Comment.

Comment.

:- include(misc(common)).

:- begin_tests('bson:doc_bytes/2').

test('nonvar, nonvar') :-
    Doc =
    [
        hello - 256
    ],
    Bytes =
    [
        16,0,0,0, % Length of top doc.
        0x10, % Tag.
            104,101,108,108,111, 0, % Ename.
            0,1,0,0, % Int32 data.
        0 % End of top doc.
    ],
    bson:doc_bytes(Doc, Bytes).

test('nonvar, var', [true(Got == Expected)]) :-
    Doc =
    [
        hello - 256
    ],
    Expected =
    [
        16,0,0,0, % Length of top doc.
        0x10, % Tag.
            104,101,108,108,111, 0, % Ename.
            0,1,0,0, % Int32 data.
        0 % End of top doc.
    ],
    bson:doc_bytes(Doc, Got).

test('var, nonvar', [true(Got == Expected)]) :-
    Expected =
    [
        hello - 256
    ],
    Bytes =
    [
        16,0,0,0, % Length of top doc.
        0x10, % Tag.
            104,101,108,108,111, 0, % Ename.
            0,1,0,0, % Int32 data.
        0 % End of top doc.
    ],
    bson:doc_bytes(Got, Bytes).

test('var, var', [fail]) :-
    bson:doc_bytes(_, _).

test('complex doc back-and-forth', [true(Got == Expected)]) :-
    Expected =
    [
        k01 - -5.05,
        k02 - åäö_string, % Atoms only (no code lists).
        k03 - [],
        k04 - [k1-v1, k2-v2],
        k05 - [v1,v2,v3],
        k06 - binary(generic,[1,2,3]),
        k07 - binary(function,[1,2,3]),
        k08 - binary(old_generic,[1,2,3]),
        k09 - binary(uuid,[1,2,3]),
        k10 - binary(md5,[1,2,3]),
        k11 - binary(user_defined,[1,2,3]),
        k12 - +undefined,
        k13 - object_id('47cc67093475061e3d95369d'),
        k14 - +false,
        k15 - +true,
        k16 - utc(1302354660284),
        k17 - +null,
        k18 - regex('pattern','options'),
        k19 - db_pointer('string','47cc67093475061e3d95369d'),
        k20 - js('code'),
        k21 - symbol(åäö_string), % Just like atoms.
        k22 - js('code',[mappings-doc]),
        k23 - 32,
        k24 - mongostamp(0),
        k25 - 9223372036854775807,
        k26 - +min,
        k27 - +max
    ],
    bson:doc_bytes(Expected, Bytes),
    bson:doc_bytes(Got, Bytes).

:- end_tests('bson:doc_bytes/2').

:- begin_tests('bson:doc_empty/1').

test('empty') :-
    bson:doc_empty(Doc),
    bson:doc_empty(Doc).

test('non-empty', [fail]) :-
    bson:doc_empty(Doc),
    bson:doc_put(Doc, key, value, Doc1),
    bson:doc_empty(Doc1).

test('fill and empty') :-
    bson:doc_empty(Doc),
    bson:doc_put(Doc, key, value, Doc1),
    bson:doc_delete(Doc1, key, Doc2),
    bson:doc_empty(Doc2).

:- end_tests('bson:doc_empty/1').

:- begin_tests('bson:doc_get/3').

test('not found') :-
    Doc =
    [
        key - value
    ],
    bson:doc_get(Doc, notfoundkey, +null).

test('not found in empty doc') :-
    Doc = [],
    bson:doc_get(Doc, notfoundkey, +null).

test('found') :-
    Doc =
    [
        key - value
    ],
    bson:doc_get(Doc, key, value).

test('found null') :-
    Doc =
    [
        key - +null
    ],
    bson:doc_get(Doc, key, +null).

:- end_tests('bson:doc_get/3').

:- begin_tests('bson:doc_put/4').

test('put in empty') :-
    Doc = [],
    bson:doc_get(Doc, key, +null),
    bson:doc_put(Doc, key, value, Doc1),
    bson:doc_get(Doc1, key, value).

test('put in non-empty') :-
    Doc =
    [
        keyold - valueold
    ],
    bson:doc_get(Doc, keyold, valueold),
    bson:doc_get(Doc, keynew, +null),
    bson:doc_put(Doc, keynew, valuenew, Doc1),
    bson:doc_get(Doc1, keyold, valueold),
    bson:doc_get(Doc1, keynew, +null).

:- end_tests('bson:doc_put/4').

:- begin_tests('bson:doc_delete/3').

test('delete from empty') :-
    Doc = [],
    bson:doc_delete(Doc, notfoundkey, Doc).

test('delete not found') :-
    Doc =
    [
        key - value
    ],
    bson:doc_delete(Doc, notfoundkey, Doc).

test('delete only key') :-
    Doc =
    [
        key - value
    ],
    bson:doc_delete(Doc, key, Doc1),
    bson:doc_get(Doc1, key, +null).

test('delete one key') :-
    Doc =
    [
        key1 - value1,
        key2 - value2
    ],
    bson:doc_delete(Doc, key2, Doc1),
    bson:doc_get(Doc1, key1, value1),
    bson:doc_get(Doc1, key2, +null).

:- end_tests('bson:doc_delete/3').

:- include(misc(common)).

:- begin_tests('bson:doc_bytes/2').

test('nonvar, nonvar') :-
    Doc =
    [
        hello - 256
    ],
    Bytes =
    [
        16,0,0,0, % Length of top doc.
        0x10, % Tag.
            104,101,108,108,111, 0, % Ename.
            0,1,0,0, % Int32 data.
        0 % End of top doc.
    ],
    bson:doc_bytes(Doc, Bytes).

test('nonvar, var', [true(Got == Expected)]) :-
    Doc =
    [
        hello - 256
    ],
    Expected =
    [
        16,0,0,0, % Length of top doc.
        0x10, % Tag.
            104,101,108,108,111, 0, % Ename.
            0,1,0,0, % Int32 data.
        0 % End of top doc.
    ],
    bson:doc_bytes(Doc, Got).

test('var, nonvar', [true(Got == Expected)]) :-
    Expected =
    [
        hello - 256
    ],
    Bytes =
    [
        16,0,0,0, % Length of top doc.
        0x10, % Tag.
            104,101,108,108,111, 0, % Ename.
            0,1,0,0, % Int32 data.
        0 % End of top doc.
    ],
    bson:doc_bytes(Got, Bytes).

test('var, var', [fail]) :-
    bson:doc_bytes(_, _).

test('complex doc back-and-forth', [true(Got == Expected)]) :-
    Expected =
    [
        k01 - -5.05,
        k02 - åäö_string, % Atoms only.
        k03 - [],
        k04 - [k1-v1, k2-v2],
        k05 - [v1,v2,v3],
        k06 - binary(generic,[1,2,3]),
        k07 - binary(function,[1,2,3]),
        k08 - binary(old_generic,[1,2,3]),
        k09 - binary(uuid,[1,2,3]),
        k10 - binary(md5,[1,2,3]),
        k11 - binary(user_defined,[1,2,3]),
        k12 - +undefined,
        k13 - object_id('47cc67093475061e3d95369d'),
        k14 - +false,
        k15 - +true,
        k16 - utc(1302354660284),
        k17 - +null,
        k18 - regex('pattern','options'),
        k19 - db_pointer('string','47cc67093475061e3d95369d'),
        k20 - js('code'),
        k21 - symbol(åäö_string), % Just like atoms.
        k22 - js('code',[mappings-doc]),
        k23 - 32,
        k24 - mongostamp(0),
        k25 - 9223372036854775807,
        k26 - +min,
        k27 - +max
    ],
    bson:doc_bytes(Expected, Bytes),
    bson:doc_bytes(Got, Bytes).

:- end_tests('bson:doc_bytes/2').

:- begin_tests('bson:doc_empty/1').

test('empty') :-
    bson:doc_empty(Doc),
    bson:doc_empty(Doc).

test('non-empty', [fail]) :-
    bson:doc_empty(Doc),
    bson:doc_put(Doc, key, value, Doc1),
    bson:doc_empty(Doc1).

test('fill and empty') :-
    bson:doc_empty(Doc),
    bson:doc_put(Doc, key, value, Doc1),
    bson:doc_delete(Doc1, key, Doc2),
    bson:doc_empty(Doc2).

:- end_tests('bson:doc_empty/1').

:- begin_tests('bson:doc_get/3').

test('not found') :-
    Doc =
    [
        key - value
    ],
    bson:doc_get(Doc, notfoundkey, +null).

test('not found in empty doc') :-
    Doc = [],
    bson:doc_get(Doc, notfoundkey, +null).

test('found') :-
    Doc =
    [
        key - value
    ],
    bson:doc_get(Doc, key, value).

test('found null') :-
    Doc =
    [
        key - +null
    ],
    bson:doc_get(Doc, key, +null).

:- end_tests('bson:doc_get/3').

:- begin_tests('bson:doc_put/4').

test('put in empty') :-
    Doc = [],
    bson:doc_get(Doc, key, +null),
    bson:doc_put(Doc, key, value, Doc1),
    bson:doc_get(Doc1, key, value).

test('put in non-empty') :-
    Doc =
    [
        keyold - valueold
    ],
    bson:doc_get(Doc, keyold, valueold),
    bson:doc_get(Doc, keynew, +null),
    bson:doc_put(Doc, keynew, valuenew, Doc1),
    bson:doc_get(Doc1, keyold, valueold),
    bson:doc_get(Doc1, keynew, +null).

:- end_tests('bson:doc_put/4').

:- begin_tests('bson:doc_delete/3').

test('delete from empty') :-
    Doc = [],
    bson:doc_delete(Doc, notfoundkey, Doc).

test('delete not found') :-
    Doc =
    [
        key - value
    ],
    bson:doc_delete(Doc, notfoundkey, Doc).

test('delete only key') :-
    Doc =
    [
        key - value
    ],
    bson:doc_delete(Doc, key, Doc1),
    bson:doc_get(Doc1, key, +null).

test('delete one key') :-
    Doc =
    [
        key1 - value1,
        key2 - value2
    ],
    bson:doc_delete(Doc, key2, Doc1),
    bson:doc_get(Doc1, key1, value1),
    bson:doc_get(Doc1, key2, +null).

:- end_tests('bson:doc_delete/3').


fix typo

fix typo


Stylized gnuplot visualization.

Stylized gnuplot visualization.

# msswarp.gnuplot

f(x) = mean_basic
t(x) = mean_tile

# Retrieve data need during plot:
plot 'dat/BASICWARPFLOAT.mss'
mss_min_basic = GPVAL_DATA_Y_MIN
mss_max_basic = GPVAL_DATA_Y_MAX
plot 'dat/TILEWARPFLOAT.mss'
mss_min_tile = GPVAL_DATA_Y_MIN
mss_max_tile = GPVAL_DATA_Y_MAX

reset
set terminal latex
set output "msswarp.tex"
unset key
unset xtics
set clip
set border 10

#set ylabel "Time (ms)" rotate by 0 offset -2

set style line 1 lt rgb "#000000" lw 2 pt 1
set style line 2 lt rgb "#000000" lw 2 pt 6
set style line 3 lt rgb "#000000" lw 2 pt 2
set style line 4 lt rgb "#000000" lw 2 pt 9

fit f( x ) 'dat/BASICWARPFLOAT.mss' u 0:1 via mean_basic
stdd_basic = sqrt( FIT_WSSR / ( FIT_NDF + 1 ) )

fit t( x ) 'dat/TILEWARPFLOAT.mss' u 0:1 via mean_tile
stdd_tile = sqrt( FIT_WSSR / ( FIT_NDF + 1 ) )

#set label 1 "Basic" at 0,mean_basic left offset -8,0
#set label 2 "Tile" at 0,mean_tile left offset -8,0
plot mean_basic w l lt rgb "black"      ,\
	mean_basic+stdd_basic w l ls 2	,\
	mean_basic-stdd_basic w l ls 2  ,\
	mean_basic w l ls 2             ,\
	'dat/BASICWARPFLOAT.mss' u 0:(abs($1-mean_basic) < stdd_basic ? $1 : 1/0) w p pt 7 lt rgb "#000000" ps 1 ,\
	mean_tile w l lt rgb "black", mean_tile+stdd_tile w l ls 1 ,\
	mean_tile-stdd_tile w l ls 1 ,\
	mean_tile w l ls 1 ,\
	'dat/TILEWARPFLOAT.mss' u 0:(abs($1-mean_tile) < stdd_tile ? $1 : 1/0) w p pt 7 lt rgb "#000000" ps 1

# msswarp.gnuplot

f(x) = mean_basic
t(x) = mean_tile

# Retrieve data need during plot:
plot 'dat/BASICWARPFLOAT.mss'
mss_min_basic = GPVAL_DATA_Y_MIN
mss_max_basic = GPVAL_DATA_Y_MAX
plot 'dat/TILEWARPFLOAT.mss'
mss_min_tile = GPVAL_DATA_Y_MIN
mss_max_tile = GPVAL_DATA_Y_MAX

reset
set terminal latex
set output "msswarp.tex"
unset key
unset xtics
set ytics nomirror

#set ylabel "Time (ms)" rotate by 0 offset -2

set style line 1 lt rgb "#000000" lw 2 pt 1
set style line 2 lt rgb "#000000" lw 2 pt 6
set style line 3 lt rgb "#000000" lw 2 pt 2
set style line 4 lt rgb "#000000" lw 2 pt 9

fit f( x ) 'dat/BASICWARPFLOAT.mss' u 0:1 via mean_basic
stdd_basic = sqrt( FIT_WSSR / ( FIT_NDF + 1 ) )

fit t( x ) 'dat/TILEWARPFLOAT.mss' u 0:1 via mean_tile
stdd_tile = sqrt( FIT_WSSR / ( FIT_NDF + 1 ) )

#set label 1 "Basic" at 0,mean_basic left offset -8,0
#set label 2 "Tile" at 0,mean_tile left offset -8,0
plot mean_basic w l lt rgb "black"      ,\
	mean_basic+stdd_basic w l ls 2	,\
	mean_basic-stdd_basic w l ls 2  ,\
	mean_basic w l ls 2             ,\
	'dat/BASICWARPFLOAT.mss' u 0:(abs($1-mean_basic) < stdd_basic ? $1 : 1/0) w p pt 7 lt rgb "#000000" ps 1 ,\
	mean_tile w l lt rgb "black", mean_tile+stdd_tile w l ls 1 ,\
	mean_tile-stdd_tile w l ls 1 ,\
	mean_tile w l ls 1 ,\
	'dat/TILEWARPFLOAT.mss' u 0:(abs($1-mean_tile) < stdd_tile ? $1 : 1/0) w p pt 7 lt rgb "#000000" ps 1


use delta

use delta

#!/usr/bin/env gnuplot

# graph of power usage history

# datafiles
ifnameh = "/tmp/kamstrupd/mysql/kamh.csv"
ifnamed = "/tmp/kamstrupd/mysql/kamd.csv"
ifnamew = "/tmp/kamstrupd/mysql/kamw.csv"
set output "/tmp/kamstrupd/site/img/kamstrup12.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

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

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 2 name "X" nooutput

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

# ********************************************************* 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 - epoch_compensate
Xd_max = X_max + utc_offset - epoch_compensate

# ********************************************************* 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 - epoch_compensate
Xw_max = X_max + utc_offset - epoch_compensate

set multiplot layout 1, 3 title "Power History ".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 "Verbruik [kWh]"

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

# ***************************************************************** 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 ($2+utc_offset):((delta($3))+(delta($4)))         title "system"  fc "yellow"         \
  ,'' using ($2+utc_offset):(delta($3))                title "user"    fc rgb "#ccbb0000"

old_x = NaN

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

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

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

# ***** PLOT *****
plot ifnamed \
      using ($2+utc_offset):((delta($3))+(delta($4)))         title "system"  fc "yellow"         \
  ,'' using ($2+utc_offset):(delta($3))                title "user"    fc rgb "#ccbb0000"
old_x = NaN

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

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

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

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

# ***** PLOT *****
plot ifnameh \
      using ($2+utc_offset):((delta($3))+(delta($4)))         title "system"  fc "yellow"         \
  ,'' using ($2+utc_offset):(delta($3))                title "user"    fc rgb "#ccbb0000"

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

unset multiplot

#!/usr/bin/env gnuplot

# graph of power usage history

# datafiles
ifnameh = "/tmp/kamstrupd/mysql/kamh.csv"
ifnamed = "/tmp/kamstrupd/mysql/kamd.csv"
ifnamew = "/tmp/kamstrupd/mysql/kamw.csv"
set output "/tmp/kamstrupd/site/img/kamstrup12.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 2 name "X" nooutput

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

# ********************************************************* 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 - epoch_compensate
Xd_max = X_max + utc_offset - epoch_compensate

# ********************************************************* 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 - epoch_compensate
Xw_max = X_max + utc_offset - epoch_compensate

set multiplot layout 1, 3 title "Power History ".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 "Verbruik [kWh]"

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

# ***************************************************************** 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 ($2+utc_offset):($3+$4)         title "system"  fc "yellow"         \
  ,'' using ($2+utc_offset):3                title "user"    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 " "

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

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

# ***** PLOT *****
plot ifnamed \
      using ($2+utc_offset):($3+$4)         fc "yellow"         \
  ,'' using ($2+utc_offset):3                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 ]
set xtics textcolor rgb "red"

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "

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

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

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

# ***** PLOT *****
plot ifnameh \
      using ($2+utc_offset):($3+$4)         fc "yellow"         \
  ,'' using ($2+utc_offset):3                fc rgb "#ccbb0000"

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

unset multiplot


Fixed plot showing the binned performance results.

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); MAXMNK = STATS_max
stats BASENAME.".dat" using (log(column(FLOPS))) nooutput; GEO = sprintf("%.0f", exp(STATS_sum/STATS_records))
stats BASENAME.".dat" using FLOPS nooutput; MED = sprintf("%.0f", 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 yrange [*:MNK] }
if (0>HIK) { set zrange [*: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 (Binned by Problem Size)" }
set style fill solid 0.05 border -1
set boxwidth 0.5
set grid y2tics lc "grey"
unset key
unset xtics
set x2tics ("Small" 0, "Medium" 1, "Larger" 2) scale 0
set xrange [-0.5:2.5]
unset ytics
set y2tics nomirror
set y2label "GFLOP/s"
plot  BASENAME.".dat" using (0.0):((((0.0)<(column(MPARM)*column(NPARM)*column(KPARM)))&&((column(MPARM)*column(NPARM)*column(KPARM))<=(MAXMNK*1.0/3.0)))?column(FLOPS):1/0) notitle smooth unique with boxes, \
      BASENAME.".dat" using (1.0):((((MAXMNK*1.0/3.0)<(column(MPARM)*column(NPARM)*column(KPARM)))&&((column(MPARM)*column(NPARM)*column(KPARM))<=(MAXMNK*2.0/3.0)))?column(FLOPS):1/0) notitle smooth unique with boxes, \
      BASENAME.".dat" using (2.0):((((MAXMNK*2.0/3.0)<(column(MPARM)*column(NPARM)*column(KPARM)))&&((column(MPARM)*column(NPARM)*column(KPARM))<=(MAXMNK)))?column(FLOPS):1/0) notitle smooth unique with boxes

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 y2label "GFLOP/s"
set y2tics nomirror
unset ytics
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*0.95:x*1.05] 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("%.0f%%", x) at x, 0.5 * h(x) left offset 1
set arrow 2 from x, h(x) to 2 * x, h(x)
set label 2 sprintf("%.0f GFLOP/s", h(x)) at 1.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
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); MAXMNK = STATS_max
stats BASENAME.".dat" using (log(column(FLOPS))) nooutput; GEO = sprintf("%.0f", exp(STATS_sum/STATS_records))
stats BASENAME.".dat" using FLOPS nooutput; MED = sprintf("%.0f", 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 yrange [*:MNK] }
if (0>HIK) { set zrange [*: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 (Binned by Problem Size)" }
set style fill solid 1.0 noborder
set style data histograms
set style histogram columnstacked
set boxwidth 0.5 relative
set noborder
unset key
unset xtics
unset ytics
set xrange [-0.5:2.5]
set x2tics ("Small" 0, "Medium" 1, "Larger" 2) scale 0
plot  newhistogram at 0 linetype 1, \
                    BASENAME.".dat" using (column(MPARM)*column(NPARM)*column(KPARM)<=(MAXMNK*1.0/3.0)?column(FLOPS):1/0) notitle, \
      newhistogram at 1 linetype 1, \
                    BASENAME.".dat" using (column(MPARM)*column(NPARM)*column(KPARM)<=(MAXMNK*2.0/3.0)?column(FLOPS):1/0) notitle, \
      newhistogram at 2 linetype 1, \
                    BASENAME.".dat" using (column(MPARM)*column(NPARM)*column(KPARM)<=(MAXMNK*3.0/3.0)?column(FLOPS):1/0) notitle

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 y2label "GFLOP/s"
set y2tics nomirror
unset ytics
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*0.99:x*1.01] 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("%.0f%%", x) at x, 0.5 * h(x) left offset 1
set arrow 2 from x, h(x) to 2 * x, h(x)
set label 2 sprintf("%.0f GFLOP/s", h(x)) at 1.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
}


no ticlabels on left and middle chart

no ticlabels on left and middle chart

#!/usr/bin/env gnuplot

# graph of CPU load

# datafiles
ifnameh = "/tmp/lnxdiagd/mysql4gnuplot/sql12h.csv"
ifnamed = "/tmp/lnxdiagd/mysql4gnuplot/sql12d.csv"
ifnamew = "/tmp/lnxdiagd/mysql4gnuplot/sql12w.csv"
ifnamey = "/tmp/lnxdiagd/mysql4gnuplot/sql12y.csv"
set output "/tmp/lnxdiagd/site/img/day12.png"

# ******************************************************* General settings *****
set terminal png truecolor enhanced font "Vera,9" size 1280,480
set style fill transparent solid 0.25 noborder
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
TTPOS = 0.95
TBPOS = 0.55
BTPOS = 0.48
BBPOS = 0.08

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

# ********************************************************* 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

# ********************************************************* 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

# ********************************************************* Statistics (Y) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamey using 1 name "X" nooutput
Xy_min = X_min + utc_offset - epoch_compensate
Xy_max = X_max + utc_offset - epoch_compensate

set multiplot layout 2, 3 title "CPU Usage \\& Load ".strftime("( %Y-%m-%dT%H:%M:%S )", time(0)+utc_offset)
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                  UPPER ROW
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
set tmargin at screen TTPOS
set bmargin at screen TBPOS
set lmargin at screen LMARG
set rmargin at screen RMARG

# ***************************************************************** X-axis *****
unset xlabel                 # 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 "%b"            # Display time in 24 hour notation on the X axis
set xrange [ Xy_min : Xy_max ]

# ***************************************************************** Y-axis *****
set ylabel "Usage [%]"
set yrange [ 0 : 100 ]
set y2range [ 0 : 2 ]

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

# ***************************************************************** Output *****
# ***** PLOT *****
set style data boxes

plot ifnamey \
      using ($1+utc_offset):($5+$6+$7+$8)     title "idle"    fc rgb "#229922" fs solid 1.0 \
  ,'' using ($1+utc_offset):($5+$6+$7)        title "waiting" fc "blue"        fs solid 1.0 \
  ,'' using ($1+utc_offset):($5+$6)           title "system"  fc "yellow"      fs solid 1.0 \
  ,'' using ($1+utc_offset):5                 title "user"    fc rgb "#bb0000" fs solid 1.0 \
  ,'' using ($1+utc_offset):2:4             notitle with filledcurves lc "white" axes x1y2 \
  ,'' using ($1+utc_offset):3                 title "load 5min" with lines lw 0.1 fc "black" axes x1y2

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       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 [ 0 : 100 ]

# **************************************************************** Y2-axis *****
set y2label " "
set y2tics format " "
set y2tics border
set y2range [ 0 : 2 ]

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

# ***************************************************************** 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 tmargin at screen BTPOS
set bmargin at screen BBPOS
set lmargin at screen LMARG
set rmargin at screen LMPOS

# ***** PLOT *****
set style data boxes

plot ifnamew \
      using ($1+utc_offset):($5+$6+$7+$8)     title "idle"    fc rgb "#229922" fs solid 1.0 \
  ,'' using ($1+utc_offset):($5+$6+$7)        title "waiting" fc "blue"        fs solid 1.0 \
  ,'' using ($1+utc_offset):($5+$6)           title "system"  fc "yellow"      fs solid 1.0 \
  ,'' using ($1+utc_offset):5                 title "user"    fc rgb "#bb0000" fs solid 1.0 \
  ,'' using ($1+utc_offset):2:4             notitle with filledcurves lc "white" axes x1y2 \
  ,'' using ($1+utc_offset):3                 title "load 5min" with lines lw 0.1 fc "black" axes x1y2

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                     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 [ 0 : 100 ]
set y2range [ 0 : 2 ]

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

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

# ***** PLOT *****
plot ifnamed \
      using ($1+utc_offset):($5+$6+$7+$8)     fc rgb "#229922" fs solid 1.0 \
  ,'' using ($1+utc_offset):($5+$6+$7)        fc "blue"        fs solid 1.0 \
  ,'' using ($1+utc_offset):($5+$6)           fc "yellow"      fs solid 1.0 \
  ,'' using ($1+utc_offset):5                 fc rgb "#bb0000" fs solid 1.0 \
  ,'' using ($1+utc_offset):2:4             notitle with filledcurves lc "white" axes x1y2 \
  ,'' using ($1+utc_offset):3                 with lines lw 0.1 fc "black" axes x1y2

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      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 [ 0 : 100 ]

# **************************************************************** Y2-axis *****
set y2label "Load"
set y2range [0:2]
set y2tics border

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

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

# ***** PLOT *****
plot ifnameh \
      using ($1+utc_offset):($3+$4+$5+$6)     fc rgb "#229922" fs solid 1.0 \
  ,'' using ($1+utc_offset):($3+$4+$5)        fc "blue"        fs solid 1.0 \
  ,'' using ($1+utc_offset):($3+$4)           fc "yellow"      fs solid 1.0 \
  ,'' using ($1+utc_offset):3                 fc rgb "#bb0000" fs solid 1.0 \
  ,'' using ($1+utc_offset):2                 with lines lw 0.1 fc "black" axes x1y2

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

unset multiplot

#!/usr/bin/env gnuplot

# graph of CPU load

# datafiles
ifnameh = "/tmp/lnxdiagd/mysql4gnuplot/sql12h.csv"
ifnamed = "/tmp/lnxdiagd/mysql4gnuplot/sql12d.csv"
ifnamew = "/tmp/lnxdiagd/mysql4gnuplot/sql12w.csv"
ifnamey = "/tmp/lnxdiagd/mysql4gnuplot/sql12y.csv"
set output "/tmp/lnxdiagd/site/img/day12.png"

# ******************************************************* General settings *****
set terminal png truecolor enhanced font "Vera,9" size 1280,480
set style fill transparent solid 0.25 noborder
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
TTPOS = 0.95
TBPOS = 0.55
BTPOS = 0.48
BBPOS = 0.08

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

# ********************************************************* 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

# ********************************************************* 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

# ********************************************************* Statistics (Y) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamey using 1 name "X" nooutput
Xy_min = X_min + utc_offset - epoch_compensate
Xy_max = X_max + utc_offset - epoch_compensate

set multiplot layout 2, 3 title "CPU Usage \\& Load ".strftime("( %Y-%m-%dT%H:%M:%S )", time(0)+utc_offset)
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                  UPPER ROW
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
set tmargin at screen TTPOS
set bmargin at screen TBPOS
set lmargin at screen LMARG
set rmargin at screen RMARG

# ***************************************************************** X-axis *****
unset xlabel                 # 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 "%b"            # Display time in 24 hour notation on the X axis
set xrange [ Xy_min : Xy_max ]

# ***************************************************************** Y-axis *****
set ylabel "Usage [%]"
set yrange [ 0 : 100 ]
set y2range [ 0 : 2 ]

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

# ***************************************************************** Output *****
# ***** PLOT *****
set style data boxes

plot ifnamey \
      using ($1+utc_offset):($5+$6+$7+$8)     title "idle"    fc rgb "#229922" fs solid 1.0 \
  ,'' using ($1+utc_offset):($5+$6+$7)        title "waiting" fc "blue"        fs solid 1.0 \
  ,'' using ($1+utc_offset):($5+$6)           title "system"  fc "yellow"      fs solid 1.0 \
  ,'' using ($1+utc_offset):5                 title "user"    fc rgb "#bb0000" fs solid 1.0 \
  ,'' using ($1+utc_offset):2:4             notitle with filledcurves lc "white" axes x1y2 \
  ,'' using ($1+utc_offset):3                 title "load 5min" with lines lw 0.1 fc "black" axes x1y2

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       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 [ 0 : 100 ]

# **************************************************************** Y2-axis *****
set y2label "Load"
set y2tics border
set y2range [ 0 : 2 ]

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

# ***************************************************************** 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 tmargin at screen BTPOS
set bmargin at screen BBPOS
set lmargin at screen LMARG
set rmargin at screen LMPOS

# ***** PLOT *****
set style data boxes

plot ifnamew \
      using ($1+utc_offset):($5+$6+$7+$8)     title "idle"    fc rgb "#229922" fs solid 1.0 \
  ,'' using ($1+utc_offset):($5+$6+$7)        title "waiting" fc "blue"        fs solid 1.0 \
  ,'' using ($1+utc_offset):($5+$6)           title "system"  fc "yellow"      fs solid 1.0 \
  ,'' using ($1+utc_offset):5                 title "user"    fc rgb "#bb0000" fs solid 1.0 \
  ,'' using ($1+utc_offset):2:4             notitle with filledcurves lc "white" axes x1y2 \
  ,'' using ($1+utc_offset):3                 title "load 5min" with lines lw 0.1 fc "black" axes x1y2

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                     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 [ 0 : 100 ]
set y2range [ 0 : 2 ]

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

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

# ***** PLOT *****
plot ifnamed \
      using ($1+utc_offset):($5+$6+$7+$8)     fc rgb "#229922" fs solid 1.0 \
  ,'' using ($1+utc_offset):($5+$6+$7)        fc "blue"        fs solid 1.0 \
  ,'' using ($1+utc_offset):($5+$6)           fc "yellow"      fs solid 1.0 \
  ,'' using ($1+utc_offset):5                 fc rgb "#bb0000" fs solid 1.0 \
  ,'' using ($1+utc_offset):2:4             notitle with filledcurves lc "white" axes x1y2 \
  ,'' using ($1+utc_offset):3                 with lines lw 0.1 fc "black" axes x1y2

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      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 [ 0 : 100 ]

# **************************************************************** Y2-axis *****
set y2label "Load"
#set autoscale y2
set y2range [0:2]
set y2tics border

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

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

# ***** PLOT *****
plot ifnameh \
      using ($1+utc_offset):($3+$4+$5+$6)     fc rgb "#229922" fs solid 1.0 \
  ,'' using ($1+utc_offset):($3+$4+$5)        fc "blue"        fs solid 1.0 \
  ,'' using ($1+utc_offset):($3+$4)           fc "yellow"      fs solid 1.0 \
  ,'' using ($1+utc_offset):3                 fc rgb "#bb0000" fs solid 1.0 \
  ,'' using ($1+utc_offset):2                 with lines lw 0.1 fc "black" axes x1y2

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

unset multiplot


Cosmetic

Cosmetic

:- begin_tests(db_i).
:- use_module(u(v)).
:- use_module(u(vd)).
:- use_module(u(internal/objects_i)).
:- use_module(u(internal/db_i)).
:- use_module(u(internal/db_vocab)).

test(db_next_class_id, [setup(setup)]) :-

	db_i:db_next_class_id(db_i_test, Id1),
	assertion(Id1 =:= 2),
	db_i:db_next_class_id(db_i_test, Id2),
	assertion(Id2 =:= 3),
	db_i:db_next_class_id(db_i_test, Id3),
	assertion(Id3 =:= 4).

% test local class id -> db class id conversion
test(db_conv_local_db1, [setup(setup)]) :-

	obj_construct(man_v, [], [], Man1),
	obj_rebase((object_v -> db_object_v), Man1, Man),
	arg(1, Man, Man_Local_Id),

	db_i:db_add_class(db_i_test, Man_Local_Id, Man_DB_Id, _),

	db_conv_local_db(db_i_test, Man_Local_Id,
			 Man_DB_Id1,_),

	assertion(Man_DB_Id =:= Man_DB_Id1),

	% object_v
	class_id(Object_Local_Id, object_v), !,
	db_conv_local_db(db_i_test, Object_Local_Id,
			 Object_DB_Id, _),

	assertion(Object_DB_Id =:= 1), % always 1
	assertion(Man_DB_Id =\= Object_DB_Id).

test(db_recorded_int,
     [setup(setup),
      throws(error(no_object_field(Obj0, db_ref), _))]
    ) :-

        obj_construct(man_v, [sex, name], [man, 'Adam'], Obj0),
        db_put_object(db_i_test, Obj0, _),
        db_recorded_int(db_i_test, Obj0).

test(db_recorded_int,
     [setup(setup), fail]) :-

        obj_construct(man_v, [sex, name], [man, 'Adam'], Obj0),
        db_put_object(db_i_test, Obj0, Obj),
        db_recorded(db_i_test, Obj).

setup :-

	db_clear(db_i_test).

:- end_tests(db_i).

:- begin_tests(db_i).
:- use_module(u(v)).
:- use_module(u(vd)).
:- use_module(u(internal/objects_i)).
:- use_module(u(internal/db_i)).
:- use_module(u(internal/db_vocab)).

test(db_next_class_id, [setup(setup)]) :-

	db_i:db_next_class_id(db_i_test, Id1),
	assertion(Id1 =:= 2),
	db_i:db_next_class_id(db_i_test, Id2),
	assertion(Id2 =:= 3),
	db_i:db_next_class_id(db_i_test, Id3),
	assertion(Id3 =:= 4).

% test local class id -> db class id conversion
test(db_conv_local_db1, [setup(setup)]) :-

	obj_construct(man_v, [], [], Man1),
	obj_rebase((object_v -> db_object_v), Man1, Man),
	arg(1, Man, Man_Local_Id),

	db_i:db_add_class(db_i_test, Man_Local_Id, Man_DB_Id, _),

	db_conv_local_db(db_i_test, Man_Local_Id,
			 Man_DB_Id1,_),

	assertion(Man_DB_Id =:= Man_DB_Id1),

	% object_v
	class_id(Object_Local_Id, object_v), !,
	db_conv_local_db(db_i_test, Object_Local_Id,
			 Object_DB_Id, _),

	assertion(Object_DB_Id =:= 1), % always 1
	assertion(Man_DB_Id =\= Object_DB_Id).

test(db_recorded_int,
     [setup(setup),
      throws(error(no_object_field(X, db_ref), _))]
    ) :-

        obj_construct(man_v, [sex, name], [man, 'Adam'], Obj0),
        db_put_object(db_i_test, Obj0, _),
        db_recorded_int(db_i_test, Obj0).

test(db_recorded_int,
     [setup(setup), fail]) :-

        obj_construct(man_v, [sex, name], [man, 'Adam'], Obj0),
        db_put_object(db_i_test, Obj0, Obj),
        db_recorded(db_i_test, Obj).

setup :-

	db_clear(db_i_test).

:- end_tests(db_i).