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
"
));
}
}
}
供大家学习参考,转文章随意--重典
查看全文
相关阅读:
jdk8中奖Date转换为String格式的方法
Java Calendar详解
Java Calendar使用总结
得到当前时间的小时数
Java中 break continue return 的区别
两个QWidget叠加,可部分代替layout的功能
Qt5官方demo解析集35——Music Player(使用winextras模块)
P和P1指向了O和O1两个变量(对象)的地址, 而不是O和O1的内容(对象的实际地址)——充分证明@是取变量(对象)的地址,而不是变量里面的内容,够清楚!
提高Android和iOS调试编译速度
Delphi 快速获取文件大小(使用_lopen和FileSeek,此函数可以快速获取文件大小,即使文件已经被其它程序锁定)
原文地址:https://www.cnblogs.com/chsword/p/1068493.html
最新文章
Java实现 LeetCode 201 数字范围按位与
Java实现 LeetCode 201 数字范围按位与
Java实现 LeetCode 201 数字范围按位与
Java实现 LeetCode 200 岛屿数量
Java实现 LeetCode 200 岛屿数量
boost::thread用法
ASIO攻破!!!----转
boost::asio网络传输错误码的一些实验结果(recv error_code)
boost::thread之while(true)型线程终结方法
Boost Thread学习笔记五
热门文章
Boost Thread学习笔记四
Boost Thread学习笔记三
Boost Thread学习笔记二
Boost Thread学习笔记
boost asio 异步实现tcp通讯
CodeBlock 快捷键大全
CodeBblock 常用快捷键 (最常用)
Code::Blocks代码自动提示设置及常用快捷键
KDevelop使用经验
各大开源软件镜像源
Copyright © 2011-2022 走看看