Debian Codegraph @

benchmarks/vs-email-mime

raw
1 #!/usr/bin/env perl
2
3 use Benchmark qw( timethese );
4
5 use Courriel;
6 use Email::MIME;
7
8 my $text = <<'EOF';
9 From [email protected] Sun May 29 11:22:29 2011
10 MIME-Version: 1.0
11 Date: Sun, 29 May 2011 11:22:22 -0500
12 Message-ID: <[email protected]>
13 Subject: Testing
14 From: Dave Rolsky <[email protected]>
15 To: Dave Rolsky <[email protected]>
16 Content-Type: multipart/alternative; boundary=20cf3071cfd06272ae04a46c9306
17
18
19 --20cf3071cfd06272ae04a46c9306
20 Content-Type: text/plain; charset=ISO-8859-1
21
22 This is a test email.
23
24 It has some *bold* text.
25
26 --20cf3071cfd06272ae04a46c9306
27 Content-Type: text/html; charset=ISO-8859-1
28
29 This is a test email.<br><br>It has some <b>bold</b> text.<br><br>
30
31 --20cf3071cfd06272ae04a46c9306--
32 EOF
33
34 sub courriel {
35 my $copy = $text;
36 Courriel->parse( text => \$copy );
37 }
38
39 sub email_mime {
40 my $copy = $text;
41 Email::MIME->new(\$copy);
42 }
43
44 timethese(
45 5000, {
46 Courriel => \&courriel,
47 'Email::MIME' => \&email_mime,
48 }
49 );