zoukankan
html css js c++ java
Dictionary<string,object>性能之测试
添加二百万记录时间 16秒
用键查询值的平均时间,0MS
内存使用 150M
代码:
/**/
/*
* Created by 邹健
* Date: 2008-2-14
* Time: 10:21
*
*
*/
namespace
test
{
using
System;
using
System.Collections.Generic;
class
Program
{
public
static
void
Main(
string
[] args)
{
GetTime();
Random r
=
new
Random();
Dictionary
<
string
,
object
>
dict
=
new
Dictionary
<
string
,
object
>
();
for
(
int
i
=
1
;i
<
2000000
; i
++
)
dict.Add(i.ToString(),i
+
r.Next(
1000
));
GetTime();
while
(
true
)
{
GetTime(
"
begin :
"
);
string
input
=
Console.ReadLine();
if
(input.ToLower()
==
"
end
"
)
break
;
if
(dict.ContainsKey(input))
Console.Write(
"
result is
"
+
dict[input]);
GetTime(
"
end :
"
);
}
Console.Write(
"
Press any key to continue . . .
"
);
Console.ReadKey(
true
);
}
static
void
GetTime()
{
GetTime(
"
当前时间
"
);
}
static
void
GetTime(
string
str)
{
Console.WriteLine(str
+
DateTime.Now.ToString(
"
mm:ss:fff
"
));
}
}
}
供大家学习参考,转文章随意--重典
查看全文
相关阅读:
人生苦短,我用python-- Day8
人生苦短,我用python-- Day7
人生苦短,我用python-- Day6 面向对象
人生苦短,我用python-- Day5
人生苦短,我用python-- Day4
人生苦短,我用python-- Day3
人生苦短,我用python-- Day2
人生苦短,我用python-- Day1
小康陪你学JAVA--------三大循环之Do-while循环
小康陪你学JAVA--------三大循环之For循环
原文地址:https://www.cnblogs.com/chsword/p/1068493.html
最新文章
day7----面向对象编程进阶
day6
linux内核调优详解
day5----模块
day5----正则
day4----装饰器
day4----生成器,迭代器
day4----json的简单实用
【练习题】99乘法口诀
【练习题】QQ登录练习
热门文章
字典
列表操作
For 循环
WebDriver框架
二、Cucumber Demo
一、Cucumber 环境配置
一、Tomcat+Jenkins环境搭建
二、Git命令
一段mongodb服务器读取数据超时的故事
人生苦短,我用python-- Day9
Copyright © 2011-2022 走看看