benchmarks: use gst_util_get_timestamp() instead of own implementation

This commit is contained in:
Stefan Kost 2010-05-18 17:51:01 +03:00
parent 3d72274b19
commit f9fd1524cd
4 changed files with 28 additions and 64 deletions

View file

@ -36,16 +36,6 @@
"signed = (boolean) { true, false }" "signed = (boolean) { true, false }"
static GstClockTime
gst_get_current_time (void)
{
GTimeVal tv;
g_get_current_time (&tv);
return GST_TIMEVAL_TO_TIME (tv);
}
gint gint
main (gint argc, gchar * argv[]) main (gint argc, gchar * argv[])
{ {
@ -58,18 +48,18 @@ main (gint argc, gchar * argv[])
protocaps = gst_caps_from_string (GST_AUDIO_INT_PAD_TEMPLATE_CAPS); protocaps = gst_caps_from_string (GST_AUDIO_INT_PAD_TEMPLATE_CAPS);
start = gst_get_current_time (); start = gst_util_get_timestamp ();
capses = g_new (GstCaps *, NUM_CAPS); capses = g_new (GstCaps *, NUM_CAPS);
for (i = 0; i < NUM_CAPS; i++) for (i = 0; i < NUM_CAPS; i++)
capses[i] = gst_caps_copy (protocaps); capses[i] = gst_caps_copy (protocaps);
end = gst_get_current_time (); end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT " - creating %d caps\n", g_print ("%" GST_TIME_FORMAT " - creating %d caps\n",
GST_TIME_ARGS (end - start), i); GST_TIME_ARGS (end - start), i);
start = gst_get_current_time (); start = gst_util_get_timestamp ();
for (i = 0; i < NUM_CAPS; i++) for (i = 0; i < NUM_CAPS; i++)
gst_caps_unref (capses[i]); gst_caps_unref (capses[i]);
end = gst_get_current_time (); end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT " - destroying %d caps\n", g_print ("%" GST_TIME_FORMAT " - destroying %d caps\n",
GST_TIME_ARGS (end - start), i); GST_TIME_ARGS (end - start), i);

View file

@ -26,15 +26,6 @@
#define SINK_ELEMENT "fakesink" #define SINK_ELEMENT "fakesink"
static GstClockTime
gst_get_current_time (void)
{
GTimeVal tv;
g_get_current_time (&tv);
return GST_TIMEVAL_TO_TIME (tv);
}
gint gint
main (gint argc, gchar * argv[]) main (gint argc, gchar * argv[])
{ {
@ -55,7 +46,7 @@ main (gint argc, gchar * argv[])
complexity_order = atoi (argv[1]); complexity_order = atoi (argv[1]);
n_elements = atoi (argv[2]); n_elements = atoi (argv[2]);
start = gst_get_current_time (); start = gst_util_get_timestamp ();
pipeline = gst_element_factory_make ("pipeline", NULL); pipeline = gst_element_factory_make ("pipeline", NULL);
g_assert (pipeline); g_assert (pipeline);
@ -108,40 +99,40 @@ main (gint argc, gchar * argv[])
g_slist_free (saved_src_list); g_slist_free (saved_src_list);
g_slist_free (new_src_list); g_slist_free (new_src_list);
end = gst_get_current_time (); end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT " - creating and linking %d elements\n", g_print ("%" GST_TIME_FORMAT " - creating and linking %d elements\n",
GST_TIME_ARGS (end - start), i); GST_TIME_ARGS (end - start), i);
start = gst_get_current_time (); start = gst_util_get_timestamp ();
if (gst_element_set_state (pipeline, if (gst_element_set_state (pipeline,
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
g_assert_not_reached (); g_assert_not_reached ();
if (gst_element_get_state (pipeline, NULL, NULL, if (gst_element_get_state (pipeline, NULL, NULL,
GST_CLOCK_TIME_NONE) == GST_STATE_CHANGE_FAILURE) GST_CLOCK_TIME_NONE) == GST_STATE_CHANGE_FAILURE)
g_assert_not_reached (); g_assert_not_reached ();
end = gst_get_current_time (); end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT " - setting pipeline to playing\n", g_print ("%" GST_TIME_FORMAT " - setting pipeline to playing\n",
GST_TIME_ARGS (end - start)); GST_TIME_ARGS (end - start));
start = gst_get_current_time (); start = gst_util_get_timestamp ();
msg = gst_bus_poll (gst_element_get_bus (pipeline), msg = gst_bus_poll (gst_element_get_bus (pipeline),
GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1); GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
end = gst_get_current_time (); end = gst_util_get_timestamp ();
gst_message_unref (msg); gst_message_unref (msg);
g_print ("%" GST_TIME_FORMAT " - putting %u buffers through\n", g_print ("%" GST_TIME_FORMAT " - putting %u buffers through\n",
GST_TIME_ARGS (end - start), BUFFER_COUNT); GST_TIME_ARGS (end - start), BUFFER_COUNT);
start = gst_get_current_time (); start = gst_util_get_timestamp ();
if (gst_element_set_state (pipeline, if (gst_element_set_state (pipeline,
GST_STATE_NULL) != GST_STATE_CHANGE_SUCCESS) GST_STATE_NULL) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached (); g_assert_not_reached ();
end = gst_get_current_time (); end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT " - setting pipeline to NULL\n", g_print ("%" GST_TIME_FORMAT " - setting pipeline to NULL\n",
GST_TIME_ARGS (end - start)); GST_TIME_ARGS (end - start));
start = gst_get_current_time (); start = gst_util_get_timestamp ();
g_object_unref (pipeline); g_object_unref (pipeline);
end = gst_get_current_time (); end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n", g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n",
GST_TIME_ARGS (end - start)); GST_TIME_ARGS (end - start));

View file

@ -26,14 +26,6 @@
static guint64 nbbuffers; static guint64 nbbuffers;
static GMutex *mutex; static GMutex *mutex;
static GstClockTime
gst_get_current_time (void)
{
GTimeVal tv;
g_get_current_time (&tv);
return GST_TIMEVAL_TO_TIME (tv);
}
static void * static void *
run_test (void *user_data) run_test (void *user_data)
@ -46,14 +38,14 @@ run_test (void *user_data)
g_mutex_lock (mutex); g_mutex_lock (mutex);
g_mutex_unlock (mutex); g_mutex_unlock (mutex);
start = gst_get_current_time (); start = gst_util_get_timestamp ();
for (nb = nbbuffers; nb; nb--) { for (nb = nbbuffers; nb; nb--) {
buf = gst_buffer_new (); buf = gst_buffer_new ();
gst_buffer_unref (buf); gst_buffer_unref (buf);
} }
end = gst_get_current_time (); end = gst_util_get_timestamp ();
g_print ("total %" GST_TIME_FORMAT " - average %" GST_TIME_FORMAT g_print ("total %" GST_TIME_FORMAT " - average %" GST_TIME_FORMAT
" - Thread %d\n", GST_TIME_ARGS (end - start), " - Thread %d\n", GST_TIME_ARGS (end - start),
GST_TIME_ARGS ((end - start) / nbbuffers), threadid); GST_TIME_ARGS ((end - start) / nbbuffers), threadid);
@ -99,7 +91,7 @@ main (gint argc, gchar * argv[])
} }
/* Signal all threads to start */ /* Signal all threads to start */
start = gst_get_current_time (); start = gst_util_get_timestamp ();
g_mutex_unlock (mutex); g_mutex_unlock (mutex);
for (t = 0; t < num_threads; t++) { for (t = 0; t < num_threads; t++) {
@ -107,7 +99,7 @@ main (gint argc, gchar * argv[])
g_thread_join (threads[t]); g_thread_join (threads[t]);
} }
end = gst_get_current_time (); end = gst_util_get_timestamp ();
g_print ("*** total %" GST_TIME_FORMAT " - average %" GST_TIME_FORMAT g_print ("*** total %" GST_TIME_FORMAT " - average %" GST_TIME_FORMAT
" - Done creating %" G_GUINT64_FORMAT " buffers\n", " - Done creating %" G_GUINT64_FORMAT " buffers\n",
GST_TIME_ARGS (end - start), GST_TIME_ARGS (end - start),

View file

@ -26,15 +26,6 @@
#define SINK_ELEMENT "fakesink" #define SINK_ELEMENT "fakesink"
static GstClockTime
gst_get_current_time (void)
{
GTimeVal tv;
g_get_current_time (&tv);
return GST_TIMEVAL_TO_TIME (tv);
}
gint gint
main (gint argc, gchar * argv[]) main (gint argc, gchar * argv[])
{ {
@ -58,7 +49,7 @@ main (gint argc, gchar * argv[])
g_print g_print
("*** benchmarking this pipeline: %s num-buffers=%u ! %u * identity ! %s\n", ("*** benchmarking this pipeline: %s num-buffers=%u ! %u * identity ! %s\n",
src_name, buffers, identities, sink_name); src_name, buffers, identities, sink_name);
start = gst_get_current_time (); start = gst_util_get_timestamp ();
pipeline = gst_element_factory_make ("pipeline", NULL); pipeline = gst_element_factory_make ("pipeline", NULL);
g_assert (pipeline); g_assert (pipeline);
src = gst_element_factory_make (src_name, NULL); src = gst_element_factory_make (src_name, NULL);
@ -86,40 +77,40 @@ main (gint argc, gchar * argv[])
} }
if (!gst_element_link (last, sink)) if (!gst_element_link (last, sink))
g_assert_not_reached (); g_assert_not_reached ();
end = gst_get_current_time (); end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT " - creating %u identity elements\n", g_print ("%" GST_TIME_FORMAT " - creating %u identity elements\n",
GST_TIME_ARGS (end - start), identities); GST_TIME_ARGS (end - start), identities);
start = gst_get_current_time (); start = gst_util_get_timestamp ();
if (gst_element_set_state (pipeline, if (gst_element_set_state (pipeline,
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
g_assert_not_reached (); g_assert_not_reached ();
if (gst_element_get_state (pipeline, NULL, NULL, if (gst_element_get_state (pipeline, NULL, NULL,
GST_CLOCK_TIME_NONE) == GST_STATE_CHANGE_FAILURE) GST_CLOCK_TIME_NONE) == GST_STATE_CHANGE_FAILURE)
g_assert_not_reached (); g_assert_not_reached ();
end = gst_get_current_time (); end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT " - setting pipeline to playing\n", g_print ("%" GST_TIME_FORMAT " - setting pipeline to playing\n",
GST_TIME_ARGS (end - start)); GST_TIME_ARGS (end - start));
start = gst_get_current_time (); start = gst_util_get_timestamp ();
msg = gst_bus_poll (gst_element_get_bus (pipeline), msg = gst_bus_poll (gst_element_get_bus (pipeline),
GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1); GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
end = gst_get_current_time (); end = gst_util_get_timestamp ();
gst_message_unref (msg); gst_message_unref (msg);
g_print ("%" GST_TIME_FORMAT " - putting %u buffers through\n", g_print ("%" GST_TIME_FORMAT " - putting %u buffers through\n",
GST_TIME_ARGS (end - start), buffers); GST_TIME_ARGS (end - start), buffers);
start = gst_get_current_time (); start = gst_util_get_timestamp ();
if (gst_element_set_state (pipeline, if (gst_element_set_state (pipeline,
GST_STATE_NULL) != GST_STATE_CHANGE_SUCCESS) GST_STATE_NULL) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached (); g_assert_not_reached ();
end = gst_get_current_time (); end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT " - setting pipeline to NULL\n", g_print ("%" GST_TIME_FORMAT " - setting pipeline to NULL\n",
GST_TIME_ARGS (end - start)); GST_TIME_ARGS (end - start));
start = gst_get_current_time (); start = gst_util_get_timestamp ();
g_object_unref (pipeline); g_object_unref (pipeline);
end = gst_get_current_time (); end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n", g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n",
GST_TIME_ARGS (end - start)); GST_TIME_ARGS (end - start));