使用VS2010构建时,以下C#代码似乎比使用VS2008 运行速度慢:在Core i5 Win7 x64 8 GB RAM PC上,VS2008内置版本在大约7.5秒内对字符串进行排序,而VS2010内置版本需要大约9秒.这是为什么?
我的代码有什么问题吗?
排序算法是否在VS2010中发生了变化?
底层CLR中有什么不同会使性能变差吗?
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
namespace StringSortCSharp
{
/// <summary>
/// Console app to test string sorting performance in C#.
/// </summary>
class Program
{
/// <summary>
/// Displays the first lines from a vector of strings.
/// </summary>
/// <param name="wishedN">Number of lines to display.</param>
/// <param name="lines">Source lines to display.</param>
private static void DisplayFirst(int wishedN, List<string> lines)
{
int …Run Code Online (Sandbox Code Playgroud)