项目中包含浮点运算,大概每秒 20 - 100 万左右. 其计算结果每秒只包含1000个左右。 因此大量运算是重复性的。程序运行时,cpu 在 3% - 10% 浮动。打算将结果缓存。根据键值索值。
目前考虑数据类型有: SortedList , SortedDictionary , Dictionary , List 。测试结果如下:
aaarticlea/png;base64,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if9BgAAAAAASUVORK5CYII=" alt="" />
代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace ConsoleApplication1
{
class Program
{
static System.Random random = new Random();
static void Main(string[] args)
{
System.Threading.Thread.Sleep(1000); System.Drawing.PointF[] p = new System.Drawing.PointF[1024];
for (int i = 0; i < 1024; i++)
{
p[i] = new System.Drawing.PointF((float)random.NextDouble(), (float)random.NextDouble());
} double[] find = new double[10];
find[0] = p[10].X;
find[1] = p[800].X;
find[2] = p[200].X;
find[3] = p[199].X;
find[4] = p[485].X;
find[5] = p[874].X;
find[6] = p[912].X;
find[7] = p[110].X;
find[8] = p[12].X;
find[9] = p[600].X; testSortList(p, find);
Console.WriteLine();
testSortedDictionary(p, find);
Console.WriteLine();
testDictionary(p, find);
Console.WriteLine();
testList(p, find); Console.Read(); } static void testSortList(System.Drawing.PointF [] p , double [] find) {
SortedList<double, double> s = new SortedList<double, double>(1024); System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
stopWatch.Start();
foreach (System.Drawing.PointF sp in p)
{
s.Add(sp.X, sp.Y);
}
stopWatch.Stop();
Console.WriteLine("SortedList add:" + stopWatch.ElapsedTicks); stopWatch.Reset();
stopWatch.Start();
foreach (double d in find)
{
Console.WriteLine(s.ContainsKey(d));
}
stopWatch.Stop(); Console.WriteLine("SortedList find:" + stopWatch.ElapsedTicks);
} static void testSortedDictionary(System.Drawing.PointF[] p, double[] find)
{
SortedDictionary<double, double> s = new SortedDictionary<double, double>(); System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
stopWatch.Start();
foreach (System.Drawing.PointF sp in p)
{
s.Add(sp.X, sp.Y);
}
stopWatch.Stop();
Console.WriteLine("SortedDictionary add:" + stopWatch.ElapsedTicks); stopWatch.Reset();
stopWatch.Start();
foreach (double d in find)
{
Console.WriteLine(s.ContainsKey(d));
}
stopWatch.Stop(); Console.WriteLine("SortedDictionary find:" + stopWatch.ElapsedTicks);
} static void testDictionary(System.Drawing.PointF[] p, double[] find)
{
Dictionary<double, double> s = new Dictionary<double, double>(1024); System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
stopWatch.Start();
foreach (System.Drawing.PointF sp in p)
{
s.Add(sp.X, sp.Y);
}
stopWatch.Stop();
Console.WriteLine("Dictionary add:" + stopWatch.ElapsedTicks); stopWatch.Reset();
stopWatch.Start();
foreach (double d in find)
{
Console.WriteLine(s.ContainsKey(d));
}
stopWatch.Stop(); Console.WriteLine("Dictionary find:" + stopWatch.ElapsedTicks);
} static void testList(System.Drawing.PointF[] p, double[] find)
{ List<System.Drawing.PointF> lst = new List<System.Drawing.PointF>(); System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
stopWatch.Start();
foreach (System.Drawing.PointF sp in p)
{
lst.Add(sp);
}
stopWatch.Stop();
Console.WriteLine("List add:" + stopWatch.ElapsedTicks); stopWatch.Reset();
stopWatch.Start();
System.Drawing.PointF p2;
bool bln = false ;
foreach (double d in find)
{
p2 = lst.Find(new Predicate<System.Drawing.PointF>((p1) =>
{
return p1.X == d;
})); //foreach (System.Drawing.PointF p1 in lst)
//{
// if (p1.X == d)
// {
// bln = true;
// break;
// }
//} //for (int i = 0; i < lst.Count; i++ )
//{
// if (lst[i].X == d)
// {
// bln = true;
// break;
// }
//} if (bln)
{
Console.WriteLine("True");
bln = false;
}
else {
Console.WriteLine("False");
}
}
stopWatch.Stop(); Console.WriteLine("List find:" + stopWatch.ElapsedTicks);
} }
}