这件事情似乎很无聊但是没人做我来做下苦力吧
以下是一些简单的测试单位以ms计算注意里面用到循环的数量有些事W有些是W
这些记录可以作为编程过程中的一些参考
测试平台
奔腾G 双核CPU
G内存
vs 调试环境测试
一ArrayList (WW)
Stopwatch timer = new Stopwatch();
timerStart();
SystemCollectionsArrayList al = new SystemCollectionsArrayList();
for (int i = ; i < ; i++)
{
alAdd(i);
}
timerStop();
ConsoleWrite(timerElapsedMillisecondsToString() + \t);
Stopwatch timer = new Stopwatch();
timerStart();
for (int i = ; i < ; i++)
{
alContains(i);
}
timerStop();
ConsoleWriteLine(timerElapsedMillisecondsToString());
二Hashtable (WW)
Stopwatch timer = new Stopwatch();
timerStart();
SystemCollectionsHashtable ht = new SystemCollectionsHashtable();
for (int i = ; i < ; i++)
{
htAdd(i i);
}
timerStop();
ConsoleWrite(timerElapsedMillisecondsToString() + \t);
Stopwatch timer = new Stopwatch();
timerStart();
for (int i = ; i < ; i++)
{
htContainsKey(i);
}
timerStop();
ConsoleWriteLine(timerElapsedMillisecondsToString());
}
把timer提高到万(Hashtable (WW))
三HashSet (WW)
Stopwatch timer = new Stopwatch();
timerStart();
SystemCollectionsGenericHashSet ht = new SystemCollectionsGenericHashSet(); for (int i = ; i < ; i++)
{
htAdd(i);
}
timerStop();
ConsoleWrite(timerElapsedMillisecondsToString() + \t);
Stopwatch timer = new Stopwatch();
timerStart();
for (int i = ; i < ; i++)
{
htContains(i);
}
timerStop();
ConsoleWriteLine(timerElapsedMillisecondsToString());
四List (WW)
Stopwatch timer = new Stopwatch();
timerStart();
SystemCollectionsGenericList ht = new SystemCollectionsGenericList(); for (int i = ; i < ; i++)
{
htAdd(i);
}
timerStop();
ConsoleWrite(timerElapsedMillisecondsToString() + \t);
Stopwatch timer = new Stopwatch();
timerStart();
for (int i = ; i < ; i++)
{
htContains(i);
}
timerStop();
ConsoleWriteLine(timerElapsedMillisecondsToString());
把List换成List