Last active
May 22, 2021 06:48
-
-
Save idkravitz/8c09b2c4215d3c5f0641fbf13be8946a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import string | |
| import sqlite3 | |
| import time | |
| import sqlalchemy | |
| import os.path | |
| from binance_trade_bot.database import Database, LogScout | |
| from binance_trade_bot.logger import Logger | |
| from binance_trade_bot.config import Config | |
| import sys | |
| database_path = "bench.db" | |
| fake_coins = list(string.ascii_uppercase[:5]) | |
| # print(fake_coins) | |
| print("="*20) | |
| print(f"python: {sys.version}") | |
| print(f"sqlite ver.: {sqlite3.sqlite_version}") | |
| print(f"sqlalchemy ver.: {sqlalchemy.__version__}") | |
| print("="*20) | |
| logger = Logger(logging_service="bench_database", enable_notifications=False) | |
| config = Config() | |
| if os.path.exists(database_path): | |
| os.remove(database_path) | |
| db = Database(logger, config, uri=f"sqlite:///{database_path}") | |
| print("Creating database") | |
| db.create_database() | |
| print("Setting up coins") | |
| db.set_coins(fake_coins) | |
| print("Bench log_scouts") | |
| pairs = db.get_pairs() | |
| t0 = time.time() | |
| for pair in pairs: | |
| db.log_scout(pair, 0, 0, 0) | |
| regular_dt = time.time() - t0 | |
| print(f"log_scouts for each pair (total: {len(pairs)}) took {regular_dt} seconds") | |
| print("Bench batch_log_scouts") | |
| t0 = time.time() | |
| scouts = [] | |
| for pair in pairs: | |
| scouts.append(LogScout(pair, 0, 0, 0)) | |
| db.batch_log_scout(scouts) | |
| batch_dt = time.time() - t0 | |
| print(f"batch_log_scouts for each pair (total: {len(pairs)}) took {batch_dt} seconds") | |
| print(f"Boost ratio is {regular_dt/batch_dt}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment