Skip to content

Instantly share code, notes, and snippets.

@Rast1234
Created June 26, 2014 19:43
Show Gist options
  • Select an option

  • Save Rast1234/6a5d192b5a156ce450a2 to your computer and use it in GitHub Desktop.

Select an option

Save Rast1234/6a5d192b5a156ce450a2 to your computer and use it in GitHub Desktop.
log stats for content migration
#!/bin/bash
bytes=`cat $1* | grep -i 'to drive' | cut -d ' ' -f 8 | paste -s -d + | bc`
rows=`cat $1* | grep -i 'fetched' | cut -d ' ' -f 7 | paste -s -d + | bc`
start=`cat $1* | grep -i 'started' | head -n 1 | cut -d ' ' -f 1,2`
end=`cat $1* | grep -i 'finished' | tail -n 1 | cut -d ' ' -f 1,2`
echo "$start - $end; $rows rows; $bytes bytes"
seconds=`python -c "from dateutil.parser import parse; import sys; print (parse(sys.argv[2])-parse(sys.argv[1])).seconds" "$start" "$end"`
rs=`bc <<< "scale=2;$rows/$seconds"`
bs=`bc <<< "scale=2;$bytes/$seconds"`
echo "$seconds sec; $rs row/sec; $bs byte/sec"
minutes=`bc <<< "scale=2;$seconds/60"`
rm=`bc <<< "scale=2;$rows/$minutes"`
mm=`bc <<< "scale=2;$bytes/1024/1024/$minutes"`
ms=`bc <<< "scale=2;$bytes/1024/1024/$seconds"`
echo "$minutes min; $rm row/min; $mm mb/min; $ms mb/sec"
maxrows='1000000000'
est_s=`bc <<< "scale=2;$maxrows/$rs"`
est_h=`bc <<< "scale=2;$est_s/60/60"`
est_d=`bc <<< "scale=2;$est_h/24"`
echo "Est. for 10**9 rows: $est_s sec -or- $est_h hrs -or- $est_d days"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment