Integrate adding files with the file manager
[anjuta-git-plugin.git] / plugins / profiler / gprof-flat-profile-entry.c
blob75240141151fd9e1b099cdda20b853a280bf78bc
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * gprof-flat-profile-entry.c
4 * Copyright (C) James Liggett 2006 <jrliggett@cox.net>
5 *
6 * gprof-flat-profile-entry.c is free software.
7 *
8 * You may redistribute it and/or modify it under the terms of the
9 * GNU General Public License, as published by the Free Software
10 * Foundation; either version 2, or (at your option) any later version.
12 * plugin.c is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 * See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with plugin.c. See the file "COPYING". If not,
19 * write to: The Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
24 #include "gprof-flat-profile-entry.h"
26 struct _GProfFlatProfileEntryPriv
28 gfloat time_perc; /* Percent of total execution */
29 gfloat cum_sec; /* Cumulative seconds spent on function and children */
30 gfloat self_sec; /* Time spent on this function only */
31 guint calls; /* Number of times called */
32 gfloat avg_ms; /* Average number of milliseconds spent by this call */
33 gfloat total_ms; /* Spent by function and children */
34 gchar *name; /* Function name */
37 static void
38 gprof_flat_profile_entry_init (GProfFlatProfileEntry *self)
40 self->priv = g_new0 (GProfFlatProfileEntryPriv, 1);
43 static void
44 gprof_flat_profile_entry_finalize (GObject *obj)
46 GProfFlatProfileEntry *self;
48 self = (GProfFlatProfileEntry *) obj;
50 g_free (self->priv->name);
51 g_free (self->priv);
54 static void
55 gprof_flat_profile_entry_class_init (GProfFlatProfileEntryClass *klass)
57 GObjectClass *object_class;
59 object_class = (GObjectClass *) klass;
61 object_class->finalize = gprof_flat_profile_entry_finalize;
64 GType
65 gprof_flat_profile_entry_get_type (void)
67 static GType obj_type = 0;
69 if (!obj_type)
71 static const GTypeInfo obj_info =
73 sizeof (GProfFlatProfileEntryClass),
74 (GBaseInitFunc) NULL,
75 (GBaseFinalizeFunc) NULL,
76 (GClassInitFunc) gprof_flat_profile_entry_class_init,
77 (GClassFinalizeFunc) NULL,
78 NULL, /* class_data */
79 sizeof (GProfFlatProfileEntry),
80 0, /* n_preallocs */
81 (GInstanceInitFunc) gprof_flat_profile_entry_init,
82 NULL /* value_table */
84 obj_type = g_type_register_static (G_TYPE_OBJECT,
85 "GProfFlatProfileEntry", &obj_info,
86 0);
88 return obj_type;
91 GProfFlatProfileEntry *
92 gprof_flat_profile_entry_new (gchar **fields)
94 GProfFlatProfileEntry *entry;
96 entry = g_object_new (GPROF_FLAT_PROFILE_ENTRY_TYPE, NULL);
98 entry->priv->time_perc = g_ascii_strtod (fields[0], NULL);
99 entry->priv->cum_sec = g_ascii_strtod (fields[1], NULL);
100 entry->priv->self_sec = g_ascii_strtod (fields[2], NULL);
101 entry->priv->calls = (unsigned) atoi (fields[3]);
102 entry->priv->avg_ms = g_ascii_strtod (fields[4], NULL);
103 entry->priv->total_ms = g_ascii_strtod (fields[5], NULL);
104 entry->priv->name = g_strdup (fields[6]);
106 return entry;
109 void
110 gprof_flat_profile_entry_free (GProfFlatProfileEntry *self)
112 g_object_unref (self);
115 gfloat
116 gprof_flat_profile_entry_get_time_perc (GProfFlatProfileEntry *self)
118 return self->priv->time_perc;
121 gfloat
122 gprof_flat_profile_entry_get_cum_sec (GProfFlatProfileEntry *self)
124 return self->priv->cum_sec;
127 gfloat
128 gprof_flat_profile_entry_get_self_sec (GProfFlatProfileEntry *self)
130 return self->priv->self_sec;
133 guint
134 gprof_flat_profile_entry_get_calls (GProfFlatProfileEntry *self)
136 return self->priv->calls;
139 gfloat
140 gprof_flat_profile_entry_get_avg_ms (GProfFlatProfileEntry *self)
142 return self->priv->avg_ms;
145 gfloat
146 gprof_flat_profile_entry_get_total_ms (GProfFlatProfileEntry *self)
148 return self->priv->total_ms;
151 gchar *
152 gprof_flat_profile_entry_get_name (GProfFlatProfileEntry *self)
154 return self->priv->name;
157 GProfFlatProfileEntry *
158 gprof_flat_profile_entry_get_next (GList *current_iter, GList **next_iter)
160 *next_iter = g_list_next (current_iter);
162 if (*next_iter)
163 return GPROF_FLAT_PROFILE_ENTRY ((*next_iter)->data);
164 else
165 return NULL;