tetsuya-ki / discord-reminderbot

Discord用のリマインダーBotです(discord reminder bot)。
MIT License
22 stars 9 forks source link

処理が遅い #82

Open tetsuya-ki opened 2 months ago

tetsuya-ki commented 2 months ago

書き込みやら何やらで以下の流れをずっとやってるため遅い。

  1. Decode
  2. 書き込み
  3. 読み込み(なんで入れたんだっけ?)
  4. Encode
  5. (必要があればDiscordへ添付) 今は無効にしてる

データを一時的にインメモリデータベースに格納し、そこでごちゃごちゃやった後に、ファイルへ出力すれば多分速くなる

https://stackoverflow.com/questions/3850022/how-can-i-load-an-existing-database-file-into-memory-in-python-sqlite-3

" Availability: SQLite 3.6.11 or higher. New in version 3.7.

import sqlite3

source = sqlite3.connect('existing_db.db')
dest = sqlite3.connect(':memory:')
source.backup(dest)
$ poetry run python
Python 3.9.13 (main, Aug 28 2022, 15:38:55) 
[Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.37.0'
tetsuya-ki commented 1 month ago

インメモリにしなくても、読み込みさえブロックすれば、なんとかなる気がしている。そっちの方向でやろうかな〜