I was curious to see how much slower sprintf was in perl than an equivalent print statement. Using Debug::Profile hotness, after a million calls it turns out that sprintf is insignificantly slower. Yay boredom.
time elapsed (wall): 47.2054
time running program: 34.0098 (72.05%)
time profiling (est.): 13.1956 (27.95%)
number of calls: 2000000
%Time Sec. #calls sec/call F name
60.20 20.4722 0 20.472220 *
21.04 7.1548 1000000 0.000007 main::sp
18.77 6.3828 1000000 0.000006 main::nosp
sub sp {
return sprintf("(%s) %s - %s\n", $album, $artist, $title);
}
sub nosp {
return "(" . $album . ") " . $artist . " - " . $title . "\n";
}