Recent functions

Recent functions — Remember the most and/or most recently used functions

Functions

Includes

#include <libgwyapp/gwyapp.h>

Description

Every time a function is used, record it with gwy_recent_funcs_record_use(). You can then use gwy_recent_funcs_get_head() to obtain a list of the most and/or most recently used functions. The usage weight slowly fades away over time. Frequently used functions will always come on top. For less used functions, recency has a larger influence.

Functions

gwy_recent_funcs_record_use()

void
gwy_recent_funcs_record_use (const gchar *kind,
                             const gchar *name);

Records one use of a function.

For meaningful statistics, programmatic execution should not be recorded, only user-invoked functions.

Parameters

kind

Function kind.

 

name

Name of function.

 

gwy_recent_funcs_get_head()

guint
gwy_recent_funcs_get_head (const gchar *kind,
                           const gchar **names,
                           guint n);

Obtains a sorted list of most and/or most recently used functions.

The functions are sorted by usage, in descending order. The output array may not be fully filled with function names if there are not enough functions in the usage history. Check the return value. The empty elements are set to NULL.

Normally, only a handful of most recent functions is needed, and the usage recording is designed for that. If you request a long list, recoding future usage can become somewhat inefficient.

Parameters

kind

Function kind.

 

names

Array of size at least n where to put the names of most used functions.

[out][array]

n

The size of names .

 

Returns

The number of items actually filled in names .


gwy_recent_funcs_load()

gboolean
gwy_recent_funcs_load (const gchar *filename,
                       GError **error);

Loads information about recent function usage from a file.

Any existing information is completely replaced. However, this function should normally be only called once during program initialisation.

Parameters

filename

File name to load recently used functions from.

 

error

Optional location to store any error occurred.

 

Returns

TRUE if the operation succeeded.


gwy_recent_funcs_save()

gboolean
gwy_recent_funcs_save (const gchar *filename,
                       GError **error);

Saves information about recent function usage to a file.

Parameters

filename

File name to save recently used functions to.

 

error

Optional location to store any error occurred.

 

Returns

TRUE if the operation succeeded.