From c70fedc47675fab39a1d9b5270706d804e0e156b Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Thu, 24 Feb 2005 17:12:19 +0000 Subject: [PATCH] tests/: New files, good for running complexity benchmarks. Original commit message from CVS: 2005-02-24 Andy Wingo * tests/bench-complexity.scm: * tests/complexity.gnuplot: New files, good for running complexity benchmarks. --- ChangeLog | 4 +++ tests/bench-complexity.scm | 69 +++++++++++++++++++++++++++++++++++++ tests/benchmarks/complexity.c | 28 +++++---------- tests/benchmarks/complexity.gnuplot | 9 +++++ tests/benchmarks/complexity.scm | 69 +++++++++++++++++++++++++++++++++++++ tests/complexity.c | 28 +++++---------- tests/complexity.gnuplot | 9 +++++ 7 files changed, 178 insertions(+), 38 deletions(-) create mode 100755 tests/bench-complexity.scm create mode 100644 tests/benchmarks/complexity.gnuplot create mode 100755 tests/benchmarks/complexity.scm create mode 100644 tests/complexity.gnuplot diff --git a/ChangeLog b/ChangeLog index 28395cd..040f1d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2005-02-24 Andy Wingo + * tests/bench-complexity.scm: + * tests/complexity.gnuplot: New files, good for running complexity + benchmarks. + * tests/Makefile.am: * tests/complexity.c: New test, sets up N elements, at each level teeing into M streams per element. Eeeenteresting. diff --git a/tests/bench-complexity.scm b/tests/bench-complexity.scm new file mode 100755 index 0000000..985d0ae --- /dev/null +++ b/tests/bench-complexity.scm @@ -0,0 +1,69 @@ +#!/bin/bash +# -*- scheme -*- +exec guile -s $0 "$@" +!# + +;; Quick hack to make some data files that gnuplot can read from +;; complexity. Guile 1.6. + +(use-modules (srfi srfi-13) + (srfi srfi-1) + (ice-9 optargs) + (ice-9 popen)) + +(define *phases* '(create set run destroy)) + +(define (read-lines port) + (let lp ((lines '())) + (let ((x (read-line port))) + (if (eof-object? x) + (begin + (close-port port) + (reverse! lines)) + (lp (cons x lines)))))) + +(define (parse-time str) + (and (char-numeric? (string-ref str 0)) + (fold (lambda (x ret) (+ (* ret 60) x)) 0 + (map (lambda (x) (with-input-from-string x read)) + (string-split str #\:))))) + +(define (run-test program . args) + (format #t "; running test: ~a\n" (cons program args)) + (map + cons + *phases* + (filter-map + parse-time + (read-lines + (open-input-pipe + (string-join (map object->string (cons program args)) " ")))))) + +(define (seq start stop step) + (let lp ((n start) (out '())) + (if (> n stop) + (reverse! out) + (lp (+ n step) (cons n out))))) + +(define (run-tests n-elements) + (let lp ((x 1) (out '())) + (if (> x n-elements) + (reverse! out) + (lp (* x 2) + (acons x (run-test "./complexity" x n-elements) out))))) + +(define (output-results results) + (let ((p (open-output-file "complexity.data"))) + (display "#complexity creation state-change run destroy\n" p) + (for-each + (lambda (line) + (display (car line) p) + (for-each + (lambda (t) (format p " ~a" t)) + (map cdr (cdr line))) + (newline p)) + results) + (close-port p))) + +(output-results + (apply run-tests (map string->number (cdr (program-arguments))))) diff --git a/tests/benchmarks/complexity.c b/tests/benchmarks/complexity.c index 44937aa..703aa32 100644 --- a/tests/benchmarks/complexity.c +++ b/tests/benchmarks/complexity.c @@ -58,6 +58,7 @@ main (gint argc, gchar * argv[]) e = gst_element_factory_make ("fakesrc", NULL); g_object_set (e, "num-buffers", BUFFER_COUNT, NULL); + g_object_set (e, "silent", TRUE, NULL); gst_bin_add (GST_BIN (pipeline), e); src_list = saved_src_list = g_slist_append (NULL, e); @@ -70,7 +71,7 @@ main (gint argc, gchar * argv[]) for (i = 0, j = 0; i < n_elements; i++, j++) { if (j >= max_this_level) { g_slist_free (saved_src_list); - saved_src_list = new_src_list; + saved_src_list = g_slist_reverse (new_src_list); new_src_list = NULL; j = 0; all_srcs_linked = FALSE; @@ -86,7 +87,11 @@ main (gint argc, gchar * argv[]) src = (GstElement *) src_list->data; src_list = src_list->next; - e = gst_element_factory_make ("tee", NULL); + if (i + max_this_level < n_elements) + e = gst_element_factory_make ("tee", NULL); + else + e = gst_element_factory_make ("fakesink", NULL); + g_object_set (e, "silent", TRUE, NULL); new_src_list = g_slist_prepend (new_src_list, e); gst_bin_add (GST_BIN (pipeline), e); @@ -94,26 +99,11 @@ main (gint argc, gchar * argv[]) g_assert_not_reached (); } - if (all_srcs_linked) - src_list = new_src_list; - else - src_list = g_slist_concat (new_src_list, g_slist_copy (src_list)); - - g_slist_free (saved_src_list); - saved_src_list = src_list; - while (src_list) { - src = (GstElement *) src_list->data; - src_list = src_list->next; - - e = gst_element_factory_make ("fakesink", NULL); - gst_bin_add (GST_BIN (pipeline), e); - if (gst_element_link (src, e) != GST_PAD_LINK_OK) - g_assert_not_reached (); - } g_slist_free (saved_src_list); + g_slist_free (new_src_list); end = gst_get_current_time (); - g_print ("%" GST_TIME_FORMAT " - creating and linking %d tee elements\n", + g_print ("%" GST_TIME_FORMAT " - creating and linking %d elements\n", GST_TIME_ARGS (end - start), i); start = gst_get_current_time (); diff --git a/tests/benchmarks/complexity.gnuplot b/tests/benchmarks/complexity.gnuplot new file mode 100644 index 0000000..5cb1a33 --- /dev/null +++ b/tests/benchmarks/complexity.gnuplot @@ -0,0 +1,9 @@ +set terminal postscript landscape monochrome dashed "Helvetica" 14 +set xlabel "Number of Forks Per Tee" +set ylabel "Seconds" +set logscale x +set title "Complex Pipeline Performance: N Forks per Tee, 1024 Elements" +plot "complexity.data" using 1:2 title "Element creation", \ + "complexity.data" using 1:3 title "State change", \ + "complexity.data" using 1:4 title "Processing 1000 buffers", \ + "complexity.data" using 1:5 title "Element destruction" diff --git a/tests/benchmarks/complexity.scm b/tests/benchmarks/complexity.scm new file mode 100755 index 0000000..985d0ae --- /dev/null +++ b/tests/benchmarks/complexity.scm @@ -0,0 +1,69 @@ +#!/bin/bash +# -*- scheme -*- +exec guile -s $0 "$@" +!# + +;; Quick hack to make some data files that gnuplot can read from +;; complexity. Guile 1.6. + +(use-modules (srfi srfi-13) + (srfi srfi-1) + (ice-9 optargs) + (ice-9 popen)) + +(define *phases* '(create set run destroy)) + +(define (read-lines port) + (let lp ((lines '())) + (let ((x (read-line port))) + (if (eof-object? x) + (begin + (close-port port) + (reverse! lines)) + (lp (cons x lines)))))) + +(define (parse-time str) + (and (char-numeric? (string-ref str 0)) + (fold (lambda (x ret) (+ (* ret 60) x)) 0 + (map (lambda (x) (with-input-from-string x read)) + (string-split str #\:))))) + +(define (run-test program . args) + (format #t "; running test: ~a\n" (cons program args)) + (map + cons + *phases* + (filter-map + parse-time + (read-lines + (open-input-pipe + (string-join (map object->string (cons program args)) " ")))))) + +(define (seq start stop step) + (let lp ((n start) (out '())) + (if (> n stop) + (reverse! out) + (lp (+ n step) (cons n out))))) + +(define (run-tests n-elements) + (let lp ((x 1) (out '())) + (if (> x n-elements) + (reverse! out) + (lp (* x 2) + (acons x (run-test "./complexity" x n-elements) out))))) + +(define (output-results results) + (let ((p (open-output-file "complexity.data"))) + (display "#complexity creation state-change run destroy\n" p) + (for-each + (lambda (line) + (display (car line) p) + (for-each + (lambda (t) (format p " ~a" t)) + (map cdr (cdr line))) + (newline p)) + results) + (close-port p))) + +(output-results + (apply run-tests (map string->number (cdr (program-arguments))))) diff --git a/tests/complexity.c b/tests/complexity.c index 44937aa..703aa32 100644 --- a/tests/complexity.c +++ b/tests/complexity.c @@ -58,6 +58,7 @@ main (gint argc, gchar * argv[]) e = gst_element_factory_make ("fakesrc", NULL); g_object_set (e, "num-buffers", BUFFER_COUNT, NULL); + g_object_set (e, "silent", TRUE, NULL); gst_bin_add (GST_BIN (pipeline), e); src_list = saved_src_list = g_slist_append (NULL, e); @@ -70,7 +71,7 @@ main (gint argc, gchar * argv[]) for (i = 0, j = 0; i < n_elements; i++, j++) { if (j >= max_this_level) { g_slist_free (saved_src_list); - saved_src_list = new_src_list; + saved_src_list = g_slist_reverse (new_src_list); new_src_list = NULL; j = 0; all_srcs_linked = FALSE; @@ -86,7 +87,11 @@ main (gint argc, gchar * argv[]) src = (GstElement *) src_list->data; src_list = src_list->next; - e = gst_element_factory_make ("tee", NULL); + if (i + max_this_level < n_elements) + e = gst_element_factory_make ("tee", NULL); + else + e = gst_element_factory_make ("fakesink", NULL); + g_object_set (e, "silent", TRUE, NULL); new_src_list = g_slist_prepend (new_src_list, e); gst_bin_add (GST_BIN (pipeline), e); @@ -94,26 +99,11 @@ main (gint argc, gchar * argv[]) g_assert_not_reached (); } - if (all_srcs_linked) - src_list = new_src_list; - else - src_list = g_slist_concat (new_src_list, g_slist_copy (src_list)); - - g_slist_free (saved_src_list); - saved_src_list = src_list; - while (src_list) { - src = (GstElement *) src_list->data; - src_list = src_list->next; - - e = gst_element_factory_make ("fakesink", NULL); - gst_bin_add (GST_BIN (pipeline), e); - if (gst_element_link (src, e) != GST_PAD_LINK_OK) - g_assert_not_reached (); - } g_slist_free (saved_src_list); + g_slist_free (new_src_list); end = gst_get_current_time (); - g_print ("%" GST_TIME_FORMAT " - creating and linking %d tee elements\n", + g_print ("%" GST_TIME_FORMAT " - creating and linking %d elements\n", GST_TIME_ARGS (end - start), i); start = gst_get_current_time (); diff --git a/tests/complexity.gnuplot b/tests/complexity.gnuplot new file mode 100644 index 0000000..5cb1a33 --- /dev/null +++ b/tests/complexity.gnuplot @@ -0,0 +1,9 @@ +set terminal postscript landscape monochrome dashed "Helvetica" 14 +set xlabel "Number of Forks Per Tee" +set ylabel "Seconds" +set logscale x +set title "Complex Pipeline Performance: N Forks per Tee, 1024 Elements" +plot "complexity.data" using 1:2 title "Element creation", \ + "complexity.data" using 1:3 title "State change", \ + "complexity.data" using 1:4 title "Processing 1000 buffers", \ + "complexity.data" using 1:5 title "Element destruction" -- 2.7.4