annotate src/gtkidle.h @ 12233:02833a0ae716

[gaim-migrate @ 14535] SF Patch #1367116 from Michael Carlson "In profiling gaim, I noticed that on simply starting CVS gaim, xmlnode_insert_child is using up by far the most CPU time. After some testing, I realized the reason why: xmlnode_insert_child is called some 18,000 times on startup, and it is inserting the child at the end of the list each time, simply by traversing through the entire linked list. Sometimes this list can have as many as 800 elements. This patch adds a variable to the _xmlnode struct, lastchild, which simply keeps track of the last node in the list of children. This is then used by xmlnode_insert_child to insert at the end of the list, instead of traversing through the whole list each time. The two relevant functions in xmlnode.c that need to be updated to keep track of this function appropriately have been updated. Running 3 times with and without the change, the results from oprofile say it all. Here are the measured number of clock cycles / % of total clock cycles / function used to simply start and close gaim before the change: 204 60.7143 xmlnode_insert_child 210 61.4035 xmlnode_insert_child 230 61.8280 xmlnode_insert_child And after (note that one time no clock cycles were caught at all) 3 2.5862 xmlnode_insert_child 3 2.5641 xmlnode_insert_child This affects other areas of the program than just starting up, but this seems to be the most noticeable place." Speed is good. As I was verifying this patch, I added some g_return_val_if_fail() checks. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Sun, 27 Nov 2005 03:42:39 +0000
parents 90d7e0f342fa
children a72eb0342977
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1 /**
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
2 * @file gtkidle.h GTK+ Idle API
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
3 * @ingroup gtkui
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
4 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
5 * gaim
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
6 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
9 * source distribution.
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
10 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
14 * (at your option) any later version.
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
15 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
19 * GNU General Public License for more details.
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
20 *
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
24 */
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
25 #ifndef _GAIM_GTK_IDLE_H_
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
26 #define _GAIM_GTK_IDLE_H_
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
27
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
28 /**************************************************************************/
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
29 /** @name GTK+ Idle API */
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
30 /**************************************************************************/
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
31 /*@{*/
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
32
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
33
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
34 /**
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
35 * Initializes the GTK+ idle system.
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
36 */
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
37 void gaim_gtk_idle_init(void);
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
38
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
39 /**
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
40 * Uninitializes the GTK+ idle system.
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
41 */
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
42 void gaim_gtk_idle_uninit(void);
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
43
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
44 /**
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
45 * Check the current idle time, reporting to the server or going auto-away as
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
46 * appropriate.
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
47 *
12050
90d7e0f342fa [gaim-migrate @ 14345]
Mark Doliner <mark@kingant.net>
parents: 11907
diff changeset
48 * @param data A pointer to the GaimConnection* to check
11907
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
49 */
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
50 gint gaim_gtk_idle_check(gpointer data);
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
51
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
52 /*@}*/
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
53
d2db6426c88a [gaim-migrate @ 14198]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
54 #endif /* _GAIM_GTK_IDLE_H_ */