static void TestSources() { ITunesLibrary lib = new ITunesLibrary(); lib.MaxSongsToFetch = 150; lib.LoadSongs(); lib.WaitLoad(); List <Song> songs = lib.Songs.FindAll( delegate(Song s) { LyricsStatus status = s.LyricsStatus; return(status == LyricsStatus.Untried || status == LyricsStatus.Failed || status == LyricsStatus.Success); } ); songs = songs.GetRange(0, 10); //TestOneSource(songs, new LyricsSourceLyricWiki()); //TestOneSource(songs, new LyricsSourceLyricWikiHtml()); TestOneSource(songs, new LyricsSourceLyricsPlugin()); TestOneSource(songs, new LyricsSourceLyrdb()); TestOneSource(songs, new LyricsSourceLyricsFly()); }
static void TestManyMetaDataLookup() { ITunesLibrary lib = new ITunesLibrary(); lib.MaxSongsToFetch = 50; lib.LoadSongs(); lib.WaitLoad(); Stopwatch sw = new Stopwatch(); sw.Start(); try { foreach (Song song in lib.Songs) { MetaDataLookup req = new MetaDataLookup(); //MetaDataLookupOld req = new MetaDataLookupOld(); req.Lookup(song); if (req.Status == MetaDataStatus.Success) { if (song.Title == req.MetaData.Title && song.Artist == req.MetaData.Artist) { System.Diagnostics.Debug.WriteLine(String.Format("same: {0}", song)); } else { System.Diagnostics.Debug.WriteLine(String.Format("different: {0}. title={1}, artist={2}", song, req.MetaData.Title, req.MetaData.Artist)); } } else { System.Diagnostics.Debug.WriteLine(String.Format("failed: {0}", song)); } } } finally { sw.Stop(); System.Diagnostics.Debug.WriteLine(String.Format("Tried {0} song in {1} ({2} secs per song)", lib.Songs.Count, sw.Elapsed, (sw.ElapsedMilliseconds / lib.Songs.Count) / 1000)); } }
static void TestSecondTry() { // Is it actually worthwhile doing the second or subsequent attempt? ITunesLibrary lib = new ITunesLibrary(); //lib.MaxSongsToFetch = 1000; lib.LoadSongs(); lib.WaitLoad(); List <Song> songs = lib.Songs.FindAll( delegate(Song s) { LyricsStatus status = s.LyricsStatus; return(status == LyricsStatus.Untried || status == LyricsStatus.Failed || status == LyricsStatus.Success); } ); ILyricsSource source2 = new LyricsSourceLyricsPlugin(); ILyricsSource source1 = new LyricsSourceLyrdb(); ILyricsSource source3 = new LyricsSourceLyricsFly(); Stopwatch sw1 = new Stopwatch(); Stopwatch sw2 = new Stopwatch(); Stopwatch sw3 = new Stopwatch(); int failures = 0; int success1 = 0; int success2 = 0; int success3 = 0; foreach (Song song in songs) { sw1.Start(); string lyrics = source1.GetLyrics(song); sw1.Stop(); if (lyrics == string.Empty) { sw2.Start(); lyrics = source2.GetLyrics(song); sw2.Stop(); if (lyrics == string.Empty) { sw3.Start(); lyrics = source3.GetLyrics(song); sw3.Stop(); if (lyrics == string.Empty) { failures++; } else { success3++; } } else { success2++; } } else { success1++; } } Console.WriteLine("1st try: successes: {0} ({1}%), time: {2} ({3} each)", success1, (success1 * 100 / songs.Count), sw1.Elapsed, sw1.ElapsedMilliseconds / songs.Count); Console.WriteLine("2st try: successes: {0} ({1}%), time: {2} ({3} each)", success2, (success2 * 100 / songs.Count), sw2.Elapsed, sw2.ElapsedMilliseconds / (songs.Count - success1)); Console.WriteLine("3st try: successes: {0} ({1}%), time: {2} ({3} each)", success3, (success3 * 100 / songs.Count), sw3.Elapsed, sw3.ElapsedMilliseconds / (songs.Count - success1 - success2)); Console.WriteLine("failures: {0} ({1}%)", failures, (failures * 100 / songs.Count)); }