Taglib: Performance and crashes problems

白昼怎懂夜的黑 提交于 2019-12-03 16:34:19

Sometimes, when a tag is not set, the app crashes, and output...

It is one of the many strange design decisions in the TagLib. The AudioProperties object is NULL when there are no tags. You have to live with it and add some extra code to check for NULLs.

The weird thing is that once all the files have been loaded, the next time it load the folder again, it's done instantaneous (until i reboot the os)

It's not weird, since Windows 7 has a very advanced and very aggressive disk I/O caching mechanism. Once you "touch" the file, it gets to the RAM and the next time you access it - it's almost instantaneous. 400 mp3 files is not much and it all fits into the RAM.

11s to load a folder containing 400 songs

400 times you have to perform a disk seek which usually takes 9-11ms on a typical hard disk drive (yes, it's only 0.1ms for the SSD). So you have at least 10*400 = 4 seconds just to "rewind" the drive's head, if the folder is fragmented. Since id3 tags may occur at the beginning and at the end of the file this virtually increases the number of reads twice (you have to rewind to the end of the file), thus giving the 2x time (about 8 seconds).

Resume: The time to read the folder is close to something realistic. There is a number of quircks in TagLib (like NULLs or the inability to overload the file operations to allow, e.g. reading from archives), but they are avoidable. The functionality of TagLib is really good and in many aspects it is unique (broad format support).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!