mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-13 03:05:12 +01:00
gobject/performance: rework setting the base factor for number of rounds
Move the factor inside the PerformanceTest structure, so it can be programatically accessed. More importantly, the number is now expressed directly beside the test setup (the PerformanceTest structure), all at one place. Also, each test now gets a separate factor. This change will be useful in the next commit. So far there is no notable change in behavior.
This commit is contained in:
parent
6a231008e4
commit
0e1597ffb9
@ -52,8 +52,11 @@ static GOptionEntry cmd_entries[] = {
|
||||
typedef struct _PerformanceTest PerformanceTest;
|
||||
struct _PerformanceTest {
|
||||
const char *name;
|
||||
|
||||
gpointer extra_data;
|
||||
|
||||
guint base_factor;
|
||||
|
||||
gpointer (*setup) (PerformanceTest *test);
|
||||
void (*init) (PerformanceTest *test,
|
||||
gpointer data,
|
||||
@ -501,8 +504,6 @@ complex_object_init (ComplexObject *complex_object)
|
||||
* Test object construction performance
|
||||
*************************************************************/
|
||||
|
||||
#define NUM_OBJECT_TO_CONSTRUCT 10000
|
||||
|
||||
struct ConstructionTest {
|
||||
GObject **objects;
|
||||
unsigned int n_objects;
|
||||
@ -528,7 +529,7 @@ test_construction_init (PerformanceTest *test,
|
||||
struct ConstructionTest *data = _data;
|
||||
unsigned int n;
|
||||
|
||||
n = (unsigned int) (NUM_OBJECT_TO_CONSTRUCT * count_factor);
|
||||
n = (unsigned int) (test->base_factor * count_factor);
|
||||
if (data->n_objects != n)
|
||||
{
|
||||
data->n_objects = n;
|
||||
@ -650,7 +651,7 @@ test_finalization_init (PerformanceTest *test,
|
||||
struct ConstructionTest *data = _data;
|
||||
unsigned int n;
|
||||
|
||||
n = (unsigned int) (NUM_OBJECT_TO_CONSTRUCT * count_factor);
|
||||
n = (unsigned int) (test->base_factor * count_factor);
|
||||
if (data->n_objects != n)
|
||||
{
|
||||
data->n_objects = n;
|
||||
@ -710,8 +711,6 @@ test_finalization_print_result (PerformanceTest *test,
|
||||
* Test runtime type check performance
|
||||
*************************************************************/
|
||||
|
||||
#define NUM_KILO_CHECKS_PER_ROUND 50
|
||||
|
||||
/* Work around g_type_check_instance_is_a being marked "pure",
|
||||
* and thus only called once for the loop. */
|
||||
static gboolean (*my_type_check_instance_is_a) (GTypeInstance *type_instance,
|
||||
@ -742,7 +741,7 @@ test_type_check_init (PerformanceTest *test,
|
||||
{
|
||||
struct TypeCheckTest *data = _data;
|
||||
|
||||
data->n_checks = (unsigned int) (factor * NUM_KILO_CHECKS_PER_ROUND);
|
||||
data->n_checks = (unsigned int) (test->base_factor * factor);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -800,8 +799,6 @@ test_type_check_teardown (PerformanceTest *test,
|
||||
* Test signal emissions performance (common code)
|
||||
*************************************************************/
|
||||
|
||||
#define NUM_EMISSIONS_PER_ROUND 10000
|
||||
|
||||
struct EmissionTest {
|
||||
GObject *object;
|
||||
unsigned int n_checks;
|
||||
@ -852,7 +849,7 @@ test_emission_unhandled_init (PerformanceTest *test,
|
||||
{
|
||||
struct EmissionTest *data = _data;
|
||||
|
||||
data->n_checks = (unsigned int) (factor * NUM_EMISSIONS_PER_ROUND);
|
||||
data->n_checks = (unsigned int) (test->base_factor * factor);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -925,7 +922,7 @@ test_emission_handled_init (PerformanceTest *test,
|
||||
{
|
||||
struct EmissionTest *data = _data;
|
||||
|
||||
data->n_checks = (unsigned int) (factor * NUM_EMISSIONS_PER_ROUND);
|
||||
data->n_checks = (unsigned int) (test->base_factor * factor);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -959,8 +956,6 @@ test_emission_handled_teardown (PerformanceTest *test,
|
||||
* Test object notify performance (common code)
|
||||
*************************************************************/
|
||||
|
||||
#define NUM_NOTIFY_PER_ROUND 10000
|
||||
|
||||
struct NotifyTest {
|
||||
GObject *object;
|
||||
unsigned int n_checks;
|
||||
@ -1009,7 +1004,7 @@ test_notify_unhandled_init (PerformanceTest *test,
|
||||
{
|
||||
struct NotifyTest *data = _data;
|
||||
|
||||
data->n_checks = (unsigned int) (factor * NUM_NOTIFY_PER_ROUND);
|
||||
data->n_checks = (unsigned int) (test->base_factor * factor);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1071,7 +1066,7 @@ test_notify_handled_init (PerformanceTest *test,
|
||||
{
|
||||
struct NotifyTest *data = _data;
|
||||
|
||||
data->n_checks = (unsigned int) (factor * NUM_NOTIFY_PER_ROUND);
|
||||
data->n_checks = (unsigned int) (test->base_factor * factor);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1109,8 +1104,6 @@ test_notify_handled_teardown (PerformanceTest *test,
|
||||
* Test object set performance
|
||||
*************************************************************/
|
||||
|
||||
#define NUM_SET_PER_ROUND 10000
|
||||
|
||||
struct SetTest {
|
||||
GObject *object;
|
||||
unsigned int n_checks;
|
||||
@ -1151,7 +1144,7 @@ test_set_init (PerformanceTest *test,
|
||||
{
|
||||
struct SetTest *data = _data;
|
||||
|
||||
data->n_checks = (unsigned int) (factor * NUM_SET_PER_ROUND);
|
||||
data->n_checks = (unsigned int) (test->base_factor * factor);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1186,8 +1179,6 @@ test_set_teardown (PerformanceTest *test,
|
||||
* Test object get performance
|
||||
*************************************************************/
|
||||
|
||||
#define NUM_GET_PER_ROUND 10000
|
||||
|
||||
struct GetTest {
|
||||
GObject *object;
|
||||
unsigned int n_checks;
|
||||
@ -1229,7 +1220,7 @@ test_get_init (PerformanceTest *test,
|
||||
{
|
||||
struct GetTest *data = _data;
|
||||
|
||||
data->n_checks = (unsigned int) (factor * NUM_GET_PER_ROUND);
|
||||
data->n_checks = (unsigned int) (test->base_factor * factor);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1264,8 +1255,6 @@ test_get_teardown (PerformanceTest *test,
|
||||
* Test object refcount performance
|
||||
*************************************************************/
|
||||
|
||||
#define NUM_KILO_REFS_PER_ROUND 100000
|
||||
|
||||
struct RefcountTest {
|
||||
GObject *object;
|
||||
unsigned int n_checks;
|
||||
@ -1304,7 +1293,7 @@ test_refcount_init (PerformanceTest *test,
|
||||
{
|
||||
struct RefcountTest *data = _data;
|
||||
|
||||
data->n_checks = (unsigned int) (factor * NUM_KILO_REFS_PER_ROUND);
|
||||
data->n_checks = (unsigned int) (test->base_factor * factor);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1382,6 +1371,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"simple-construction",
|
||||
simple_object_get_type,
|
||||
10000,
|
||||
test_construction_setup,
|
||||
test_construction_init,
|
||||
test_construction_run,
|
||||
@ -1392,6 +1382,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"simple-construction1",
|
||||
simple_object_get_type,
|
||||
10000,
|
||||
test_construction_setup,
|
||||
test_construction_init,
|
||||
test_construction_run1,
|
||||
@ -1402,6 +1393,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"complex-construction",
|
||||
complex_object_get_type,
|
||||
10000,
|
||||
test_construction_setup,
|
||||
test_construction_init,
|
||||
test_complex_construction_run,
|
||||
@ -1412,6 +1404,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"complex-construction1",
|
||||
complex_object_get_type,
|
||||
10000,
|
||||
test_construction_setup,
|
||||
test_construction_init,
|
||||
test_complex_construction_run1,
|
||||
@ -1422,6 +1415,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"complex-construction2",
|
||||
complex_object_get_type,
|
||||
10000,
|
||||
test_construction_setup,
|
||||
test_construction_init,
|
||||
test_complex_construction_run2,
|
||||
@ -1432,6 +1426,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"finalization",
|
||||
simple_object_get_type,
|
||||
10000,
|
||||
test_construction_setup,
|
||||
test_finalization_init,
|
||||
test_finalization_run,
|
||||
@ -1442,6 +1437,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"type-check",
|
||||
NULL,
|
||||
50,
|
||||
test_type_check_setup,
|
||||
test_type_check_init,
|
||||
test_type_check_run,
|
||||
@ -1452,6 +1448,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"emit-unhandled",
|
||||
GUINT_TO_POINTER (COMPLEX_SIGNAL),
|
||||
10000,
|
||||
test_emission_unhandled_setup,
|
||||
test_emission_unhandled_init,
|
||||
test_emission_run,
|
||||
@ -1462,6 +1459,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"emit-unhandled-empty",
|
||||
GUINT_TO_POINTER (COMPLEX_SIGNAL_EMPTY),
|
||||
10000,
|
||||
test_emission_unhandled_setup,
|
||||
test_emission_unhandled_init,
|
||||
test_emission_run,
|
||||
@ -1472,6 +1470,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"emit-unhandled-generic",
|
||||
GUINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC),
|
||||
10000,
|
||||
test_emission_unhandled_setup,
|
||||
test_emission_unhandled_init,
|
||||
test_emission_run,
|
||||
@ -1482,6 +1481,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"emit-unhandled-generic-empty",
|
||||
GUINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC_EMPTY),
|
||||
10000,
|
||||
test_emission_unhandled_setup,
|
||||
test_emission_unhandled_init,
|
||||
test_emission_run,
|
||||
@ -1492,6 +1492,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"emit-unhandled-args",
|
||||
GUINT_TO_POINTER (COMPLEX_SIGNAL_ARGS),
|
||||
10000,
|
||||
test_emission_unhandled_setup,
|
||||
test_emission_unhandled_init,
|
||||
test_emission_run_args,
|
||||
@ -1502,6 +1503,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"emit-handled",
|
||||
GUINT_TO_POINTER (COMPLEX_SIGNAL),
|
||||
10000,
|
||||
test_emission_handled_setup,
|
||||
test_emission_handled_init,
|
||||
test_emission_run,
|
||||
@ -1512,6 +1514,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"emit-handled-empty",
|
||||
GUINT_TO_POINTER (COMPLEX_SIGNAL_EMPTY),
|
||||
10000,
|
||||
test_emission_handled_setup,
|
||||
test_emission_handled_init,
|
||||
test_emission_run,
|
||||
@ -1522,6 +1525,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"emit-handled-generic",
|
||||
GUINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC),
|
||||
10000,
|
||||
test_emission_handled_setup,
|
||||
test_emission_handled_init,
|
||||
test_emission_run,
|
||||
@ -1532,6 +1536,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"emit-handled-generic-empty",
|
||||
GUINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC_EMPTY),
|
||||
10000,
|
||||
test_emission_handled_setup,
|
||||
test_emission_handled_init,
|
||||
test_emission_run,
|
||||
@ -1542,6 +1547,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"emit-handled-args",
|
||||
GUINT_TO_POINTER (COMPLEX_SIGNAL_ARGS),
|
||||
10000,
|
||||
test_emission_handled_setup,
|
||||
test_emission_handled_init,
|
||||
test_emission_run_args,
|
||||
@ -1552,6 +1558,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"notify-unhandled",
|
||||
complex_object_get_type,
|
||||
10000,
|
||||
test_notify_unhandled_setup,
|
||||
test_notify_unhandled_init,
|
||||
test_notify_run,
|
||||
@ -1562,6 +1569,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"notify-by-pspec-unhandled",
|
||||
complex_object_get_type,
|
||||
10000,
|
||||
test_notify_unhandled_setup,
|
||||
test_notify_unhandled_init,
|
||||
test_notify_by_pspec_run,
|
||||
@ -1572,6 +1580,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"notify-handled",
|
||||
complex_object_get_type,
|
||||
10000,
|
||||
test_notify_handled_setup,
|
||||
test_notify_handled_init,
|
||||
test_notify_run,
|
||||
@ -1582,6 +1591,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"notify-by-pspec-handled",
|
||||
complex_object_get_type,
|
||||
10000,
|
||||
test_notify_handled_setup,
|
||||
test_notify_handled_init,
|
||||
test_notify_by_pspec_run,
|
||||
@ -1592,6 +1602,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"property-set",
|
||||
complex_object_get_type,
|
||||
10000,
|
||||
test_set_setup,
|
||||
test_set_init,
|
||||
test_set_run,
|
||||
@ -1602,6 +1613,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"property-get",
|
||||
complex_object_get_type,
|
||||
10000,
|
||||
test_get_setup,
|
||||
test_get_init,
|
||||
test_get_run,
|
||||
@ -1612,6 +1624,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"refcount",
|
||||
NULL,
|
||||
100000,
|
||||
test_refcount_setup,
|
||||
test_refcount_init,
|
||||
test_refcount_run,
|
||||
@ -1622,6 +1635,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"refcount-1",
|
||||
NULL,
|
||||
100000,
|
||||
test_refcount_setup,
|
||||
test_refcount_init,
|
||||
test_refcount_1_run,
|
||||
@ -1632,6 +1646,7 @@ static PerformanceTest tests[] = {
|
||||
{
|
||||
"refcount-toggle",
|
||||
NULL,
|
||||
100000,
|
||||
test_refcount_setup,
|
||||
test_refcount_init,
|
||||
test_refcount_1_run,
|
||||
|
Loading…
x
Reference in New Issue
Block a user