diff options
Diffstat (limited to 'benchmark/benchmark.c')
-rw-r--r-- | benchmark/benchmark.c | 156 |
1 files changed, 136 insertions, 20 deletions
diff --git a/benchmark/benchmark.c b/benchmark/benchmark.c index ea6c65e..b885f26 100644 --- a/benchmark/benchmark.c +++ b/benchmark/benchmark.c @@ -1,10 +1,11 @@ -/* benchmark.c generated by valac 0.16.1, the Vala compiler +/* benchmark.c generated by valac 0.18.0, the Vala compiler * generated from benchmark.vala, do not modify */ /* benchmark.vala * * Copyright (C) 2008 Jürg Billeter * Copyright (C) 2009 Didier Villevalois + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,13 +27,15 @@ #include <glib.h> #include <glib-object.h> -#include <gee-internals.h> #include <stdlib.h> #include <string.h> +#include <stdio.h> +#include <gee-internals.h> #include <math.h> #include <float.h> -#include <stdio.h> +#define _g_option_context_free0(var) ((var == NULL) ? NULL : (var = (g_option_context_free (var), NULL))) +#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) #define GEE_BENCHMARK_TYPE_FACTORY (gee_benchmark_factory_get_type ()) #define GEE_BENCHMARK_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_BENCHMARK_TYPE_FACTORY, GeeBenchmarkFactory)) @@ -260,6 +263,9 @@ static gpointer gee_benchmark_array_list_factory_parent_class = NULL; static GeeBenchmarkFactoryIface* gee_benchmark_array_list_factory_gee_benchmark_factory_parent_iface = NULL; static gpointer gee_benchmark_benchmark_parent_class = NULL; +void gee_benchmark_run_benchmark_option (const gchar* long_name, gchar short_name, const gchar* description, gboolean* do_run, GOptionEntry* result); +gint gee_benchmark_main (gchar** args, int args_length1); +void gee_benchmark_benchmark_sorts (void); GType gee_benchmark_factory_get_type (void) G_GNUC_CONST; GeeCollection* gee_benchmark_factory_create (GeeBenchmarkFactory* self); GeeCollection* gee_benchmark_factory_copy (GeeBenchmarkFactory* self, GeeCollection* collection); @@ -346,6 +352,116 @@ static void _vala_gee_benchmark_benchmark_get_property (GObject * object, guint static void _vala_gee_benchmark_benchmark_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); +void gee_benchmark_run_benchmark_option (const gchar* long_name, gchar short_name, const gchar* description, gboolean* do_run, GOptionEntry* result) { + const gchar* _tmp0_; + gchar _tmp1_; + const gchar* _tmp2_; + GOptionEntry _tmp3_ = {0}; + g_return_if_fail (long_name != NULL); + g_return_if_fail (description != NULL); + _tmp0_ = long_name; + _tmp1_ = short_name; + _tmp2_ = description; + memset (&_tmp3_, 0, sizeof (GOptionEntry)); + _tmp3_.long_name = _tmp0_; + _tmp3_.short_name = _tmp1_; + _tmp3_.flags = 0; + _tmp3_.arg = G_OPTION_ARG_NONE; + _tmp3_.arg_data = do_run; + _tmp3_.description = _tmp2_; + _tmp3_.arg_description = NULL; + *result = _tmp3_; + return; +} + + +gint gee_benchmark_main (gchar** args, int args_length1) { + gint result = 0; + gboolean run_sort; + GOptionEntry _tmp0_ = {0}; + GOptionEntry* _tmp1_ = NULL; + GOptionEntry* entries; + gint entries_length1; + gint _entries_size_; + GOptionContext* _tmp2_; + GOptionContext* context; + GOptionContext* _tmp3_; + GOptionEntry* _tmp4_; + gint _tmp4__length1; + gboolean _tmp9_; + GError * _inner_error_ = NULL; + run_sort = FALSE; + gee_benchmark_run_benchmark_option ("run-sort", 's', "Run sorting benchmark", &run_sort, &_tmp0_); + _tmp1_ = g_new0 (GOptionEntry, 1); + _tmp1_[0] = _tmp0_; + entries = _tmp1_; + entries_length1 = 1; + _entries_size_ = entries_length1; + _tmp2_ = g_option_context_new ("Run various benchmarks"); + context = _tmp2_; + _tmp3_ = context; + _tmp4_ = entries; + _tmp4__length1 = entries_length1; + g_option_context_add_main_entries (_tmp3_, _tmp4_, "gee-benchmark"); + { + GOptionContext* _tmp5_; + _tmp5_ = context; + g_option_context_parse (_tmp5_, &args_length1, &args, &_inner_error_); + if (_inner_error_ != NULL) { + if (_inner_error_->domain == G_OPTION_ERROR) { + goto __catch0_g_option_error; + } + _g_option_context_free0 (context); + entries = (g_free (entries), NULL); + g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); + return 0; + } + } + goto __finally0; + __catch0_g_option_error: + { + GError* e = NULL; + FILE* _tmp6_; + GError* _tmp7_; + const gchar* _tmp8_; + e = _inner_error_; + _inner_error_ = NULL; + _tmp6_ = stdout; + _tmp7_ = e; + _tmp8_ = _tmp7_->message; + fprintf (_tmp6_, "option parsing failed: %s\n", _tmp8_); + result = 2; + _g_error_free0 (e); + _g_option_context_free0 (context); + entries = (g_free (entries), NULL); + return result; + } + __finally0: + if (_inner_error_ != NULL) { + _g_option_context_free0 (context); + entries = (g_free (entries), NULL); + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); + return 0; + } + _tmp9_ = run_sort; + if (_tmp9_) { + gee_benchmark_benchmark_sorts (); + } + result = 0; + _g_option_context_free0 (context); + entries = (g_free (entries), NULL); + return result; +} + + +int main (int argc, char ** argv) { + g_type_init (); + return gee_benchmark_main (argv, argc); +} + + GeeCollection* gee_benchmark_factory_create (GeeBenchmarkFactory* self) { g_return_val_if_fail (self != NULL, NULL); return GEE_BENCHMARK_FACTORY_GET_INTERFACE (self)->create (self); @@ -479,7 +595,7 @@ static void gee_benchmark_random_int32_real_generate_collection (GeeBenchmarkGen _tmp5_ = collection; _tmp6_ = size; _tmp7_ = g_random_int_range ((gint32) 0, (gint32) (_tmp6_ - 1)); - gee_collection_add (_tmp5_, GINT_TO_POINTER (_tmp7_)); + gee_collection_add (_tmp5_, (gpointer) ((gintptr) _tmp7_)); } } } @@ -541,7 +657,7 @@ GType gee_benchmark_random_int32_get_type (void) { static void _vala_gee_benchmark_random_int32_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { GeeBenchmarkRandomInt32 * self; - self = GEE_BENCHMARK_RANDOM_INT32 (object); + self = G_TYPE_CHECK_INSTANCE_CAST (object, GEE_BENCHMARK_TYPE_RANDOM_INT32, GeeBenchmarkRandomInt32); switch (property_id) { case GEE_BENCHMARK_RANDOM_INT32_NAME: g_value_set_string (value, gee_benchmark_generator_get_name ((GeeBenchmarkGenerator*) self)); @@ -595,7 +711,7 @@ static void gee_benchmark_fixed_variance_int32_real_generate_collection (GeeBenc _tmp9_ = variance; _tmp10_ = g_random_int_range ((gint32) 0, (gint32) _tmp9_); _tmp11_ = variance; - gee_collection_add (_tmp7_, GINT_TO_POINTER ((gint32) ((_tmp8_ + _tmp10_) - (_tmp11_ / 2)))); + gee_collection_add (_tmp7_, (gpointer) ((gintptr) ((gint32) ((_tmp8_ + _tmp10_) - (_tmp11_ / 2))))); } } } @@ -657,7 +773,7 @@ GType gee_benchmark_fixed_variance_int32_get_type (void) { static void _vala_gee_benchmark_fixed_variance_int32_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { GeeBenchmarkFixedVarianceInt32 * self; - self = GEE_BENCHMARK_FIXED_VARIANCE_INT32 (object); + self = G_TYPE_CHECK_INSTANCE_CAST (object, GEE_BENCHMARK_TYPE_FIXED_VARIANCE_INT32, GeeBenchmarkFixedVarianceInt32); switch (property_id) { case GEE_BENCHMARK_FIXED_VARIANCE_INT32_NAME: g_value_set_string (value, gee_benchmark_generator_get_name ((GeeBenchmarkGenerator*) self)); @@ -739,7 +855,7 @@ static void gee_benchmark_mounts_int32_real_generate_collection (GeeBenchmarkGen _tmp15_ = last; _tmp16_ = height; _tmp17_ = width; - gee_collection_add (_tmp14_, GINT_TO_POINTER ((gint32) (_tmp15_ + (_tmp16_ / _tmp17_)))); + gee_collection_add (_tmp14_, (gpointer) ((gintptr) ((gint32) (_tmp15_ + (_tmp16_ / _tmp17_))))); } } } @@ -808,7 +924,7 @@ GType gee_benchmark_mounts_int32_get_type (void) { static void _vala_gee_benchmark_mounts_int32_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { GeeBenchmarkMountsInt32 * self; - self = GEE_BENCHMARK_MOUNTS_INT32 (object); + self = G_TYPE_CHECK_INSTANCE_CAST (object, GEE_BENCHMARK_TYPE_MOUNTS_INT32, GeeBenchmarkMountsInt32); switch (property_id) { case GEE_BENCHMARK_MOUNTS_INT32_NAME: g_value_set_string (value, gee_benchmark_generator_get_name ((GeeBenchmarkGenerator*) self)); @@ -852,7 +968,7 @@ static void gee_benchmark_reverse_sorted_int32_real_generate_collection (GeeBenc _tmp5_ = collection; _tmp6_ = size; _tmp7_ = i; - gee_collection_add (_tmp5_, GINT_TO_POINTER ((gint32) ((_tmp6_ - _tmp7_) - 1))); + gee_collection_add (_tmp5_, (gpointer) ((gintptr) ((gint32) ((_tmp6_ - _tmp7_) - 1)))); } } } @@ -914,7 +1030,7 @@ GType gee_benchmark_reverse_sorted_int32_get_type (void) { static void _vala_gee_benchmark_reverse_sorted_int32_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { GeeBenchmarkReverseSortedInt32 * self; - self = GEE_BENCHMARK_REVERSE_SORTED_INT32 (object); + self = G_TYPE_CHECK_INSTANCE_CAST (object, GEE_BENCHMARK_TYPE_REVERSE_SORTED_INT32, GeeBenchmarkReverseSortedInt32); switch (property_id) { case GEE_BENCHMARK_REVERSE_SORTED_INT32_NAME: g_value_set_string (value, gee_benchmark_generator_get_name ((GeeBenchmarkGenerator*) self)); @@ -956,7 +1072,7 @@ static void gee_benchmark_sorted_int32_real_generate_collection (GeeBenchmarkGen } _tmp5_ = collection; _tmp6_ = i; - gee_collection_add (_tmp5_, GINT_TO_POINTER ((gint32) _tmp6_)); + gee_collection_add (_tmp5_, (gpointer) ((gintptr) ((gint32) _tmp6_))); } } } @@ -1018,7 +1134,7 @@ GType gee_benchmark_sorted_int32_get_type (void) { static void _vala_gee_benchmark_sorted_int32_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { GeeBenchmarkSortedInt32 * self; - self = GEE_BENCHMARK_SORTED_INT32 (object); + self = G_TYPE_CHECK_INSTANCE_CAST (object, GEE_BENCHMARK_TYPE_SORTED_INT32, GeeBenchmarkSortedInt32); switch (property_id) { case GEE_BENCHMARK_SORTED_INT32_NAME: g_value_set_string (value, gee_benchmark_generator_get_name ((GeeBenchmarkGenerator*) self)); @@ -1035,7 +1151,7 @@ static GeeCollection* gee_benchmark_array_list_factory_real_create (GeeBenchmark GeeCollection* result = NULL; GeeArrayList* _tmp0_; self = (GeeBenchmarkArrayListFactory*) base; - _tmp0_ = gee_array_list_new (self->priv->g_type, (GBoxedCopyFunc) self->priv->g_dup_func, self->priv->g_destroy_func, NULL); + _tmp0_ = gee_array_list_new (self->priv->g_type, (GBoxedCopyFunc) self->priv->g_dup_func, self->priv->g_destroy_func, NULL, NULL, NULL); result = (GeeCollection*) _tmp0_; return result; } @@ -1048,7 +1164,7 @@ static GeeCollection* gee_benchmark_array_list_factory_real_copy (GeeBenchmarkFa GeeArrayList* copy; self = (GeeBenchmarkArrayListFactory*) base; g_return_val_if_fail (collection != NULL, NULL); - _tmp0_ = gee_array_list_new (self->priv->g_type, (GBoxedCopyFunc) self->priv->g_dup_func, self->priv->g_destroy_func, NULL); + _tmp0_ = gee_array_list_new (self->priv->g_type, (GBoxedCopyFunc) self->priv->g_dup_func, self->priv->g_destroy_func, NULL, NULL, NULL); copy = _tmp0_; { GeeCollection* _tmp1_; @@ -1139,7 +1255,7 @@ GType gee_benchmark_array_list_factory_get_type (void) { static void _vala_gee_benchmark_array_list_factory_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { GeeBenchmarkArrayListFactory * self; - self = GEE_BENCHMARK_ARRAY_LIST_FACTORY (object); + self = G_TYPE_CHECK_INSTANCE_CAST (object, GEE_BENCHMARK_TYPE_ARRAY_LIST_FACTORY, GeeBenchmarkArrayListFactory); switch (property_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -1150,7 +1266,7 @@ static void _vala_gee_benchmark_array_list_factory_get_property (GObject * objec static void _vala_gee_benchmark_array_list_factory_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { GeeBenchmarkArrayListFactory * self; - self = GEE_BENCHMARK_ARRAY_LIST_FACTORY (object); + self = G_TYPE_CHECK_INSTANCE_CAST (object, GEE_BENCHMARK_TYPE_ARRAY_LIST_FACTORY, GeeBenchmarkArrayListFactory); switch (property_id) { case GEE_BENCHMARK_ARRAY_LIST_FACTORY_G_TYPE: self->priv->g_type = g_value_get_gtype (value); @@ -1906,7 +2022,7 @@ static void gee_benchmark_benchmark_instance_init (GeeBenchmarkBenchmark * self) static void gee_benchmark_benchmark_finalize (GObject* obj) { GeeBenchmarkBenchmark * self; - self = GEE_BENCHMARK_BENCHMARK (obj); + self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEE_BENCHMARK_TYPE_BENCHMARK, GeeBenchmarkBenchmark); _g_object_unref0 (self->priv->factory); self->priv->sizes = (g_free (self->priv->sizes), NULL); _g_object_unref0 (self->priv->generators); @@ -1931,7 +2047,7 @@ GType gee_benchmark_benchmark_get_type (void) { static void _vala_gee_benchmark_benchmark_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { GeeBenchmarkBenchmark * self; - self = GEE_BENCHMARK_BENCHMARK (object); + self = G_TYPE_CHECK_INSTANCE_CAST (object, GEE_BENCHMARK_TYPE_BENCHMARK, GeeBenchmarkBenchmark); switch (property_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -1942,7 +2058,7 @@ static void _vala_gee_benchmark_benchmark_get_property (GObject * object, guint static void _vala_gee_benchmark_benchmark_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { GeeBenchmarkBenchmark * self; - self = GEE_BENCHMARK_BENCHMARK (object); + self = G_TYPE_CHECK_INSTANCE_CAST (object, GEE_BENCHMARK_TYPE_BENCHMARK, GeeBenchmarkBenchmark); switch (property_id) { case GEE_BENCHMARK_BENCHMARK_G_TYPE: self->priv->g_type = g_value_get_gtype (value); |