Very slow with long string.Join

I have a test that has the contents of a file just as a string in the test.

For readability the string is just a field set to string,Join(Environment.NewLine,............)

where ... is each line of the file seperated by commars, it's slightly nicer than having one long string with \r\n in it or having lots of + \r\n + in the string

However this KILLS resharper, it takes 1 minute to read the file and tell me about anything in it.

If I change the string to use + "\r\n" + between each line then ReSharper speeds up, but it won't let me keep adding after a while it says that it's expecting a ;

The other option is making it not readable at all and making it one string without any +'s in it

Resharper works fine and everything compiles if i do it as one string but now I cant' read my text. Maybe it should be a file but I don't want tests that read the disk just for a smallish file

4 comments
Comment actions Permalink

Hello David,

1. What exact ReSharper version do you use?
2. Could you please help us to determine the cause of the issue by profiling Visual Studio for us? In the ReSharper 7 you may do that straight away with 'ReSharper | Help | Profile Visual Studio'. This action will start the profiling of the VS immediately - after you finish doing the repro actions, please press the 'Get Snapshot' button in the dialog.


After profiling is complete, you 'll be able to upload the snapshot to our FTP server, so we could investigate it to provide a solution and/or bugfix for the performance issues.


Thank you.

0
Comment actions Permalink

Using 7.1.1, I have sent a profile already before I posted the original message, I attached my email with the profile. I can give you an exact example

namespace MyNameSpace
{
    public class ExampleClass
    {
        private string myFile = string.Join(Environment.NewLine,
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",
                                             "Some line of a text file",);

        public void Test()
        {
               // Uncomment this and the suggestion to import System.IO won't appear for a while
               // var stream = new Stream();
        }
    }
}

0
Comment actions Permalink

Have you tried using a literal string?

namespace MyNameSpace
{
    public class ExampleClass
    {
        private string myFile = @"Line 1
Line 2
Line 3
...
Line 100";

    }
}

0
Comment actions Permalink

Literal string works, that'll do as a work around for now :) good thinking.

0

Please sign in to leave a comment.