[Q-e-developers] Parsing wall time, bug with fixed width?
Paolo Giannozzi
p.giannozzi at gmail.com
Tue Jun 2 15:33:33 CEST 2015
The script PW/tests/check-pw.x.j parses times as follows:
# convert from "1h23m45.6s" to seconds
# the following line prevents cases such as "2m 7.5s"
grep 'WALL$' $1.ref | sed 's/m /m0/' > $1.tmp
# in order to get cpu instead of wall time, replace $3 to $5
tref=`awk '{ str = $5; h = m = s = 0;
if (split(str, x, "h") == 2) { h = x[1]; str = x[2]; }
if (split(str, x, "m") == 2) { m = x[1]; str = x[2]; }
if (split(str, x, "s") == 2) { s = x[1]; str = x[2]; }
t += h * 3600 + m * 60 + s; }
END { printf("%.2f\n", t); }' \
$1.tmp`
Parsing the output is always a bad idea because the output is not made for
parsing but for reading and may change any time.
Assuming a fixed format is an even worse idea.
Paolo
On Wed, May 27, 2015 at 12:03 PM, Blair Lebert <Blair.Lebert at impmc.upmc.fr>
wrote:
> Hello,
>
> I found a very small 'bug' with the output of the computation time. I
> wanted to parse multiple files to get the their wall time. I thought it was
> fixed width but as seen below the times without minutes at the top are all
> shifted by one space. Also using fields to grab the data is also
> troublesome since a space is put between minutes and seconds when the
> seconds are less than 10 (highlight in red)
>
> [image: Inline image 2]
>
> One (probably poor) way of grabbing the wall time isn't very
> straight-forward:
> line=`grep PWSCF Fe.scf.out_s${s}_k${k} | tail -n 1`
> minutes=`echo $line | sed 's/.*CPU //g' | egrep -o "[0-9]*m" | tr -d m`
> seconds=`echo $line | sed 's/.*CPU //g' | egrep -o "[0-9]*\.[0-9]*s" | tr
> -d s`
> t=`echo "${minutes:-0}*60 + $seconds" | bc`
>
>
> Cheers,
> Blair
>
> _______________________________________________
> Q-e-developers mailing list
> Q-e-developers at qe-forge.org
> http://qe-forge.org/mailman/listinfo/q-e-developers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quantum-espresso.org/pipermail/developers/attachments/20150602/7935eb03/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PWSCF_fixed.png
Type: image/png
Size: 12581 bytes
Desc: not available
URL: <http://lists.quantum-espresso.org/pipermail/developers/attachments/20150602/7935eb03/attachment.png>
More information about the developers
mailing list