Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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,

Posted
Which option did you try first, the debug mode or the release .exe?
Anybody looking for a graduate programmer (Midlands, England)?
  • Leaders
Posted
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.
[sIGPIC]e[/sIGPIC]
Posted
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.
Anybody looking for a graduate programmer (Midlands, England)?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...