libsysprof-analyze: remove old series implementations

This commit is contained in:
Christian Hergert
2023-06-23 21:54:31 -07:00
parent 4282ff2b15
commit 5c2f4dc0a9
6 changed files with 0 additions and 571 deletions

View File

@ -32,9 +32,7 @@ libsysprof_analyze_public_sources = [
'sysprof-no-symbolizer.c',
'sysprof-symbol.c',
'sysprof-symbolizer.c',
'sysprof-time-series.c',
'sysprof-time-span.c',
'sysprof-xy-series.c',
]
libsysprof_analyze_public_headers = [
@ -73,9 +71,7 @@ libsysprof_analyze_public_headers = [
'sysprof-no-symbolizer.h',
'sysprof-symbol.h',
'sysprof-symbolizer.h',
'sysprof-time-series.h',
'sysprof-time-span.h',
'sysprof-xy-series.h',
]
libsysprof_analyze_private_sources = [

View File

@ -59,9 +59,7 @@ G_BEGIN_DECLS
# include "sysprof-no-symbolizer.h"
# include "sysprof-symbol.h"
# include "sysprof-symbolizer.h"
# include "sysprof-time-series.h"
# include "sysprof-time-span.h"
# include "sysprof-xy-series.h"
#undef SYSPROF_ANALYZE_INSIDE
G_END_DECLS

View File

@ -1,187 +0,0 @@
/* sysprof-time-series.c
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "config.h"
#include "sysprof-time-series.h"
struct _SysprofTimeSeries
{
/* Model of SysprofDocumentFrame */
GListModel *model;
/* Array of SysprofTimeSeriesValue */
GArray *values;
/* The timespan contained in this series */
SysprofTimeSpan time_span;
/* The duration of the series */
gint64 duration;
/* Used for warning on items-changed */
gulong items_changed_handler;
};
G_DEFINE_BOXED_TYPE (SysprofTimeSeries,
sysprof_time_series,
sysprof_time_series_ref,
sysprof_time_series_unref)
static void
warn_on_items_changed_cb (GListModel *model,
guint position,
guint removed,
guint added,
gpointer user_data)
{
g_critical ("%s @ %p emitted items changed while a timeseries is active! Expect errors.",
G_OBJECT_TYPE_NAME (model), model);
}
/**
* sysprof_time_series_new:
* @model: a #GListModel
* @time_span: the span of the time series
*
* Used for creating normalized time spans (between 0..1) for times
* within a timespan. Useful for creating time-based charts at any
* size or scale.
*
* It is required that @model does not change during the lifetime
* of the time series.
*/
SysprofTimeSeries *
sysprof_time_series_new (GListModel *model,
SysprofTimeSpan time_span)
{
SysprofTimeSeries *self;
g_return_val_if_fail (G_IS_LIST_MODEL (model), NULL);
self = g_atomic_rc_box_new0 (SysprofTimeSeries);
self->model = g_object_ref (model);
self->values = g_array_new (FALSE, FALSE, sizeof (SysprofTimeSeriesValue));
self->time_span = sysprof_time_span_order (time_span);
self->duration = MAX (1, self->time_span.end_nsec - self->time_span.begin_nsec);
self->items_changed_handler =
g_signal_connect (self->model,
"items-changed",
G_CALLBACK (warn_on_items_changed_cb),
NULL);
return self;
}
SysprofTimeSeries *
sysprof_time_series_ref (SysprofTimeSeries *self)
{
return g_atomic_rc_box_acquire (self);
}
static void
_sysprof_time_series_finalize (SysprofTimeSeries *self)
{
g_clear_signal_handler (&self->items_changed_handler, self->model);
g_clear_object (&self->model);
g_clear_pointer (&self->values, g_array_unref);
}
void
sysprof_time_series_unref (SysprofTimeSeries *self)
{
g_atomic_rc_box_release_full (self,
(GDestroyNotify)_sysprof_time_series_finalize);
}
void
sysprof_time_series_add (SysprofTimeSeries *self,
SysprofTimeSpan time_span,
guint index)
{
SysprofTimeSeriesValue value;
time_span = sysprof_time_span_order (time_span);
if (!sysprof_time_span_clamp (&time_span, self->time_span))
return;
value.index = index;
sysprof_time_span_normalize (time_span, self->time_span, value.time);
g_array_append_val (self->values, value);
}
/**
* sysprof_time_series_get_model:
* @self: a #SysprofTimeSeries
*
* Gets the underlying model for the time series.
*
* Returns: (transfer none): a #GListModel
*/
GListModel *
sysprof_time_series_get_model (SysprofTimeSeries *self)
{
g_return_val_if_fail (self != NULL, NULL);
return self->model;
}
const SysprofTimeSeriesValue *
sysprof_time_series_get_values (const SysprofTimeSeries *self,
guint *n_values)
{
*n_values = self->values->len;
if (self->values->len > 0)
return &g_array_index (self->values, SysprofTimeSeriesValue, 0);
return NULL;
}
static int
compare_by_time (gconstpointer a,
gconstpointer b)
{
const SysprofTimeSeriesValue *aval = a;
const SysprofTimeSeriesValue *bval = b;
if (aval->begin < bval->begin)
return -1;
else if (aval->begin > bval->begin)
return 1;
if (aval->end < bval->end)
return -1;
else if (aval->end > bval->end)
return 1;
return 0;
}
void
sysprof_time_series_sort (SysprofTimeSeries *self)
{
qsort (self->values->data,
self->values->len,
sizeof (SysprofTimeSeriesValue),
compare_by_time);
}

View File

@ -1,74 +0,0 @@
/* sysprof-time-series.h
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include <sysprof-capture.h>
#include <gio/gio.h>
#include "sysprof-time-span.h"
G_BEGIN_DECLS
#define SYSPROF_TYPE_TIME_SERIES (sysprof_time_series_get_type())
typedef struct _SysprofTimeSeries SysprofTimeSeries;
typedef struct _SysprofTimeSeriesValue SysprofTimeSeriesValue;
struct _SysprofTimeSeriesValue
{
/* Normalized begin/end value between 0..1 */
union {
float time[2];
struct {
float begin;
float end;
};
};
/* Index of SysprofDocumentFrame */
guint index;
};
SYSPROF_AVAILABLE_IN_ALL
GType sysprof_time_series_get_type (void) G_GNUC_CONST;
SYSPROF_AVAILABLE_IN_ALL
SysprofTimeSeries *sysprof_time_series_new (GListModel *model,
SysprofTimeSpan time_span);
SYSPROF_AVAILABLE_IN_ALL
SysprofTimeSeries *sysprof_time_series_ref (SysprofTimeSeries *self);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_time_series_unref (SysprofTimeSeries *self);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_time_series_add (SysprofTimeSeries *self,
SysprofTimeSpan time_span,
guint index);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_time_series_sort (SysprofTimeSeries *self);
SYSPROF_AVAILABLE_IN_ALL
GListModel *sysprof_time_series_get_model (SysprofTimeSeries *self);
SYSPROF_AVAILABLE_IN_ALL
const SysprofTimeSeriesValue *sysprof_time_series_get_values (const SysprofTimeSeries *self,
guint *n_values);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofTimeSeries, sysprof_time_series_unref)
G_END_DECLS

View File

@ -1,230 +0,0 @@
/* sysprof-xy-series.c
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "config.h"
#include <math.h>
#include "sysprof-xy-series.h"
struct _SysprofXYSeries
{
/* Model of SysprofDocumentFrame */
GListModel *model;
/* Array of SysprofXYSeriesValue */
GArray *values;
/* Our bounds for non-normalized values */
double min_x;
double min_y;
double max_x;
double max_y;
/* Pre-calculated distance between min/max */
double x_distance;
double y_distance;
/* Used for warning on items-changed */
gulong items_changed_handler;
};
G_DEFINE_BOXED_TYPE (SysprofXYSeries,
sysprof_xy_series,
sysprof_xy_series_ref,
sysprof_xy_series_unref)
static void
warn_on_items_changed_cb (GListModel *model,
guint position,
guint removed,
guint added,
gpointer user_data)
{
g_critical ("%s @ %p emitted items changed while an XYSeries is active! Expect errors.",
G_OBJECT_TYPE_NAME (model), model);
}
/**
* sysprof_xy_series_new:
* @model: a #GListModel
* @xy_span: the span of the xy series
*
* Used for creating normalized xy spans (between 0..1) for xys
* within a xyspan. Useful for creating xy-based charts at any
* size or scale.
*
* It is required that @model does not change during the lifexy
* of the xy series.
*/
SysprofXYSeries *
sysprof_xy_series_new (GListModel *model,
double min_x,
double min_y,
double max_x,
double max_y)
{
SysprofXYSeries *self;
g_return_val_if_fail (!model || G_IS_LIST_MODEL (model), NULL);
self = g_atomic_rc_box_new0 (SysprofXYSeries);
self->model = model ? g_object_ref (model) : NULL;
self->values = g_array_new (FALSE, FALSE, sizeof (SysprofXYSeriesValue));
self->min_x = min_x;
self->min_y = min_y;
self->max_x = max_x;
self->max_y = max_y;
self->x_distance = max_x - min_x;
self->y_distance = max_y - min_y;
if (model != NULL)
self->items_changed_handler =
g_signal_connect (self->model,
"items-changed",
G_CALLBACK (warn_on_items_changed_cb),
NULL);
return self;
}
SysprofXYSeries *
sysprof_xy_series_ref (SysprofXYSeries *self)
{
return g_atomic_rc_box_acquire (self);
}
static void
_sysprof_xy_series_finalize (SysprofXYSeries *self)
{
g_clear_signal_handler (&self->items_changed_handler, self->model);
g_clear_object (&self->model);
g_clear_pointer (&self->values, g_array_unref);
}
void
sysprof_xy_series_unref (SysprofXYSeries *self)
{
g_atomic_rc_box_release_full (self,
(GDestroyNotify)_sysprof_xy_series_finalize);
}
void
sysprof_xy_series_add (SysprofXYSeries *self,
double x,
double y,
guint index)
{
SysprofXYSeriesValue value;
if (x < self->min_x || x > self->max_x)
return;
if (y < self->min_y || y > self->max_y)
return;
value.index = index;
value.x = (x - self->min_x) / self->x_distance;
value.y = (y - self->min_y) / self->y_distance;
if (isinf (value.x) || isinf (value.y))
return;
g_array_append_val (self->values, value);
}
/**
* sysprof_xy_series_get_model:
* @self: a #SysprofXYSeries
*
* Gets the underlying model for the xy series.
*
* Returns: (transfer none) (nullable): a #GListModel
*/
GListModel *
sysprof_xy_series_get_model (SysprofXYSeries *self)
{
g_return_val_if_fail (self != NULL, NULL);
return self->model;
}
const SysprofXYSeriesValue *
sysprof_xy_series_get_values (const SysprofXYSeries *self,
guint *n_values)
{
*n_values = self->values->len;
if (self->values->len > 0)
return &g_array_index (self->values, SysprofXYSeriesValue, 0);
return NULL;
}
static int
compare_by_xy (gconstpointer aptr,
gconstpointer bptr)
{
const SysprofXYSeriesValue *a = aptr;
const SysprofXYSeriesValue *b = bptr;
if (a->x < b->x)
return -1;
else if (a->x > b->x)
return 1;
if (a->y < b->y)
return -1;
else if (a->y > b->y)
return 1;
return 0;
}
void
sysprof_xy_series_sort (SysprofXYSeries *self)
{
qsort (self->values->data,
self->values->len,
sizeof (SysprofXYSeriesValue),
compare_by_xy);
}
void
sysprof_xy_series_get_range (SysprofXYSeries *self,
double *min_x,
double *min_y,
double *max_x,
double *max_y)
{
g_return_if_fail (self != NULL);
if (min_x)
*min_x = self->min_x;
if (max_x)
*max_x = self->max_x;
if (min_y)
*min_y = self->min_y;
if (max_y)
*max_y = self->max_y;
}

View File

@ -1,74 +0,0 @@
/* sysprof-xy-series.h
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include <sysprof-capture.h>
#include <gio/gio.h>
G_BEGIN_DECLS
#define SYSPROF_TYPE_XY_SERIES (sysprof_xy_series_get_type())
typedef struct _SysprofXYSeries SysprofXYSeries;
typedef struct _SysprofXYSeriesValue SysprofXYSeriesValue;
struct _SysprofXYSeriesValue
{
float x;
float y;
guint index;
};
SYSPROF_AVAILABLE_IN_ALL
GType sysprof_xy_series_get_type (void) G_GNUC_CONST;
SYSPROF_AVAILABLE_IN_ALL
SysprofXYSeries *sysprof_xy_series_new (GListModel *model,
double min_x,
double min_y,
double max_x,
double max_y);
SYSPROF_AVAILABLE_IN_ALL
SysprofXYSeries *sysprof_xy_series_ref (SysprofXYSeries *self);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_xy_series_unref (SysprofXYSeries *self);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_xy_series_add (SysprofXYSeries *self,
double x,
double y,
guint index);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_xy_series_sort (SysprofXYSeries *self);
SYSPROF_AVAILABLE_IN_ALL
GListModel *sysprof_xy_series_get_model (SysprofXYSeries *self);
SYSPROF_AVAILABLE_IN_ALL
const SysprofXYSeriesValue *sysprof_xy_series_get_values (const SysprofXYSeries *self,
guint *n_values);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_xy_series_get_range (SysprofXYSeries *self,
double *min_x,
double *min_y,
double *max_x,
double *max_y);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofXYSeries, sysprof_xy_series_unref)
G_END_DECLS