mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-11 15:40:53 +00:00
libsysprof-analyze: give counter values backpointer and time-offset
That way we can do more things when databinding into the UI such as show the counter category/name.
This commit is contained in:
@ -24,12 +24,27 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
struct _SysprofDocumentCounter
|
||||||
|
{
|
||||||
|
GObject parent_instance;
|
||||||
|
GRefString *category;
|
||||||
|
GRefString *description;
|
||||||
|
GRefString *name;
|
||||||
|
GArray *values;
|
||||||
|
double min_value;
|
||||||
|
double max_value;
|
||||||
|
gint64 begin_time;
|
||||||
|
guint id;
|
||||||
|
guint type;
|
||||||
|
};
|
||||||
|
|
||||||
SysprofDocumentCounter *_sysprof_document_counter_new (guint id,
|
SysprofDocumentCounter *_sysprof_document_counter_new (guint id,
|
||||||
guint type,
|
guint type,
|
||||||
GRefString *category,
|
GRefString *category,
|
||||||
GRefString *name,
|
GRefString *name,
|
||||||
GRefString *description,
|
GRefString *description,
|
||||||
GArray *values);
|
GArray *values,
|
||||||
|
gint64 begin_time);
|
||||||
void _sysprof_document_counter_calculate_range (SysprofDocumentCounter *self);
|
void _sysprof_document_counter_calculate_range (SysprofDocumentCounter *self);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
SysprofDocumentCounterValue *_sysprof_document_counter_value_new (guint type,
|
SysprofDocumentCounterValue *_sysprof_document_counter_value_new (guint type,
|
||||||
const SysprofDocumentTimedValue *value);
|
const SysprofDocumentTimedValue *value,
|
||||||
|
SysprofDocumentCounter *counter);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|||||||
@ -20,18 +20,22 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "sysprof-document-counter-private.h"
|
||||||
#include "sysprof-document-counter-value-private.h"
|
#include "sysprof-document-counter-value-private.h"
|
||||||
|
|
||||||
struct _SysprofDocumentCounterValue
|
struct _SysprofDocumentCounterValue
|
||||||
{
|
{
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
SysprofDocumentCounter *counter;
|
||||||
SysprofDocumentTimedValue value;
|
SysprofDocumentTimedValue value;
|
||||||
guint type;
|
guint type;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
PROP_COUNTER,
|
||||||
PROP_TIME,
|
PROP_TIME,
|
||||||
|
PROP_TIME_OFFSET,
|
||||||
PROP_VALUE_DOUBLE,
|
PROP_VALUE_DOUBLE,
|
||||||
PROP_VALUE_INT64,
|
PROP_VALUE_INT64,
|
||||||
N_PROPS
|
N_PROPS
|
||||||
@ -51,10 +55,18 @@ sysprof_document_counter_value_get_property (GObject *object,
|
|||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
|
case PROP_COUNTER:
|
||||||
|
g_value_set_object (value, sysprof_document_counter_value_get_counter (self));
|
||||||
|
break;
|
||||||
|
|
||||||
case PROP_TIME:
|
case PROP_TIME:
|
||||||
g_value_set_int64 (value, sysprof_document_counter_value_get_time (self));
|
g_value_set_int64 (value, sysprof_document_counter_value_get_time (self));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_TIME_OFFSET:
|
||||||
|
g_value_set_int64 (value, sysprof_document_counter_value_get_time_offset (self));
|
||||||
|
break;
|
||||||
|
|
||||||
case PROP_VALUE_DOUBLE:
|
case PROP_VALUE_DOUBLE:
|
||||||
g_value_set_double (value, sysprof_document_counter_value_get_value_double (self));
|
g_value_set_double (value, sysprof_document_counter_value_get_value_double (self));
|
||||||
break;
|
break;
|
||||||
@ -75,10 +87,20 @@ sysprof_document_counter_value_class_init (SysprofDocumentCounterValueClass *kla
|
|||||||
|
|
||||||
object_class->get_property = sysprof_document_counter_value_get_property;
|
object_class->get_property = sysprof_document_counter_value_get_property;
|
||||||
|
|
||||||
|
properties [PROP_COUNTER] =
|
||||||
|
g_param_spec_object ("counter", NULL, NULL,
|
||||||
|
SYSPROF_TYPE_DOCUMENT_COUNTER,
|
||||||
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
properties [PROP_TIME] =
|
properties [PROP_TIME] =
|
||||||
g_param_spec_int64 ("time", NULL, NULL,
|
g_param_spec_int64 ("time", NULL, NULL,
|
||||||
G_MININT64, G_MAXINT64, 0,
|
G_MININT64, G_MAXINT64, 0,
|
||||||
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
properties [PROP_TIME_OFFSET] =
|
||||||
|
g_param_spec_int64 ("time-offset", NULL, NULL,
|
||||||
|
G_MININT64, G_MAXINT64, 0,
|
||||||
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
properties[PROP_VALUE_DOUBLE] =
|
properties[PROP_VALUE_DOUBLE] =
|
||||||
g_param_spec_double ("value-double", NULL, NULL,
|
g_param_spec_double ("value-double", NULL, NULL,
|
||||||
@ -100,13 +122,15 @@ sysprof_document_counter_value_init (SysprofDocumentCounterValue *self)
|
|||||||
|
|
||||||
SysprofDocumentCounterValue *
|
SysprofDocumentCounterValue *
|
||||||
_sysprof_document_counter_value_new (guint type,
|
_sysprof_document_counter_value_new (guint type,
|
||||||
const SysprofDocumentTimedValue *value)
|
const SysprofDocumentTimedValue *value,
|
||||||
|
SysprofDocumentCounter *counter)
|
||||||
{
|
{
|
||||||
SysprofDocumentCounterValue *self;
|
SysprofDocumentCounterValue *self;
|
||||||
|
|
||||||
self = g_object_new (SYSPROF_TYPE_DOCUMENT_COUNTER_VALUE, NULL);
|
self = g_object_new (SYSPROF_TYPE_DOCUMENT_COUNTER_VALUE, NULL);
|
||||||
self->type = type;
|
self->type = type;
|
||||||
self->value = *value;
|
self->value = *value;
|
||||||
|
self->counter = g_object_ref (counter);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -119,6 +143,14 @@ sysprof_document_counter_value_get_time (SysprofDocumentCounterValue *self)
|
|||||||
return self->value.time;
|
return self->value.time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gint64
|
||||||
|
sysprof_document_counter_value_get_time_offset (SysprofDocumentCounterValue *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_COUNTER_VALUE (self), 0);
|
||||||
|
|
||||||
|
return self->value.time - self->counter->begin_time;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sysprof_document_counter_value_get_value (SysprofDocumentCounterValue *self,
|
sysprof_document_counter_value_get_value (SysprofDocumentCounterValue *self,
|
||||||
GValue *value)
|
GValue *value)
|
||||||
@ -162,3 +194,17 @@ sysprof_document_counter_value_format (SysprofDocumentCounterValue *self)
|
|||||||
else
|
else
|
||||||
return g_strdup_printf ("%ld", self->value.v_int64);
|
return g_strdup_printf ("%ld", self->value.v_int64);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sysprof_document_counter_value_get_counter:
|
||||||
|
* @self: a #SysprofDocumentCounterValue
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): a #SysprofDocumentCounter
|
||||||
|
*/
|
||||||
|
SysprofDocumentCounter *
|
||||||
|
sysprof_document_counter_value_get_counter (SysprofDocumentCounterValue *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_COUNTER_VALUE (self), NULL);
|
||||||
|
|
||||||
|
return self->counter;
|
||||||
|
}
|
||||||
|
|||||||
@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
#include <sysprof-capture.h>
|
#include <sysprof-capture.h>
|
||||||
|
|
||||||
|
#include "sysprof-document-counter.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define SYSPROF_TYPE_DOCUMENT_COUNTER_VALUE (sysprof_document_counter_value_get_type())
|
#define SYSPROF_TYPE_DOCUMENT_COUNTER_VALUE (sysprof_document_counter_value_get_type())
|
||||||
@ -32,16 +34,20 @@ SYSPROF_AVAILABLE_IN_ALL
|
|||||||
G_DECLARE_FINAL_TYPE (SysprofDocumentCounterValue, sysprof_document_counter_value, SYSPROF, DOCUMENT_COUNTER_VALUE, GObject)
|
G_DECLARE_FINAL_TYPE (SysprofDocumentCounterValue, sysprof_document_counter_value, SYSPROF, DOCUMENT_COUNTER_VALUE, GObject)
|
||||||
|
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
gint64 sysprof_document_counter_value_get_time (SysprofDocumentCounterValue *self);
|
SysprofDocumentCounter *sysprof_document_counter_value_get_counter (SysprofDocumentCounterValue *self);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
void sysprof_document_counter_value_get_value (SysprofDocumentCounterValue *self,
|
gint64 sysprof_document_counter_value_get_time (SysprofDocumentCounterValue *self);
|
||||||
GValue *value);
|
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
gint64 sysprof_document_counter_value_get_value_int64 (SysprofDocumentCounterValue *self);
|
gint64 sysprof_document_counter_value_get_time_offset (SysprofDocumentCounterValue *self);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
double sysprof_document_counter_value_get_value_double (SysprofDocumentCounterValue *self);
|
void sysprof_document_counter_value_get_value (SysprofDocumentCounterValue *self,
|
||||||
|
GValue *value);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
char *sysprof_document_counter_value_format (SysprofDocumentCounterValue *self);
|
gint64 sysprof_document_counter_value_get_value_int64 (SysprofDocumentCounterValue *self);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
double sysprof_document_counter_value_get_value_double (SysprofDocumentCounterValue *self);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
char *sysprof_document_counter_value_format (SysprofDocumentCounterValue *self);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|||||||
@ -22,23 +22,10 @@
|
|||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "sysprof-document-counter.h"
|
#include "sysprof-document-counter-private.h"
|
||||||
#include "sysprof-document-counter-value-private.h"
|
#include "sysprof-document-counter-value-private.h"
|
||||||
#include "sysprof-document-private.h"
|
#include "sysprof-document-private.h"
|
||||||
|
|
||||||
struct _SysprofDocumentCounter
|
|
||||||
{
|
|
||||||
GObject parent_instance;
|
|
||||||
GRefString *category;
|
|
||||||
GRefString *description;
|
|
||||||
GRefString *name;
|
|
||||||
GArray *values;
|
|
||||||
double min_value;
|
|
||||||
double max_value;
|
|
||||||
guint id;
|
|
||||||
guint type;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_CATEGORY,
|
PROP_CATEGORY,
|
||||||
@ -75,7 +62,7 @@ sysprof_document_counter_get_item (GListModel *model,
|
|||||||
|
|
||||||
value = &g_array_index (self->values, SysprofDocumentTimedValue, position);
|
value = &g_array_index (self->values, SysprofDocumentTimedValue, position);
|
||||||
|
|
||||||
return _sysprof_document_counter_value_new (self->type, value);
|
return _sysprof_document_counter_value_new (self->type, value, self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -204,7 +191,8 @@ _sysprof_document_counter_new (guint id,
|
|||||||
GRefString *category,
|
GRefString *category,
|
||||||
GRefString *name,
|
GRefString *name,
|
||||||
GRefString *description,
|
GRefString *description,
|
||||||
GArray *values)
|
GArray *values,
|
||||||
|
gint64 begin_time)
|
||||||
{
|
{
|
||||||
SysprofDocumentCounter *self;
|
SysprofDocumentCounter *self;
|
||||||
|
|
||||||
@ -215,6 +203,7 @@ _sysprof_document_counter_new (guint id,
|
|||||||
self->name = name;
|
self->name = name;
|
||||||
self->description = description;
|
self->description = description;
|
||||||
self->values = values;
|
self->values = values;
|
||||||
|
self->begin_time = begin_time;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -802,7 +802,8 @@ sysprof_document_load_counters (SysprofDocument *self)
|
|||||||
sysprof_strings_get (self->strings, category),
|
sysprof_strings_get (self->strings, category),
|
||||||
sysprof_strings_get (self->strings, name),
|
sysprof_strings_get (self->strings, name),
|
||||||
sysprof_strings_get (self->strings, description),
|
sysprof_strings_get (self->strings, description),
|
||||||
g_steal_pointer (&values)));
|
g_steal_pointer (&values),
|
||||||
|
self->time_span.begin_nsec));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (egg_bitset_iter_next (&iter, &i));
|
while (egg_bitset_iter_next (&iter, &i));
|
||||||
|
|||||||
Reference in New Issue
Block a user