#!/bin/bash

DATA=WS/chrono.indoor
COMP=/dev/shm/comp.indoor
LAST=/dev/shm/last.indoor
IMAGE="inside-timing.png"

awk -f timingplot.awk < $DATA > $COMP
awk -f timinglast.awk < $DATA > $LAST

timestamp=$(date --utc)
title="Average tracing time for the Indoor Video ($timestamp)"

gnuplot << __EOC__
set term png    size 1280,720
set output      "${IMAGE}"

# set key         below
set yrange      [ 0.0 : 1200.0 ]
set grid        front
set xtics       100
set xlabel	"This is the frame number, we have a lot of frames."
set ytics       60
set ylabel	"Times (seconds)"

set title       "${title}"

plot									   \
	"$COMP"  using 1:2 with lines title "Average" lt rgb "#00b000"   , \
	"$COMP"  using 1:3 with lines title "Minimum" lt rgb "blue"      , \
	"$COMP"  using 1:4 with lines title "Maximum" lt rgb "red"       , \
	"$LAST"  using 1:2 with lines title "Last"    lt rgb "#000000"

__EOC__

nbs=$(wc -l $DATA | awk '{print $1}')
printf "timings on %.3f runs\n" $(echo "$nbs / 2000" | bc -l)

# rm -v $COMP $LAST

display "${IMAGE}" &


