Junkee Posted July 27, 2006 Posted July 27, 2006 Hi, I've written a little app which reads Winamp .m3u playlist files and copies all of the songs in there to a directory of the users choice. Useful for making MP3 CD's for the car. Everything works fine, no problems. I'm just concerned about the speed, especially the fact that running in debug mode within VS is faster than running the release mode .exe. This is the function that I use to copy the files. I should mention that the variable Dir is a string which contains the directory the user wants to copy the files to. Oh, and each item in the listbox lstTracks is a full path to an mp3, so each item is something along the lines of D:\Artist\Album\Song.mp3 private void CopyFiles() { // Set up progress bar progressBar.Minimum = 0; progressBar.Maximum = lstTracks.Items.Count; progressBar.Step = 1; string[] songNameArray; string songName; // Copy the files in the playlist to Dir\ foreach (object mp3 in lstTracks.Items) { lblCurrentTrack.Text = String.Format("Copying track {0} of {1}", lstTracks.Items.IndexOf(mp3), lstTracks.Items.Count.ToString()); lblCurrentTrackName.Text = mp3.ToString(); songNameArray = mp3.ToString().Split('\\'); songName = songNameArray[songNameArray.Length-1]; if (File.Exists(mp3.ToString())) File.Copy(mp3.ToString(), Dir + @"\" + songName, true); else errorLog += "|Could not copy: " + mp3.ToString(); progressBar.PerformStep(); Application.DoEvents(); } if (errorLog.Length > 31) { string[] errors = errorLog.Split('|'); MessageBox.Show("Some song(s) could not be copied. Please see\n" + Dir + "\\error.log\nfor details."); File.WriteAllLines(Dir + "\\error.log", errors); } else { MessageBox.Show(lstTracks.Items.Count.ToString() + " copied sucesfully."); } } Is there any reason why the same operation (copying the exact same playlist to the exact same location) takes longer in release mode than in debug mode? Any help would be appreciated, thanks :D Quote
Administrators PlausiblyDamp Posted August 3, 2006 Administrators Posted August 3, 2006 Out of interest what kind of difference in times are you noticing? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Junkee Posted August 3, 2006 Author Posted August 3, 2006 Hi, I've just copied a playlist of 193 songs totalling 965MB. In debug mode from the VS IDE it took 64 seconds. In from the release exe it took 89 seconds to do the exact same operation (same playlist, copying to the same drive and directory, same processes in the background etc). It isn't exactly a problem for me to wait 1 minute and a half for something, I just find it odd that there's such a difference. I just wanted to improve it where possible. Thanks, Quote
Cags Posted August 3, 2006 Posted August 3, 2006 Which option did you try first, the debug mode or the release .exe? Quote Anybody looking for a graduate programmer (Midlands, England)?
Junkee Posted August 4, 2006 Author Posted August 4, 2006 Debug mode. Then I ran I built the release exe and ran it from Windows (but left VS open in the background). Quote
Leaders snarfblam Posted August 4, 2006 Leaders Posted August 4, 2006 Since the operation is so large, I don't think that JIT compiling, assembly caching, or anything like that is going to have signifigant impact on performance, hence the order is not particularly relevant, but to be sure, you really ought to try each method a few times and mix up the order. Quote [sIGPIC]e[/sIGPIC]
Cags Posted August 4, 2006 Posted August 4, 2006 The reason I asked what order the test were performed was incase the files had been cached in a page file and as such the hdd was able to access them quicker. Quote Anybody looking for a graduate programmer (Midlands, England)?
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.