While idly thinking about coding an mp3 sorting program, I decided to look at my options for reading mp3 tags.

Turns out that (unless my benchmarking is off) MP3::Info is much faster than MP3::Tag. pudge was quite pleased...

If the following benchmark is completely off, I can only claim exhaustion, as it was wirtten at an hour when I should have been asleep. :-)

#!/usr/local/bin/perl use MP3::Info; use MP3::Tag; use Benchmark; use strict; use warnings; my $track = shift; timethese( shift || 10000, { info => sub { my $tag = get_mp3tag($track); my $tracknum = $tag->{TRACKNUM}; }, autotag => sub { my $mp3 = MP3::Tag->new($track); my $tracknum = ( $mp3->autoinfo )[1]; }, manualtag => sub { my $mp3 = MP3::Tag->new($track); $mp3->get_tags; if ( exists $mp3->{ID3v1} ) { # read some information from the tag my $id3v1 = $mp3 ->{ID3v1}; # $id3v1 is only a shortcut for $mp3 +->{ID3v1} my $tracknum = $mp3->{ID3v1}->track; } if ( exists $mp3->{ID3v2} ) { # read some information from the tag my $tacknum = $mp3->{ID3v2}->get_frame("TRCK"); # delete the tag completely from the file $mp3->{ID3v2}->remove_tag; } $mp3->close(); } } );

In reply to Benchmarking MP3::Tag vs. MP3::Info by dha

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.