File: ea-vs-ma.pl

package info (click to toggle)
libemail-address-perl 1.908-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 380 kB
  • sloc: perl: 468; makefile: 7
file content (31 lines) | stat: -rw-r--r-- 796 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/local/bin/perl;
use Benchmark qw[:all];
use strict;
$^W = 1;

use Email::Address;
use Mail::Address;

sub testit {
    my ($class) = @_;
    open CORPUS, $ARGV[0] or die $!;
    while (<CORPUS>) {
       s/-- ATAT --/@/g;
       my @objs     = $class->parse($_);
       my @new_objs = map $class->new($_->phrase, $_->address, $_->comment), @objs;
       foreach my $obj ( @objs, @new_objs ) {
           foreach ( qw[phrase address comment format name host user] ) {
               my $blah = $obj->$_;
           }
           foreach ( qw[address phrase comment] ) {
               $obj->$_('foo');
           }
       }
    }
    close CORPUS;
}

cmpthese($ARGV[1] || 10, {
  'Mail::Address'  => sub { testit 'Mail::Address' },
  'Email::Address' => sub { testit 'Email::Address' },
});