summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe de Dinechin <dinechin@redhat.com>2017-07-10 10:51:12 +0200
committerFrediano Ziglio <fziglio@redhat.com>2019-01-03 11:22:15 +0000
commita703b93a59634b2e8051a6f0bb71e215bc44c323 (patch)
treedb29717021d776c8c21f9e00f2cbf8c72b3680c2
parent166124aae15d74f1ad57d53d8f4cd607204d6e94 (diff)
Add total number of bytes written to statistics
In some of my experiments, it proved useful to have more details about the amount of data written. This commit adds the corresponding statistics in the existing stats system of SPICE.
-rw-r--r--src/spice-channel-priv.h1
-rw-r--r--src/spice-channel.c15
-rw-r--r--tools/spicy-stats.c10
3 files changed, 21 insertions, 5 deletions
diff --git a/src/spice-channel-priv.h b/src/spice-channel-priv.h
index 5984ca5..52ab357 100644
--- a/src/spice-channel-priv.h
+++ b/src/spice-channel-priv.h
@@ -139,6 +139,7 @@ struct _SpiceChannelPrivate {
GArray *remote_common_caps;
gsize total_read_bytes;
+ gsize total_written_bytes;
uint64_t last_message_serial;
GSList *flushing;
diff --git a/src/spice-channel.c b/src/spice-channel.c
index cc089eb..c917ef3 100644
--- a/src/spice-channel.c
+++ b/src/spice-channel.c
@@ -90,6 +90,7 @@ enum {
PROP_CHANNEL_TYPE,
PROP_CHANNEL_ID,
PROP_TOTAL_READ_BYTES,
+ PROP_TOTAL_WRITTEN_BYTES,
PROP_SOCKET,
};
@@ -221,6 +222,9 @@ static void spice_channel_get_property(GObject *gobject,
case PROP_TOTAL_READ_BYTES:
g_value_set_ulong(value, c->total_read_bytes);
break;
+ case PROP_TOTAL_WRITTEN_BYTES:
+ g_value_set_ulong(value, c->total_written_bytes);
+ break;
case PROP_SOCKET:
g_value_set_object(value, c->sock);
break;
@@ -326,6 +330,15 @@ static void spice_channel_class_init(SpiceChannelClass *klass)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property
+ (gobject_class, PROP_TOTAL_WRITTEN_BYTES,
+ g_param_spec_ulong("total-written-bytes",
+ "Total written bytes",
+ "Total written bytes",
+ 0, G_MAXULONG, 0,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
/**
* SpiceChannel:socket:
*
@@ -884,6 +897,7 @@ static void spice_channel_write(SpiceChannel *channel, const void *data, size_t
}
#endif
spice_channel_flush_wire(channel, data, len);
+ channel->priv->total_written_bytes += len;
}
/* coroutine context */
@@ -1154,7 +1168,6 @@ static int spice_channel_read(SpiceChannel *channel, void *data, size_t length)
#endif
}
c->total_read_bytes += length;
-
return length;
}
diff --git a/tools/spicy-stats.c b/tools/spicy-stats.c
index 8ca4cc1..9abd7d7 100644
--- a/tools/spicy-stats.c
+++ b/tools/spicy-stats.c
@@ -118,17 +118,19 @@ int main(int argc, char *argv[])
g_main_loop_run(mainloop);
{
GList *iter, *list = spice_session_get_channels(session);
- gulong total_read_bytes;
+ gulong total_read_bytes, total_written_bytes;
gint channel_type;
- printf("total bytes read:\n");
+ printf("total bytes read / written:\n");
for (iter = list ; iter ; iter = iter->next) {
g_object_get(iter->data,
"total-read-bytes", &total_read_bytes,
+ "total-written-bytes", &total_written_bytes,
"channel-type", &channel_type,
NULL);
- printf("%s: %lu\n",
+ printf("%16s: %8lu %8lu\n",
spice_channel_type_to_string(channel_type),
- total_read_bytes);
+ total_read_bytes,
+ total_written_bytes);
}
g_list_free(list);
}