-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenstats.sh
executable file
·58 lines (51 loc) · 1.11 KB
/
genstats.sh
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# We're passed the path of the directory containing chopped images and
# hyperplanes. This script runs genstats on each of the 144 subdirs,
# so that each directory should end up containing avgdist.txt.
basedir="$1"
numslices=144
gendist="/home/theapp/pca/dist/build/genstats/genstats"
function genstats {
$gendist "$basedir/$1/"
}
function format {
date -u -d @"$1" +"%T"
}
starttime=$(date +%s)
function progress {
current=$1
max=$2
elapsed=$(expr $(date +%s) - $starttime)
width=78
let numeq=current*width/max
let numspace=width-numeq
let estimated_remaining=max*elapsed/current-elapsed
#elapsed/total = current/max
#total = max * elapsed / current
echo -n '['
for j in $(seq 1 $numeq);
do
echo -n "="
done
for j in $(seq 1 $numspace);
do
echo -n " "
done
echo -n -e "]\r"
echo -n "[$(format $elapsed)/$(format $estimated_remaining)]"
}
function clearline {
echo -n -e "\r"
for z in $(seq 1 80)
do
echo -n ' '
done
echo -n -e "\r"
}
for i in $(seq 1 $numslices);
do
out=$(genstats $i)
clearline
echo -e "$i:\t $out"
progress $i $numslices
done