speed.py 858 B

1234567891011121314151617181920212223242526272829303132
  1. from web3Tools import *
  2. import pymysql
  3. def speedTest(function, *args):
  4. intiTime = time.time()
  5. i = 0
  6. while time.time() -1 < intiTime:
  7. function(*args)
  8. i = i +1
  9. return i
  10. def test0():
  11. return EthMevModel.find_by_hash('0x73cfd86895f97db1fbf555cdd449b115ce1a10c2')
  12. def test1():
  13. cursor.execute(SQL)
  14. data = cursor.fetchone()
  15. return data
  16. db = pymysql.connect(host='127.0.0.1',
  17. user='root',
  18. password='Qwe410410.',
  19. database='ethmev')
  20. cursor = db.cursor()
  21. db.ping(reconnect=True)
  22. SQL = "SELECT * FROM t_ethereum_mev_v1 WHERE hash='%s'" % "0x73cfd86895f97db1fbf555cdd449b115ce1a10c2"
  23. printTime(test0())
  24. printTime(test1())
  25. printTime(speedTest(test0,), 'JAVA API')
  26. printTime(speedTest(test1,), 'PY SQL')
  27. cursor.close()