使用time
实用程序
如果您刚刚在脚本的执行时间之后,您可以在mongoimport
命令行前加上标准的 Unix-ish 实用程序time
,例如:
time mongoimport --db jontestcsv --collection Aircraft --ignoreBlanks --type csv --headerline --file /home/jon/Desktop/Aircraft.csv
time 使用任何给定的参数 ARG 运行程序 COMMAND。当 COMMAND 完成时,时间显示有关 COMMAND 使用的资源的信息(默认情况下在标准错误输出上)。如果 COMMAND 以非零状态退出,则时间会显示警告消息和退出状态。
grepmongod
日志
mongod
如果您确定作业的连接 ID,您还可以通过更多的努力从日志中获取信息mongoimport
。例如,在下面的日志片段中,您可以计算来自 localhost 的连接 #27 被接受与 grepping for 结束之间的时间差127.0.0.1:64023
:
2014-07-21T06:20:59.143+1000 [initandlisten] connection accepted from 127.0.0.1:64023 #27 (2 connections now open)
2014-07-21T06:20:59.180+1000 [conn27] build index on: test.twitter properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "test.twitter" }
2014-07-21T06:20:59.182+1000 [conn27] added index to empty collection
2014-07-21T06:21:05.705+1000 [FileAllocator] allocating new datafile /data/test.1, filling with zeroes...
2014-07-21T06:21:05.709+1000 [FileAllocator] creating directory /data/_tmp
2014-07-21T06:21:06.337+1000 [FileAllocator] done allocating datafile data/test.1, size: 128MB, took 0.618 secs
2014-07-21T06:21:06.343+1000 [conn27] insert test.twitter ninserted:1 keyUpdates:0 numYields:0 locks(micros) w:663227 663ms
2014-07-21T06:21:11.924+1000 [conn27] end connection 127.0.0.1:64023 (1 connection now open)