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
"
));
}
}
}
供大家学习参考,转文章随意--重典
查看全文
相关阅读:
BZOJ 1192 鬼谷子的钱袋
浅谈双连通分量、强连通分量
BZOJ 1047 理想的正方形
浅谈单调队列、单调栈
django ORM之manytomany跨表
django DateTimeField和DateField和TimeField
django 一对多的添加记录create 和save 方法,update 更新和save()方法的区别,查询API的方法
Python生成随机验证码
obj.t2c.all-------django自动生成第三张多对多关系表中另一张表信息在前端的显示
Form组件验证之ajax提交数据并显示错误信息
原文地址:https://www.cnblogs.com/chsword/p/1068493.html
最新文章
bzoj1090: [SCOI2003]字符串折叠
bzoj1068: [SCOI2007]压缩
codeVS1966 乘法游戏
bzoj2588: Spoj 10628. Count on a tree
bzoj4627: [BeiJing2016]回转寿司
负载均衡与CDN简介
MongoDB
Redis
备战秋招——数据库
备战秋招——操作系统
热门文章
备战秋招——C++知识点
备战秋招——计算机网络
todo list
python thrift demo
BZOJ 1053 反素数ant
BZOJ 1045 糖果传递
浅谈栈、队列
BZOJ 1406 密码箱
BZOJ 1800 fly-飞行棋
BZOJ 1257 余数之和sum
Copyright © 2011-2022 走看看