Update readme

This commit is contained in:
wapmorgan 2017-01-10 02:54:27 +03:00
parent 0a8b5a06dd
commit 674bfda41d
2 changed files with 8 additions and 9 deletions

View File

@ -47,10 +47,8 @@ echo 'Song '.$audio->tags1['song'].' from '.$audio->tags1['artist'].PHP_EOL;
# Performance
* It parses a bunch of mp3 files in less than a half of second (without tags).
* It parses a bunch of mp3 files with their tags in two seconds or less (with both id3v1 and id3v2).
A bunch - **878 megabytes** of mp3 files (**33 tracks** with a total length **8:37:42**).
* Typically it parses one mp3-file with size around 6-7 mb in less that 0.001 sec.
* Few files constant & variable bitRate with total duration 5:22:28 are parsed in 1.76 sec.
# Console scanner
To test Mp3Info you can use built-in script that scans dirs and analyzes all mp3-files inside them. To launch script against current folder:

View File

@ -18,7 +18,7 @@ function substrIfLonger($string, $maxLength) {
return $string;
}
function analyze($filename, &$total_parse_time) {
function analyze($filename, &$total_duration, &$total_parse_time) {
if (!is_readable($filename)) return;
try {
$audio = new Mp3Info($filename, true);
@ -26,19 +26,20 @@ function analyze($filename, &$total_parse_time) {
return null;
}
echo sprintf('%15s | %4s | %7s | %0.1fkHz | %-11s | %-10s | %.5f', substrIfLonger(basename($filename), 15), formatTime($audio->duration), $audio->isVbr ? 'vbr' : ($audio->bitRate / 1000).'kbps', ($audio->sampleRate / 1000), isset($audio->tags1['song']) ? substrIfLonger($audio->tags1['song'], 11) : null, isset($audio->tags1['artist']) ? substrIfLonger($audio->tags1['artist'], 10) : null, $audio->_parsingTime).PHP_EOL;
$total_duration += $audio->duration;
$total_parse_time += $audio->_parsingTime;
}
array_shift($argv);
echo sprintf('%15s | %4s | %7s | %7s | %11s | %10s | %4s', 'File name', 'dur.', 'bitrate', 'sample', 'song', 'artist',
'time').PHP_EOL;
$total_parse_time = 0;
$total_duration = $total_parse_time = 0;
foreach ($argv as $arg) {
if (is_dir($arg)) {
foreach (glob(rtrim($arg, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*.mp3') as $f) {
if (is_file($f))
analyze($f, $total_parse_time);
analyze($f, $total_duration, $total_parse_time);
}
} else if (is_file($arg))
analyze($arg, $total_parse_time);
analyze($arg, $total_duration, $total_parse_time);
}
echo sprintf('%79s', 'Total parsing time: '.round($total_parse_time, 5)).PHP_EOL;
echo sprintf('%42s | %34s', 'Total duration: '.formatTime($total_duration), 'Total parsing time: '.round($total_parse_time, 5)).PHP_EOL;