On Tue, 2009-11-17 at 18:20 -0700, LuKreme wrote:
On 17-Nov-2009, at 17:40, JW Simpson wrote:
Right ... So that's an easy replacement of just one line. Once you
switch that out is there a significant difference in speed?
There is.
My concern is that the "scoring" might be more expensive than using the
external script?
It is about twice as slow, but the pure shell script got a LOT faster thanks
to your awk… so twice as slow is still a lot faster than what I started with.
Still, read ahead.
Fun stuff though :)
<EOF
#!/bin/bash
BIGLIST=`ls -1dA $HOME/Maildir/.*[0-9]-*/{cur,new}/*, 2>/dev/null| awk -F/
'{print $5}'`;
LIST=`echo "$BIGLIST"|uniq`
TOTALC=0
for i in $LIST; do
COUNT=`echo "$BIGLIST"| grep $i |wc -l`
echo "$COUNT in $i"
TOTALC=$(( $TOTALC + $COUNT ))
done
echo "$TOTALC unread"
EOF
Takes about 1/10th as long as it used to.
$ time newimapscan
17 in .applescript-users.2009-11
1 in .courier-users.2009-11
21 in .httpd-users.2009-11
9 in .macosx-talk.2009-11
8 in .mailman-users.2009-11
2 in .osx-nutters.2009-11
18 in .postfix-users.2009-11
1 in .procmail.2009-11
9 in .spamassassin-users.2009-11
23 in .tidbits-talk.2009-11
109 unread
real 0m0.202s
user 0m0.032s
sys 0m0.143s
(the count is correct)
$ time :|procmail -pm counter.rc
procmail: Excessive output quenched from "ls -1dA
$HOME/Maildir/.*[0-9]-*/{cur,new}/*, 2>/dev/null | awk -F/ '{print $5}'"
17 .applescript-users.2009-11
1 .courier-users.2009-11
21 .httpd-users.2009-11
9 .macosx-talk.2009-11
8 .mailman-users.2009-11
2 .osx-nutters.2009-11
18 .postfix-users.2009-11
1 .procmail.2009-11
9 .spamassassin-users.2009-11
1 .tidbits-talk.2
87 Total
Folder: /dev/null
0
real 0m0.322s
user 0m0.053s
sys 0m0.112s
I figured this might be because LINEBUF is too small, but I added a
LINEBUF=20480 (and a LINEBUF=204800) to the top of the counter.rc file and
got the same error.
Hmm ...
My next stab would be to use gawk to generate the tally. You can use
the foldernames as subscripts for an associative array in gawk.
I'll give it a stab later ... I am working on a critical issue for a
client at the moment.
Since 100+ unread messages is pretty normal for me first thing in the
morning, and then again in the early evening, I'm sticking with the shell
script for now.
Yea ... and it wasn't long ago that you didn't have that ! :D
--
JW Simpson <john(_at_)swajime(_dot_)com>
SwaJime's Cove℠
____________________________________________________________
procmail mailing list Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail