summaryrefslogtreecommitdiff
path: root/ckt0.sh
blob: ecb46ae368d6e8ac6907771c12056ff19a45b482 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env sh

# estimate sytem boot time

# [debug] enable execution tracing
#set -x
set -e

# raw input data
#date +%s
#sysctl_t0_str=$( sysctl kern.boottime | awk -F= '{print($NF)}' )
#sysctl_t0=$( date -jf "%a %b %d %H:%M:%S %G" "${sysctl_t0_str}" +%s )


# check for saved state
if [ -f /tmp/t0_est.log ] ; then {
    t0_est="$( cat /tmp/t0_est.log )"
} else {
    t0_est=""
} fi

printf "n t_est t_unc t_up_est t_up_unc t0_est t0_unc\n" | column -t
for N in $(seq 0 10080) ; do

    printf "${N} ${t0_est}\n" | column -t
    t0_est=$( awk -f ckt0.awk ${t0_est} | tail -n2 )
    #awk -f ckt0.awk
    #sleep $( awk 'BEGIN {print(sqrt( rand()^2.0 + 1.0 ))}' )
    #sleep $( echo $t0_est | awk '{print(sqrt( ((60.0*$4)/(60.0 + $4))^2.0 + rand()^2.0 ))}' )
    sleep $( echo $t0_est | awk '{print( sqrt($2^2.0 + $4^2.0 + $6^2.0 + rand()^2.0)%60.0 )}' )

done

printf "${t0_est}\n" | tee /tmp/t0_est.log

# [debug] disable execution tracing
set +x