This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I was asked to rewrite this perl code that uses perl's MAIL::IMAPClient API to get the size of an IMAP folder to Java using JavaMail. The perl looks like
The perl basically totals the rfc822 size of each message in an IMAP folder to get the total size of the folder. I rewrote this in Java like
The perl and java give identical results for IMAP folder sizes - but the Java takes *much* longer to run. For my mailboxes, the perl takes about a minute, while the Java takes about 45 minutes. I'm not sure why this is happening. Is there anything about my code, or any other factors I should be looking at that would explain why Java takes so much longer to do the same thing?