aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2022-09-26 23:38:30 -0400
committerGravatar Chris Xiong <chirs241097@gmail.com> 2022-09-26 23:38:30 -0400
commit617adf4090fbaac3a3b2d943548eeb6516fb9bdd (patch)
treea356c89886ed03dcf0085b4075e754b5ddc3ae9b
parentc95bd9595bdc612a78c6364ce6ca8f20ef28cd52 (diff)
downloaddeduper-617adf4090fbaac3a3b2d943548eeb6516fb9bdd.tar.xz
Add show db engine memory usage.
-rw-r--r--qdeduper/mingui.cpp20
-rw-r--r--qdeduper/mingui.hpp4
-rw-r--r--qdeduper/sigdb_qt.cpp5
-rw-r--r--qdeduper/sigdb_qt.hpp2
-rw-r--r--xsig/include/signature_db.hpp2
-rw-r--r--xsig/src/signature_db.cpp7
6 files changed, 39 insertions, 1 deletions
diff --git a/qdeduper/mingui.cpp b/qdeduper/mingui.cpp
index 3d11e36..c9ca2f8 100644
--- a/qdeduper/mingui.cpp
+++ b/qdeduper/mingui.cpp
@@ -29,12 +29,12 @@
#include <QAction>
#include <QSplitter>
#include <QString>
+#include <QTimer>
#include <QScrollArea>
#include <QListView>
#include <QProgressDialog>
#include <QStandardItemModel>
#include <QLabel>
-#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QStatusBar>
#include <QPixmap>
@@ -84,6 +84,7 @@ DeduperMainWindow::DeduperMainWindow()
this->setup_menu();
this->update_actions();
sb = this->statusBar();
+ sb->addPermanentWidget(dbramusg = new QLabel());
sb->addPermanentWidget(permamsg = new QLabel());
QLabel *opm = new QLabel();
opm->setText("placeholder status bar text");
@@ -136,12 +137,16 @@ DeduperMainWindow::DeduperMainWindow()
lv->setFont(fnt);
infopanel->setFont(fnt);
pdlb->setFont(fnt);
+ rampupd = new QTimer(this);
+ rampupd->setInterval(1000);
+ QObject::connect(rampupd, &QTimer::timeout, this, &DeduperMainWindow::update_memusg);
sr = new SettingsRegistry(QStandardPaths::writableLocation(QStandardPaths::StandardLocation::ConfigLocation) + QString("/qdeduperrc"));
int generalt = sr->register_tab("General");
sr->register_int_option(generalt, "min_image_dim", "Minimal Dimension in Image View", 16, 4096, 64);
sr->register_int_option(generalt, "thread_count", "Number of Threads (0 = Automatic)", 0, 4096, 0);
sr->register_bool_option(generalt, "toolbar_text", "Show Text in Toolbar Buttons", true);
+ sr->register_bool_option(generalt, "show_memory_usage", "Show Database Engine Memory Usage", false);
int sigt = sr->register_tab("Signature");
sr->register_double_option(sigt, "signature/threshold", "Distance Threshold", 0, 1, 0.3);
prefdlg = new PreferenceDialog(sr, this);
@@ -770,6 +775,19 @@ void DeduperMainWindow::apply_prefs()
id->set_min_height(sr->get_option_int("min_image_dim"));
tb->setToolButtonStyle(sr->get_option_bool("toolbar_text") ? Qt::ToolButtonStyle::ToolButtonTextBesideIcon
: Qt::ToolButtonStyle::ToolButtonIconOnly);
+ if (sr->get_option_bool("show_memory_usage"))
+ this->rampupd->start();
+ else
+ {
+ this->rampupd->stop();
+ this->dbramusg->setText(QString());
+ }
+}
+
+void DeduperMainWindow::update_memusg()
+{
+ if (this->sdb)
+ dbramusg->setText(QString("Database memory usage: %1").arg(QLocale::system().formattedDataSize(this->sdb->db_memory_usage())));
}
void DeduperMainWindow::sort_reassign_hotkeys()
diff --git a/qdeduper/mingui.hpp b/qdeduper/mingui.hpp
index 5686c3e..d675d47 100644
--- a/qdeduper/mingui.hpp
+++ b/qdeduper/mingui.hpp
@@ -23,6 +23,7 @@ class QProgressDialog;
class QSplitter;
class QStandardItemModel;
class QToolBar;
+class QTimer;
class FileScanner;
class ImageItemDelegate;
class SettingsRegistry;
@@ -44,6 +45,7 @@ private:
QSplitter *l;
QTextEdit *infopanel;
QLabel *permamsg;
+ QLabel *dbramusg;
QStatusBar *sb;
QListView *lv;
QToolBar *tb = nullptr;
@@ -56,6 +58,7 @@ private:
FileScanner *fsc = nullptr;
SettingsRegistry *sr = nullptr;
PreferenceDialog *prefdlg = nullptr;
+ QTimer *rampupd = nullptr;
std::unordered_set<fs::path> marked;
int sort_role;
Qt::SortOrder sort_order;
@@ -95,6 +98,7 @@ public Q_SLOTS:
void show_group(size_t gid);
void show_marked();
void apply_prefs();
+ void update_memusg();
Q_SIGNALS:
void next();
void prev();
diff --git a/qdeduper/sigdb_qt.cpp b/qdeduper/sigdb_qt.cpp
index 2128f8d..aff7312 100644
--- a/qdeduper/sigdb_qt.cpp
+++ b/qdeduper/sigdb_qt.cpp
@@ -187,3 +187,8 @@ bool SignatureDB::save(const fs::path &p)
{
return sdb->to_db_file(p);
}
+
+int64_t SignatureDB::db_memory_usage()
+{
+ return sdb->db_memory_usage();
+}
diff --git a/qdeduper/sigdb_qt.hpp b/qdeduper/sigdb_qt.hpp
index 39b57b7..a1203be 100644
--- a/qdeduper/sigdb_qt.hpp
+++ b/qdeduper/sigdb_qt.hpp
@@ -51,6 +51,8 @@ public:
bool load(const fs::path &p);
bool save(const fs::path &p);
+
+ int64_t db_memory_usage();
Q_SIGNALS:
void image_scanned(size_t n);
};
diff --git a/xsig/include/signature_db.hpp b/xsig/include/signature_db.hpp
index 23e3aae..b98b22a 100644
--- a/xsig/include/signature_db.hpp
+++ b/xsig/include/signature_db.hpp
@@ -94,6 +94,8 @@ public:
std::vector<std::pair<size_t, double>> search_image(const fs::path &path, const populate_cfg_t &cfg, bool insert = false);
+ int64_t db_memory_usage();
+
//disjoint set for keeping similar images in the same group
//some of these probably shouldn't be public. TBD...
void ds_init();
diff --git a/xsig/src/signature_db.cpp b/xsig/src/signature_db.cpp
index 3c4187b..105106b 100644
--- a/xsig/src/signature_db.cpp
+++ b/xsig/src/signature_db.cpp
@@ -479,6 +479,13 @@ std::vector<std::pair<size_t, double>> signature_db::search_image(const fs::path
return ret;
}
+int64_t signature_db::db_memory_usage()
+{
+ sqlite3_int64 r, dummy;
+ sqlite3_status64(SQLITE_STATUS_MEMORY_USED, &r, &dummy, 0);
+ return static_cast<int64_t>(r);
+}
+
void signature_db::ds_init()
{
sqlite3_exec(p->db, R"sql(