mongodb写入10万条数据的耗时差不多是1s
import time
import pymongo
from pymongo import MongoClient
# 连接到MongoDB
client = MongoClient('mongodb://localhost:27017/')
db = client['test_db']
collection = db['test_collection']
# 生成10万条数据
documents = [{"name": "example", "value": i, "timestamp": "2024-06-13T00:00:00Z"} for i in range(1000000)]
# 批量插入
start_time = time.time()
collection.insert_many(documents)
end_time = time.time()
print(f"写入10万条数据花费的时间: {end_time - start_time} 秒")