File: bench.pl

package info (click to toggle)
libaudio-scan-perl 0.93%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,152 kB
  • sloc: ansic: 11,482; perl: 241; sh: 48; makefile: 2
file content (102 lines) | stat: -rwxr-xr-x 1,968 bytes parent folder | download | duplicates (5)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/perl

use lib qw(blib/lib blib/arch);
use strict;

use Audio::Scan;
use Benchmark qw(cmpthese);

$ENV{AUDIO_SCAN_NO_ARTWORK} = 1;

my $file = shift || die "Usage: $0 [file]\n\n";

if ( $file =~ /\.mp(2|3)$/i ) {
  require MP3::Info;
  
  cmpthese( -5, {
    mp3_pp => sub {
      MP3::Info::get_mp3info($file);
      MP3::Info::get_mp3tag($file);
    },
    mp3_c  => sub {
      Audio::Scan->scan($file);
    },
  } );
}
elsif ( $file =~ /\.ogg$/i ) {
  require Ogg::Vorbis::Header::PurePerl;
  
  cmpthese( -5, {
    ogg_pp => sub {
      my $ogg = Ogg::Vorbis::Header::PurePerl->new($file);
      $ogg->info;
      $ogg->comment_tags;
    },
    ogg_c  => sub {
      Audio::Scan->scan($file);
    },
  } );
}
elsif ( $file =~ /\.fla?c$/i ) {
  require Audio::FLAC::Header;
  
  cmpthese( -5, {
    flac_pp => sub {
      Audio::FLAC::Header->_new_PP($file)
    },
    flac_c  => sub {
      Audio::Scan->scan($file);
    },
  } );
}
elsif ( $file =~ /\.(wma|asf)$/i ) {
    require Audio::WMA;
    
    cmpthese( -5, {
        asf_pp => sub {
            Audio::WMA->new($file);
        },
        asf_c  => sub {
            Audio::Scan->scan($file);
        },
    } );
}
elsif ( $file =~ /\.(wav|aiff?)$/i ) {
    require Audio::Wav;
    
    cmpthese( -5, {
        wav_pp => sub {
            Audio::Wav->new->read($file);
        },
        wav_c  => sub {
            Audio::Scan->scan($file);
        },
    } );
}
elsif ( $file =~ /\.(mpc|mp\+|mpp)$/i ) {
    require Audio::Musepack;
	
	cmpthese( -5, {
        mpc_pp => sub {
            Audio::Musepack->new($file);
        },
        mpc_c  => sub {
            Audio::Scan->scan($file);
        },
    } );
}
elsif ( $file =~ /\.(m4a)$/i ) {
    require MP4::Info;
	
	cmpthese( -5, {
        mp4_pp => sub {
            MP4::Info->new($file);
        },
        mp4_c  => sub {
            Audio::Scan->scan($file);
        },
    } );
}
else {
  die "Unsupported file type: $file\n\n";
}