If you want to know something obscure about performance comparisons, the best thing to do is to check for yourself: that way you get actual numbers to work with. Fortunately, .NET supplies the
Stopwatch class[
^] for just such events.
string[] ar = File.ReadAllLines(@"F:\Temp\JustSomeText.txt");
Stopwatch sOut = new Stopwatch();
sOut.Start();
for (int i = 0; i < 1000; i++)
{
stringsOut(out ar);
}
sOut.Stop();
Stopwatch sRet = new Stopwatch();
sRet.Start();
for (int i = 0; i < 1000; i++)
{
ar = stringsRet();
}
sRet.Stop();
Console.WriteLine("Out: {0}\nRet: {1}", sOut.ElapsedMilliseconds, sRet.ElapsedMilliseconds);
private void stringsOut(out string[] par)
{
par = File.ReadAllLines(@"F:\Temp\JustSomeText.txt");
}
private string[] stringsRet()
{
return File.ReadAllLines(@"F:\Temp\JustSomeText.txt");
}
Running this three times gives the results:
Out: 296
Ret: 269
Out: 265
Ret: 270
Out: 273
Ret: 279
So in practice? No difference!: laugh:
[edit]:Doh: I forgot the two routines - OriginalGriff[/edit]