123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- # -*- coding: utf-8 -*-
- #!/usr/bin/env python
- import os, sys
- import threading
- import uuid
- import xlrd
- from xlrd import xldate_as_tuple
- import simplejson as json
- import datetime
- from django.conf import settings
- PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..')
- sys.path.insert(0, PROJECT_ROOT)
- os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'configs.testing')
- from script.base import init_env
- init_env(interactive = False)
- from apps.web.device.models import SIMCard,Device
- from apps.web.constant import Const
- from apps.web.user.models import ConsumeRecord
- from pymongo import MongoClient
- import time,datetime,random,copy
- from bson import ObjectId
- print('start insert now.....')
- startTime = time.time()
- idList = [("5a153e808732d62e3647cfad",ObjectId("5fcd4954003048ae34b55d68")),
- ("5a1795078732d671884755fc",ObjectId("5fcd76986f2925679f3bb168")),
- ("5a1795078732d671884755fc",ObjectId("5fcd75966f29257ee23b89e1")),
- ("5a1795078732d671884755fc",ObjectId("5fce3c7f6f2925535543556f")),
- ("5a1795078732d671884755fc",ObjectId("5fcec88c003048b5ae2f435c")),
- ("5a1795078732d671884755fc",ObjectId("5fce1be76f29254cc75f132c")),
- ("5a1795078732d671884755fc",ObjectId("5fcde18c6f292508b6a6c998")),
- ("5a1795078732d671884755fc",ObjectId("5fcd8d1f003048d8ecd06415")),
- ("5a1795078732d671884755fc",ObjectId("5fce18e06f2925227de09e46")),
- ("5a153e808732d62e3647cfad",ObjectId("5fce044b6f29254341255ca4"))]
- orderNoList = [
- ('5a153e808732d62e3647cfad','1607337200500387'),
- ('5a1795078732d671884755fc','1607270555705875'),
- ('5a1795078732d671884755fc','1607342956104564'),
- ('5a153e808732d62e3647cfad','1607351004741034'),
- ('5a153e808732d62e3647cfad','1607350790816644'),
- ('5a153e808732d62e3647cfad','1607337319522926'),
- ('5a1795078732d671884755fc','1607349199986226'),
- ('5a1795078732d671884755fc','1607328522859221'),
- ('5a153e808732d62e3647cfad','1607351093945470'),
- ('5a1795078732d671884755fc','1607345555776737')
- ]
- c = MongoClient(host="172.16.69.132", port=20000)
- collection = c['washpay2']['ConsumeRecord']
- while True:
- startTime = time.time()
- for ii in range(10):
- index = random.randint(0,9)
- collection.find_one({"ownerId":idList[index][0],"_id":idList[index][1]})
- collection.find_one({"ownerId":orderNoList[index][0],"orderNo":orderNoList[index][1]})
- print('spend time=%s' % (time.time()-startTime))
- time.sleep(1)
|