summaryrefslogtreecommitdiffstats
path: root/subsurface-core/save-git.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-04-03 19:26:05 -0500
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-04-04 14:18:11 -0700
commit5821c56da24d0aa02e5bb6d54f14e7651d23269b (patch)
tree2d42d844bfc632fafbba6fb1eca7fc4d29e6a75f /subsurface-core/save-git.c
parent904539024e97b5980050c4ad65a6d2a901f3cb3a (diff)
downloadsubsurface-5821c56da24d0aa02e5bb6d54f14e7651d23269b.tar.gz
Instrument the git storage code
This allows fairly fine grained analysis on what part of loading from and saving to git we are spending our time. Compute performance and network speed play a significant role in how all this plays out. The routine to check if we can reach the cloud server is modified to send updates every second so we don't hang without any feedback for five seconds when there is network but we can't reach the cloud server (not an unlikely scenario in many dive locations with poor network quality) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurface-core/save-git.c')
-rw-r--r--subsurface-core/save-git.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/subsurface-core/save-git.c b/subsurface-core/save-git.c
index d089095b6..693abb623 100644
--- a/subsurface-core/save-git.c
+++ b/subsurface-core/save-git.c
@@ -911,9 +911,19 @@ static int create_git_tree(git_repository *repo, struct dir *root, bool select_o
trip->index = 0;
/* save the dives */
+ int notify_increment = dive_table.nr > 10 ? dive_table.nr / 10 : 1;
+ int last_threshold = 0;
for_each_dive(i, dive) {
struct tm tm;
struct dir *tree;
+ char buf[] = "save dives x0%";
+
+ if (i / notify_increment > last_threshold) {
+ // notify of progress - we cover the range of 20..50
+ last_threshold = i / notify_increment;
+ buf[11] = last_threshold + '0';
+ git_storage_update_progress(20 + 3 * last_threshold, buf);
+ }
trip = dive->divetrip;
@@ -1170,6 +1180,9 @@ int do_git_save(git_repository *repo, const char *branch, const char *remote, bo
if (verbose)
fprintf(stderr, "git storage: do git save\n");
+ if (!create_empty) // so we are actually saving the dives
+ git_storage_update_progress(19, "start git save");
+
/* Start with an empty tree: no subdirectories, no files */
tree.name[0] = 0;
tree.subdirs = NULL;
@@ -1181,6 +1194,9 @@ int do_git_save(git_repository *repo, const char *branch, const char *remote, bo
if (create_git_tree(repo, &tree, select_only))
return -1;
+ if (verbose)
+ fprintf(stderr, "git storage, write git tree\n");
+
if (write_git_tree(repo, &tree, &id))
return report_error("git tree write failed");