ArrayList.Sort中的.NET 2.0性能错误 [英] .NET 2.0 performance bug in ArrayList.Sort

查看:55
本文介绍了ArrayList.Sort中的.NET 2.0性能错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个显着的性能错误

..NET 2.0 ArrayList.Sort方法与Array.Sort相比同样的

数据。使用.NET 1.1使用两种方法使用两种方法更快地对同一CPU上的相同数据进行排序,这就是为什么我非常确定它是一个(相当严重的)错误。在
下面你可以找到应该允许你重现这个错误的C#测试用例,来运行它你需要将2个数据文件放到当前目录中

可执行文件或者只是相应地更改文件名路径,数据文件可以从这里获得



fast_data.txt: http://majestic12.co.uk/files/other / ... /fast_data.txt

slow_data.txt: http://majestic12.co.uk/files/other/.../slow_data.txt


数据是字符串(URL)大概以字节和数字大小相似。


以下是同一台机器上代码的控制台输出(AMD x2

3800,2 GB RAM, XP专业版SP2):


VS2003 .NET 1.1(带SP1)运行:


----------- ----------------------- -------------------------

从文件slow_data.txt加载29974行

时间在ArrayList中对字符串进行排序是:250毫秒

对字符串[]数组中的字符串进行排序的时间是:234毫秒

从文件fast_data.txt加载31688行

在ArrayList中对字符串进行排序的时间是:250毫秒

对字符串[]数组中的字符串进行排序的时间是:250毫秒

------- -------------------------------------------------- -


请注意,这里的分拣时间几乎完全相同,所以好在

..NET 1.1。


---------------------------------------------- -------------

VS2005 .NET 2.0运行:


从文件slow_data.txt加载29974行

在ArrayList中对字符串进行排序的时间是:1531毫秒

对字符串[]数组中的字符串进行排序的时间是:187毫秒

从文件fast_data加载31688行.txt

在ArrayList中对字符串进行排序的时间是:703毫秒

排序字符串的时间string []数组是:171毫秒

按ENTER键退出

---------------------- -------------------------------------


通知在具有相同数据排序时间的同一台机器上,在ArrayList.Sort中,特别是对于slow_data.txt,数据排序时间要慢得多。文件,

Array.Sort时间实际上更好,所以我不是在抱怨,但

显然ArrayList排序存在严重缺陷 - 这似乎是数据

依赖并且我不是指数据的大小或字符串的数量:我

有很多这样的数据文件,大约每10个是10-20次

比其他的慢,即使它有相同数量的线

和bytesize。


注意:我是在处理ArrayLists时意识到装箱/拆箱开销,

然而在这种情况下,与.NET 1.1相比,减速是非常糟糕的并且它/ b $ b似乎与数据有关 - 我我得到了大约10%的数据集

我从中选择了2个例子(慢速和快速)来证明它的性能问题非常严重。


以下代码可以让您复制问题:


//////////////// ////////////////// ////////////////////////////////////////

使用System ;

使用System.Collections;

使用System.IO;


/ *

这个是一个测试案例,似乎是一个主要的性能问题在

ArrayList.Sort方法中的字符串

在.NET 2.0中 - 它似乎是数据相关的,因为有些类似的大小

数据文件在使用Array.Sort方法对

string []数组进行排序时,性能损失很小

性能损失。 />

踢球者:这两个版本在.NET 1.1中运行得很快


作者:Alex Chudnovsky< al *** @ majestic12.co.uk>

日期:2006年4月28日

* /

名称空间Majestic12

{

///< summary>

///测试Array.Sort的字符串[]与
的排序性能
相同字符串的ArrayList.Sort

///看来在.NET 2.0中,在某些情况下,ArrayList需要花费很多时间才能完成ting

///< / summary>

class SlowArrayListSortTest

{

static void Main(string [ ] args)

{

//从文件加载字符串:假设与

可执行文件在同一个地方

TestFile(" slow_data.txt"); //< ---这个数据文件有10个b / b
的速度

TestFile(" fast_data.txt"); //< ---更合理2倍慢


Console.WriteLine("按ENTER退出");

Console.ReadLine() ;

}


static void TestFile(string sFile)

{

FileStream oFS = File .OpenRead(sFile);


ArrayList oLines = new ArrayList();

StreamReader oSR = new StreamReader(oFS);


while(oSR.BaseStream.Position< oSR.BaseStream.Lengt h)

{

oLines.Add(oSR.ReadLine() );

}


oFS.Close();


Console.WriteLine(" Loaded {0来自文件的行

{1}",oLines.Count,sFile);


//现在将相同的字符串复制到字符串数组中以进行速度比较

string [] sLines = new string [oLines.Count];


for(int i = 0; i< sLines.Length; i ++)

sLines [i] =(string)oLines [i];


DateTime oTime = DateTime.Now;

oLines.Sort() ;

Console.WriteLine(" ;在ArrayList中对字符串进行排序的时间是:{0}

msec",(DateTime.Now.Ticks-oTime.Ticks)/TimeSpan.TicksPerMillisecond);


oTime = DateTime.Now;

Array.Sort(sLines);

Console.WriteLine("对字符串[]数组中的字符串进行排序的时间是:

{0} msec",(DateTime.Now.Ticks-oTime.Ticks)/TimeSpan.TicksPerMillisecond);

}

}

}


//////////////////////////////// //////////////////////////////////////////

I have come across with what appears to be a significant performance bug in
..NET 2.0 ArrayList.Sort method when compared with Array.Sort on the same
data. Same data on the same CPU gets sorted a lot faster with both methods
using .NET 1.1, that''s why I am pretty sure its a (rather serious) bug. Below
you can find C# test case that should allow you to reproduce this error, to
run it you will need to put 2 data files into current directory where
executable is or just change filename pathes accordingly, the data files can
be obtained from here:

fast_data.txt: http://majestic12.co.uk/files/other/.../fast_data.txt
slow_data.txt: http://majestic12.co.uk/files/other/.../slow_data.txt

The data are strings (URLs) of about similar size in bytes and number.

The following are the console outputs from code on the same machine (AMD x2
3800, 2 GB RAM, XP Pro SP2):

VS2003 .NET 1.1 (with SP1) run:

-----------------------------------------------------------
Loaded 29974 lines from file slow_data.txt
Time to sort strings in ArrayList is: 250 msec
Time to sort strings in string[] array is: 234 msec
Loaded 31688 lines from file fast_data.txt
Time to sort strings in ArrayList is: 250 msec
Time to sort strings in string[] array is: 250 msec
-----------------------------------------------------------

Note that sorting times are almost exactly the same here, so all good in
..NET 1.1 .

-----------------------------------------------------------
VS2005 .NET 2.0 run:

Loaded 29974 lines from file slow_data.txt
Time to sort strings in ArrayList is: 1531 msec
Time to sort strings in string[] array is: 187 msec
Loaded 31688 lines from file fast_data.txt
Time to sort strings in ArrayList is: 703 msec
Time to sort strings in string[] array is: 171 msec
Press ENTER to exit
-----------------------------------------------------------

Notice that on the same machine with the same data sorting times are MUCH
slower in ArrayList.Sort, and particularly for the "slow_data.txt" file,
Array.Sort times are actually better, so I am not complaining there, but
clearly ArrayList sorts are seriously flawed - this appears to be data
dependent and by that I don''t mean size of the data or number of strings: I
have got lots of such data files and about every 10th of them is 10-20 times
slower than the other even though it has got about the same number of lines
and bytesize.

Note: I am aware of boxing/unboxing overheads when dealing with ArrayLists,
however in this case the slowdown is really bad comparing to .NET 1.1 and it
appears to be data dependent - I am getting it on about 10% of my dataset
from which I have selected 2 examples (slow and fast) to demonstrate that its
a very serious performance issue.

Here is the code that should allow you to replicate the problem:

//////////////////////////////////////////////////////////////////////////
using System;
using System.Collections;
using System.IO;

/*
This is a test case of what appears to be a major performance issue in
ArrayList.Sort method for strings
in .NET 2.0 - it appears to be data dependant as some similarly sized
data files have got a lot less
performance penalty when sorting them using Array.Sort method on
string[] array.

The kicker: both versions run fast in .NET 1.1

Author: Alex Chudnovsky <al***@majestic12.co.uk>
Date: 28 Apr 2006
*/
namespace Majestic12
{
/// <summary>
/// Tests sorting performance of Array.Sort of string[] versus
ArrayList.Sort of the same strings
/// It appears that in .NET 2.0 in some cases ArrayList will take a LOT
more time to do the sorting
/// </summary>
class SlowArrayListSortTest
{
static void Main(string[] args)
{
// load strings from file: assumed to be in the same place as
the executable
TestFile("slow_data.txt"); // <--- this data file has got 10
times slower
TestFile("fast_data.txt"); // <--- more reasonable 2 times slower

Console.WriteLine("Press ENTER to exit");
Console.ReadLine();
}

static void TestFile(string sFile)
{
FileStream oFS=File.OpenRead(sFile);

ArrayList oLines=new ArrayList();

StreamReader oSR=new StreamReader(oFS);

while(oSR.BaseStream.Position<oSR.BaseStream.Lengt h)
{
oLines.Add(oSR.ReadLine());
}

oFS.Close();

Console.WriteLine("Loaded {0} lines from file
{1}",oLines.Count,sFile);

// now copy same strings into string array for speed comparisons
string[] sLines=new string[oLines.Count];

for(int i=0;i<sLines.Length;i++)
sLines[i]=(string)oLines[i];

DateTime oTime=DateTime.Now;
oLines.Sort();
Console.WriteLine("Time to sort strings in ArrayList is: {0}
msec",(DateTime.Now.Ticks-oTime.Ticks)/TimeSpan.TicksPerMillisecond);

oTime=DateTime.Now;
Array.Sort(sLines);
Console.WriteLine("Time to sort strings in string[] array is:
{0} msec",(DateTime.Now.Ticks-oTime.Ticks)/TimeSpan.TicksPerMillisecond);
}
}
}

//////////////////////////////////////////////////////////////////////////

推荐答案

Alex Chudnovsky写道:
Alex Chudnovsky wrote:
我遇到过似乎是.NET 2.0中一个重要的性能错误与Array.Sort相比,ArrayList.Sort方法对同一数据。使用.NET 1.1的两种方法可以更快地对同一CPU上的相同数据进行排序
这就是为什么我非常确定它是一个相当严重的错误。下面你可以找到应该允许你重现这个错误的C#测试用例,要运行它你需要把2个数据文件放到当前目录中,可执行文件或只是更改
filename pathes因此,数据文件可以从这里获得:

fast_data.txt:
http://majestic12.co.uk/files/other/.../fast_data.txt
slow_data.txt:
http://majestic12.co.uk/files/other/ ... / slow_data.txt

数据是大小相近的字符串(URL),字节数和数字。

以下是控制台输出代码在同一台机器上(AMD x2 3800,2 GB RAM,XP专业版SP2):

VS2003 .NET 1.1(带SP1)运行:

- -------------------------------------------------- --------
已装载29974行m file slow_data.txt
对ArrayList中的字符串进行排序的时间是:250毫秒
对string []数组中的字符串进行排序的时间是:234毫秒
来自文件fast_data.txt 在ArrayList中对字符串进行排序的时间是:250毫秒
对字符串[]数组中的字符串进行排序的时间是:250毫秒
----------------- ------------------------------------------

请注意,这里的排序时间几乎完全相同,所以在.NET 1.1中都很好。

------------------- ----------------------------------------
VS2005 .NET 2.0运行:

从文件slow_data.txt加载29974行
在ArrayList中对字符串进行排序的时间是:1531毫秒
对string []数组中的字符串进行排序的时间是:187毫秒
从文件fast_data.txt加载31688行
在ArrayList中对字符串进行排序的时间是:703毫秒
对字符串[]数组中的字符串进行排序的时间是:171毫秒
按ENTER键退出
------------------------------------------------ -----------

请注意具有相同数据排序时间的同一台机器上的数据在ArrayList.Sort中慢得多,特别是对于
slow_data.txt而言。文件,Array.Sort时间实际上更好,所以我没有在那里抱怨,但显然ArrayList排序严重有缺陷 - 这似乎是数据依赖的,并且我并不是说
数据的大小或字符串的数量:我有很多这样的数据文件,大约每10个文件比其他文件慢10-20倍,即使它大致相同行数和
字节大小。

注意:在处理数组列表时我知道装箱/拆箱的开销,但是在这种情况下,减速是非常糟糕的比较
到.NET 1.1,它似乎依赖于数据 - 我在大约10%的数据集上得到它我从中选择了2个例子(慢速
和快速)来证明它非常严重的性能问题。

以下是应该允许你复制问题的代码:

///////////////// ////////////////////////////////////////////////// ///
////使用System;
使用System.Collections;
使用System.IO;

/ *
这是一个测试案例,似乎是ArrayList.Sort中的一个主要性能问题.NET 2.0中字符串的方法 - 它似乎与数据有关,因为在使用Array.Sort方法对其进行排序时,一些类似的大小数据文件的性能损失要小得多。 /> string [] array。

踢球者:这两个版本在.NET 1.1中运行得很快

作者:Alex Chudnovsky< al *** @ majestic12.co.uk> ;
日期:2006年4月28日
* /

名称空间Majestic12
{
///< summary>
///测试sort.Sort of string []与
ArrayList.Sort相同字符串的排序性能
///在某些情况下,在.NET 2.0中,ArrayList会花费更多的时间进行排序
///< / summary>
类SlowArrayListSortTest
{
static void Main(string [] args)
//从文件中加载字符串:假设与可执行文件处于相同的位置
TestFile(" slow_data.txt"); //< ---这个数据文件已经慢了10倍
TestFile(" fast_data.txt"); //< ---更合理2
慢一点

Console.WriteLine(按ENTER退出);
Console.ReadLine();
}

static void TestFile(string sFile)
{/> FileStream oFS = File.OpenRead(sFile);

ArrayList oLines = new ArrayList( StreamTraader oSR = new StreamReader(oFS);

while(oSR.BaseStream.Position< oSR.BaseStream.Lengt h)
{
oLines.Add(oSR.ReadLine());

oFS.Close();

Console.WriteLine(" Loaded {0}行来自文件
{1}",oLines.Count,sFile);

//现在将相同的字符串复制到字符串数组中以获得速度
比较string [] sLines = new string [oLines.Count];

for(int i = 0; i< sLines.Length; i ++)
sLines [i] =(string)oLin es [i];

DateTime oTime = DateTime.Now;
oLines.Sort();
Console.WriteLine("排序ArrayList中字符串的时间是:
{0}
msec",(DateTime.Now.Ticks-oTime.Ticks)/TimeSpan.TicksPerMillisecond);

oTime = DateTime.Now;
Array.Sort (sLines);
Console.WriteLine("对字符串[]数组中的字符串进行排序的时间是:{0}
msec",(DateTime.Now.Ticks-oTime.Ticks) /TimeSpan.TicksPerMillisecond);
}}
}

///////////////////////// /////////////////////////////////////////////
/ ///
I have come across with what appears to be a significant performance
bug in .NET 2.0 ArrayList.Sort method when compared with Array.Sort
on the same data. Same data on the same CPU gets sorted a lot faster
with both methods using .NET 1.1, that''s why I am pretty sure its a
(rather serious) bug. Below you can find C# test case that should
allow you to reproduce this error, to run it you will need to put 2
data files into current directory where executable is or just change
filename pathes accordingly, the data files can be obtained from here:

fast_data.txt:
http://majestic12.co.uk/files/other/.../fast_data.txt
slow_data.txt:
http://majestic12.co.uk/files/other/.../slow_data.txt

The data are strings (URLs) of about similar size in bytes and number.

The following are the console outputs from code on the same machine
(AMD x2 3800, 2 GB RAM, XP Pro SP2):

VS2003 .NET 1.1 (with SP1) run:

-----------------------------------------------------------
Loaded 29974 lines from file slow_data.txt
Time to sort strings in ArrayList is: 250 msec
Time to sort strings in string[] array is: 234 msec
Loaded 31688 lines from file fast_data.txt
Time to sort strings in ArrayList is: 250 msec
Time to sort strings in string[] array is: 250 msec
-----------------------------------------------------------

Note that sorting times are almost exactly the same here, so all good
in .NET 1.1 .

-----------------------------------------------------------
VS2005 .NET 2.0 run:

Loaded 29974 lines from file slow_data.txt
Time to sort strings in ArrayList is: 1531 msec
Time to sort strings in string[] array is: 187 msec
Loaded 31688 lines from file fast_data.txt
Time to sort strings in ArrayList is: 703 msec
Time to sort strings in string[] array is: 171 msec
Press ENTER to exit
-----------------------------------------------------------

Notice that on the same machine with the same data sorting times are
MUCH slower in ArrayList.Sort, and particularly for the
"slow_data.txt" file, Array.Sort times are actually better, so I am
not complaining there, but clearly ArrayList sorts are seriously
flawed - this appears to be data dependent and by that I don''t mean
size of the data or number of strings: I have got lots of such data
files and about every 10th of them is 10-20 times slower than the
other even though it has got about the same number of lines and
bytesize.

Note: I am aware of boxing/unboxing overheads when dealing with
ArrayLists, however in this case the slowdown is really bad comparing
to .NET 1.1 and it appears to be data dependent - I am getting it on
about 10% of my dataset from which I have selected 2 examples (slow
and fast) to demonstrate that its a very serious performance issue.

Here is the code that should allow you to replicate the problem:

//////////////////////////////////////////////////////////////////////
//// using System;
using System.Collections;
using System.IO;

/*
This is a test case of what appears to be a major performance
issue in ArrayList.Sort method for strings
in .NET 2.0 - it appears to be data dependant as some similarly
sized data files have got a lot less
performance penalty when sorting them using Array.Sort method on
string[] array.

The kicker: both versions run fast in .NET 1.1

Author: Alex Chudnovsky <al***@majestic12.co.uk>
Date: 28 Apr 2006
*/
namespace Majestic12
{
/// <summary>
/// Tests sorting performance of Array.Sort of string[] versus
ArrayList.Sort of the same strings
/// It appears that in .NET 2.0 in some cases ArrayList will take
a LOT more time to do the sorting
/// </summary>
class SlowArrayListSortTest
{
static void Main(string[] args)
{
// load strings from file: assumed to be in the same
place as the executable
TestFile("slow_data.txt"); // <--- this data file has got
10 times slower
TestFile("fast_data.txt"); // <--- more reasonable 2
times slower

Console.WriteLine("Press ENTER to exit");
Console.ReadLine();
}

static void TestFile(string sFile)
{
FileStream oFS=File.OpenRead(sFile);

ArrayList oLines=new ArrayList();

StreamReader oSR=new StreamReader(oFS);

while(oSR.BaseStream.Position<oSR.BaseStream.Lengt h)
{
oLines.Add(oSR.ReadLine());
}

oFS.Close();

Console.WriteLine("Loaded {0} lines from file
{1}",oLines.Count,sFile);

// now copy same strings into string array for speed
comparisons string[] sLines=new string[oLines.Count];

for(int i=0;i<sLines.Length;i++)
sLines[i]=(string)oLines[i];

DateTime oTime=DateTime.Now;
oLines.Sort();
Console.WriteLine("Time to sort strings in ArrayList is:
{0}
msec",(DateTime.Now.Ticks-oTime.Ticks)/TimeSpan.TicksPerMillisecond);

oTime=DateTime.Now;
Array.Sort(sLines);
Console.WriteLine("Time to sort strings in string[] array
is: {0}
msec",(DateTime.Now.Ticks-oTime.Ticks)/TimeSpan.TicksPerMillisecond);
} }
}

//////////////////////////////////////////////////////////////////////
////




奇怪,因为ArrayList.Sort使用Array.Sort():D(使用反射器,和

看看你自己) 。所以它不是那种'有缺陷的那种,因为它'

正是同样的例程被执行。


唯一的区别是ArrayList.Sort()使用默认的比较器,

Array.Sort()不是。我认为这就是问题发生的地方。


Iow:你的排序并不完全一样:数组排序正在排序

一个字符串数组。 arraylist排序使用比较器排序对象数组




FB


-

-------------------------------------------- ----------------------------

LLBLGen Pro的首席开发人员,这是一款高效的O / R映射器。 NET

LLBLGen Pro网站: http://www.llblgen.com

我的.NET博客: http://weblogs.asp .net / fbouma

Microsoft MVP(C#)

--------------------- -------------------------------------------------- -



Strange, as ArrayList.Sort uses Array.Sort() :D (use reflector, and
see for yourself). So it''s not the sort that''s flawed, as it''s
precisely the same routine that gets executed.

The only difference is that ArrayList.Sort() uses a default comparer,
Array.Sort() doesn''t. I think this is where the problem occurs.

I.o.w.: your sorts aren''t exactly the same: the array sort is sorting
an array of strings. The arraylist sort is sorting an array of objects
using a comparer.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------


" Frans Bouma [C#MVP]"写道:
"Frans Bouma [C# MVP]" wrote:
I.o.w。:你的排序并不完全相同:数组排序是排序
一个字符串数组。 arraylist排序使用比较器对对象数组进行排序。


我知道这一点 - 我提到过拳击/拆箱开销。问题是:

a)它比.NET 1.1慢了很多 - 仅此一点使得它无法接受

b)它的某些数据的速度慢得多

奇怪,因为ArrayList.Sort使用Array.Sort():D(使用反射器,并且
自己查看)。所以它并不是那种'有缺陷的那种,因为它与执行的程序完全相同。
I.o.w.: your sorts aren''t exactly the same: the array sort is sorting
an array of strings. The arraylist sort is sorting an array of objects
using a comparer.
I am aware of that - I mentioned boxing/unboxing overheads. The issues are:
a) its a LOT slower than in .NET 1.1 <-- this alone makes it unacceptable
b) its DRAMATICALLY slower with some data
Strange, as ArrayList.Sort uses Array.Sort() :D (use reflector, and
see for yourself). So it''s not the sort that''s flawed, as it''s
precisely the same routine that gets executed.




我可以'不能说肯定是什么'但是_something_当然是,它不那么

使ArrayList.Sort的性能慢得多,这让我感到困扰,它的性能要慢得多。与.NET 1.1相同的代码,我添加了List< string>测试它和

运行得很好,问题似乎只在ArrayList中 - 有

绝对没有理由为什么排序应该多次使用

出现在.NET 1.1中,我实际上有一些更糟糕的案例数据场景

需要更长的时间,这是一个问题,因为遗留的.NET 1.1不会

使用List< string>因此需要重写。如果性能受到影响,那么它可能会被忽略,但是如果微软的任何人有兴趣进一步跟踪这个性能,那么性能的提升似乎是_DATA_

依赖的。 />
我很乐意提供帮助。


以下链接指向该论坛所破坏的源代码:
http://majestic12.co.uk/files/other/...bug/program。 cs


当然我通过使用List< string>来解决它,但我不喜欢它

" solution"因为:

a)它阻止我能够做遗留的.NET 1.1构建或涉及

条件定义

b)遗留编译的东西没有源代码将被无法解释的减速打击


问候,


Alex



I can''t say for sure what''s flawed but _something_ certainly is, its no so
much slower performance of ArrayList.Sort that bothers me, its much slower
performance than same code for .NET 1.1, I added List<string> test and it
runs just fine, the problem appears to be solely in ArrayList - there is
absolutely no reason why sorting should take many times over version that is
present in .NET 1.1, I actually have got some much worse case data scenarios
that take even much much longer, this is an issue since legacy .NET 1.1 won''t
use List<string> and thus require a rewrite. If performance hit was moderate
it could have been ignored, but the performance hit appears to be _DATA_
dependent, if anyone from Microsoft is interested to track this further then
I will be happy to assist.

Here is link to the source code that was mangled by this forum:
http://majestic12.co.uk/files/other/...bug/program.cs

Of course I did workaround it by using List<string>, but I don''t like that
"solution" since:
a) it prevents me from being able to do legacy .NET 1.1 builds or involve
conditional defines
b) legacy compiled stuff without source will be hit by unexplained slowdowns

regards,

Alex


Alex Chudnovsky <铝************ @ discussions.microsoft.com>写道:
Alex Chudnovsky <Al************@discussions.microsoft.com> wrote:
" Frans Bouma [C#MVP]"写道:
"Frans Bouma [C# MVP]" wrote:
I.o.w。:你的排序并不完全相同:数组排序是排序
一个字符串数组。 arraylist排序使用比较器对对象数组进行排序。
I.o.w.: your sorts aren''t exactly the same: the array sort is sorting
an array of strings. The arraylist sort is sorting an array of objects
using a comparer.



我知道 - 我提到了装箱/拆箱的开销。



I am aware of that - I mentioned boxing/unboxing overheads.




那些与字符串不相关的内容 - 参考类型没有拳击/拆箱




(我还没看完这篇帖子的其余内容 - 只是觉得我现在很快就会提到

。)


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet 博客: http://www.msmvps.com/jon.skeet

如果回复小组,请不要给我发邮件



Those won''t be relevant with strings - there''s no boxing/unboxing
involved with reference types.

(I haven''t read the rest of this thread - just thought I''d mention that
quickly now.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


这篇关于ArrayList.Sort中的.NET 2.0性能错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆