Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (1)
As of 2024-04-25 01:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found