pull: Print elapsed time

This commit is contained in:
Colin Walters 2012-10-05 17:20:40 -04:00
parent 52a0b7bdb1
commit 3c0fe01152
1 changed files with 9 additions and 2 deletions

View File

@ -1185,6 +1185,8 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
GKeyFile *remote_config = NULL; GKeyFile *remote_config = NULL;
char **configured_branches = NULL; char **configured_branches = NULL;
guint64 bytes_transferred; guint64 bytes_transferred;
guint64 start_time;
guint64 end_time;
memset (pull_data, 0, sizeof (*pull_data)); memset (pull_data, 0, sizeof (*pull_data));
@ -1214,6 +1216,8 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
goto out; goto out;
} }
start_time = g_get_monotonic_time ();
pull_data->stdout_is_tty = isatty (1); pull_data->stdout_is_tty = isatty (1);
pull_data->remote_name = g_strdup (argv[1]); pull_data->remote_name = g_strdup (argv[1]);
@ -1406,6 +1410,8 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
g_print ("remote %s is now %s\n", remote_ref, checksum); g_print ("remote %s is now %s\n", remote_ref, checksum);
} }
end_time = g_get_monotonic_time ();
bytes_transferred = ostree_fetcher_bytes_transferred (pull_data->fetcher); bytes_transferred = ostree_fetcher_bytes_transferred (pull_data->fetcher);
if (bytes_transferred > 0) if (bytes_transferred > 0)
{ {
@ -1414,10 +1420,11 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
shift = 1; shift = 1;
else else
shift = 1024; shift = 1024;
g_print ("%u metadata, %u content objects fetched; %" G_GUINT64_FORMAT " %s transferred\n", g_print ("%u metadata, %u content objects fetched; %" G_GUINT64_FORMAT " %s transferred in %u seconds\n",
pull_data->n_fetched_metadata, pull_data->n_fetched_content, pull_data->n_fetched_metadata, pull_data->n_fetched_content,
(guint64)(bytes_transferred / shift), (guint64)(bytes_transferred / shift),
shift == 1 ? "B" : "KiB"); shift == 1 ? "B" : "KiB",
(guint) ((end_time - start_time) / G_USEC_PER_SEC));
} }
ret = TRUE; ret = TRUE;