in reply to Looking for ideas on how to optimize this specialized grep

what could I do for free?
There's no such thing as a free lunch. But if you do this often enough, and it takes so much time you're willing to spend time to optimize it, then why not collect the information when the mail arrives? Just use a disk tied hash (for instance, some DB_File solution), and for each mail that arrives, increment the appropriate value.

Then whenever you want to see the counts, you just get the values from a hash instead of having to parse a huge file.

  • Comment on Re: Looking for ideas on how to optimize this specialized grep

Replies are listed 'Best First'.
Re^2: Looking for ideas on how to optimize this specialized grep
by afresh1 (Hermit) on Jan 21, 2011 at 21:10 UTC

    In this case, it was just something I wondered about my existing email. I have email going back 10+ years and this was the first time I wondered about it, so it is unlikely to be something I want to do regularly. I can see that logging when it is received would move the processing to a time when I don't have to wait for it, but I didn't plan that far ahead.

    l8rZ,
    --
    andrew
      If you only do this once every 10 years, do you really have a need to optimize?

        No, absolutely no need, just curiosity.

        --
        andrew