string格式时间写入数据:

{
"_id" : ObjectId("5d314731a96f332d6c3193d4"),
"news_id" : NumberInt(1),
"member_id" : NumberInt(1),
"content" : "测试写入",
"add_time" : "2019/7/19 12:29:37"
}
{
"_id" : ObjectId("5d314731a96f332d6c3193d5"),
"news_id" : NumberInt(1),
"member_id" : NumberInt(1),
"content" : "测试写入",
"add_time" : "2019/7/19 12:29:37"
}

long格式时间写入数据:

{
"_id" : ObjectId("5d31474ba96f332d6c325724"),
"news_id" : NumberInt(1),
"member_id" : NumberInt(1),
"content" : "测试写入",
"add_time" : NumberLong(1563510603)
}
{
"_id" : ObjectId("5d31474ba96f332d6c325725"),
"news_id" : NumberInt(1),
"member_id" : NumberInt(1),
"content" : "测试写入",
"add_time" : NumberLong(1563510603)
}

结果:

string时间写入每次1W条性能测试:
【】分【】秒【】毫秒
【】分【】秒【】毫秒
【】分【】秒【】毫秒
【】分【】秒【】毫秒
【】分【】秒【】毫秒 long时间写入每次1W条性能测试:
【】分【】秒【】毫秒
【】分【】秒【】毫秒
【】分【】秒【】毫秒
【】分【】秒【】毫秒
【】分【】秒【】毫秒

long时间写入1W条性能测试:
【0】分【5】秒【400】毫秒
【0】分【3】秒【934】毫秒
【0】分【4】秒【118】毫秒
【0】分【4】秒【343】毫秒
【0】分【3】秒【479】毫秒

string时间写入1W条性能测试:
【0】分【4】秒【314】毫秒
【0】分【4】秒【824】毫秒
【0】分【4】秒【209】毫秒
【0】分【4】秒【234】毫秒
【0】分【5】秒【210】毫秒

            DateTime nowT = DateTime.Now;
IList<BsonDocument> list = new List<BsonDocument>();
for (int i = ; i < ; i++)
{
BsonDocument dom = BsonDocument.Parse(req.ToJson());
if (string.IsNullOrEmpty(req.parent_id))
dom.Add("add_time", DateTime.Now.ToString("G"));
else
dom.Add("add_time", Util.Helpers.Convert.ToTimeStamp(DateTime.Now)); dom.Remove("parent_id");
dom.Remove("ref_id");
list.Add(dom);
}
await MongoContext.InsertManyAsync(name, list);
DateTime lastT = DateTime.Now;
TimeSpan span = lastT-nowT;
var res = $"【{span.Minutes}】分【{span.Seconds}】秒【{span.Milliseconds}】毫秒";
return res;

mongodb性能测试:long时间戳与string格式时间的更多相关文章

  1. 10位时间戳转为C#格式时间

    /// <summary> /// 10位时间戳转为C#格式时间 /// </summary> /// <param name=”timeStamp”></p ...

  2. 时间戳转为C#格式时间

    经常发现很多地方使用一个时间戳表示时间.比如: 1370838759 表示 2013年6月10日 12:32:39. 我们就需要一个工具,方便地转换这种时间格式 什么是时间戳? 时间戳, 又叫Unix ...

  3. js中将时间(如:2017-10-8 22:44:55)转化为时间搓,时间戳转为标准格式时间

    function split_time(time){//将当前时间转换成时间搓 例如2013-09-11 12:12:12 var arr=time.split(" "); var ...

  4. C#关于时间(获取特定格式的时间及多种方式获取当前时间戳)以及10位和13位时间戳转为特定格式

    C#关于时间(获取特定格式的时间及多种方式获取当前时间戳)以及10位和13位时间戳转为特定格式 置顶 2018年03月06日 19:16:51 黎筱曦 阅读数:19098 标签: C#时间 更多 个人 ...

  5. PHP获取时间、时间戳的各种格式

    1.获取当前时间方法date() 很简单,这就是获取时间的方法,格式为:date($format, $timestamp),format为格式.timestamp为时间戳--可填参数. 2.获取时间戳 ...

  6. [No00003B]string格式的日期时间字符串转为DateTime类型

    新建console程序,复制粘贴直接运行: /**/ //using System.Globalization;//代码测试大致时间2015/11/3 15:09:05 //方法一:Convert.T ...

  7. PHP获取当前时间、时间戳的各种格式写法汇总[日期时间](转)

    今天写下PHP中,如何通过各种方法 获取当前系统时间.时间戳,并备注各种格式的含义,可灵活变通.1.获取当前时间方法date()很简单,这就是获取时间的方法,格式为:date($format, $ti ...

  8. (基础篇)PHP获取时间、时间戳的各种格式写法汇总

    1.获取当前时间方法date() 很简单,这就是获取时间的方法,格式为:date($format, $timestamp),format为格式.timestamp为时间戳–可填参数. 2.获取时间戳方 ...

  9. C#中 String 格式的日期时间 转为 DateTime

    C#中并没有表示时间的变量,只有DateTime,所以要表示时间,可以用TimeSpan表示. 方法一:Convert.ToDateTime(string) string格式有要求,必须是yyyy-M ...

随机推荐

  1. jenkins自动化部署springboot

    一.linux按jar包名称部署 1.执行shell PID=$(ps -ef | grep app.jar | grep -v grep | awk '{ print $2 }') if [ -z ...

  2. [python] 执行 dos 命令

    python的os模块 os模块调用CMD命令有两种方式:os.popen(),os.system(). 都是用当前进程来调用. os.system是无法获取返回值的.当运行结束后接着往下面执行程序. ...

  3. PostgreSQL的同步级别与MySQL的半同步after_sync比较

    MySQL的半同步中通过binlog进行流复制,同步级别和PostgreSQL对比可以发现: PostgreSQL                MySQL off local            ...

  4. 300英雄的危机(heroes)

    题面 正解与图书馆馆长的考验一致,都是分层图SPFA: #include <iostream> #include <cstdio> #include <cstring&g ...

  5. php aes加解密,mcrypt_encrypt 和openssl_encrypt

    php7.1以下版本使用 /* * mcrypt_encrypt 加密 * php7.1开始被丢弃 可以使用openssl_encrypt * */ function aes_encrypt($con ...

  6. Laravel5.5 实现session配置

    \Illuminate\Session\Middleware\StartSession::class,\Illuminate\View\Middleware\ShareErrorsFromSessio ...

  7. Hive 教程(一)-安装与配置解析

    安装就安装 ,不扯其他的 hive 依赖 在 hive 安装前必须具备如下条件 1. 一个可连接的关系型数据库,如 Mysql,postgresql 等,用于存储元数据 2. hadoop,并启动 h ...

  8. 【深入理解JVM】类加载器与双亲委派模型 (转)

    出处: [深入理解JVM]类加载器与双亲委派模型 加载类的开放性 类加载器(ClassLoader)是Java语言的一项创新,也是Java流行的一个重要原因.在类加载的第一阶段“加载”过程中,需要通过 ...

  9. 了解MyISAM与InnoDB的索引差异(转)

    出处原文: 1分钟了解MyISAM与InnoDB的索引差异 数据库的索引分为主键索引(Primary Inkex)与普通索引(Secondary Index).InnoDB和MyISAM是怎么利用B+ ...

  10. win10子系统Ubuntu重置

    重置: 在win10命令行下执行: lxrun /uninstall /full 安装: win+R打开bash 执行命令: lxrun /install /y