Thomas Pelle Jakobsen
2008-11-07 00:37:46 UTC
# HG changeset patch
# User Thomas Pelle Jakobsen <***@daimi.au.dk>
# Date 1226015460 -3600
# Node ID 0985564470de2bb2c5247effd30dc40f74048f17
# Parent aa8ba57c7833f0d68792db7c36782e3ba9fbc194
Added graph example.
diff -r aa8ba57c7833 -r 0985564470de apps/benchmark/graph.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/apps/benchmark/graph.py Fri Nov 07 00:51:00 2008 +0100
@@ -0,0 +1,83 @@
+#!/usr/bin/python
+#
+# Copyright 2007, 2008 VIFF Development Team.
+#
+# This file is part of VIFF, the Virtual Ideal Functionality Framework.
+#
+# VIFF is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License (LGPL) as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VIFF is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with VIFF. If not, see <http://www.gnu.org/licenses/>.
+
+""" A rudimentary script that generates graphs of some benchmark results.
+It could be executed periodically or triggered by a benchmark run, a
+viff commit or something else.
+
+All sorts of statistics could be generated by scripts like this.
+"""
+
+import sys
+from database import Database
+import numpy as np
+import matplotlib.pyplot as plt
+
+def example1(database):
+ """Create a graph showing for each suite the revision on the x-axis and
+ the average execution time of Toft05 comparison for three players on the
+ y-axis (timings from host with player_id one is used).
+ """
+ vals = database.sql_query("""
+ SELECT Suite.revision, Suite.starttime, AVG(Result.value)
+ FROM Suite
+ INNER JOIN VIFFBenchmark AS b ON Suite.id = b.suite
+ INNER JOIN IntegerBenchmarkAttribute AS iba ON b.id = iba.benchmark
+ INNER JOIN Result ON b.id = Result.benchmark
+ WHERE b.name = 'ComparisonToft05'
+ AND iba.attribute = 'n'
+ AND iba.value = 3
+ AND Result.host = 1
+ AND Result.attribute = 'execution_time'
+ GROUP BY Suite.id, b.id;
+ """)
+
+ toft05_avgs = []
+ revisions = []
+ for revision, timestamp, average in vals:
+ print revision, timestamp, average
+ toft05_avgs.append(int(average/1000))
+ revisions.append(revision)
+ N = len(revisions)
+ ind = np.arange(N)
+ width = 0.35 # the width of the bars: can also be len(x) sequence
+ p1 = plt.bar(ind, toft05_avgs, width, color='r')
+ plt.ylabel('execution time / ms')
+ plt.title('VIFF Benchmark Results')
+ plt.xticks(ind+width/2., revisions )
+ plt.legend( (p1[0],), ('Toft05Comparison',) )
+ plt.show()
+ #savefig("fig1.png",dpi=(640/8))
+
+if __name__ == "__main__":
+ database = Database(host="localhost",
+ db="viff_benchmark",
+ user="root",
+ passwd=sys.argv[1])
+
+ example1(database)
+
+ # TODO: We would like hg commit dates to exist in database as well
+ # as the suite execution date. How?
+
+ # TODO: Consider replacing the raw SQL with calls to general methods
+ # in database.py.
+
+
+
# User Thomas Pelle Jakobsen <***@daimi.au.dk>
# Date 1226015460 -3600
# Node ID 0985564470de2bb2c5247effd30dc40f74048f17
# Parent aa8ba57c7833f0d68792db7c36782e3ba9fbc194
Added graph example.
diff -r aa8ba57c7833 -r 0985564470de apps/benchmark/graph.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/apps/benchmark/graph.py Fri Nov 07 00:51:00 2008 +0100
@@ -0,0 +1,83 @@
+#!/usr/bin/python
+#
+# Copyright 2007, 2008 VIFF Development Team.
+#
+# This file is part of VIFF, the Virtual Ideal Functionality Framework.
+#
+# VIFF is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License (LGPL) as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VIFF is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with VIFF. If not, see <http://www.gnu.org/licenses/>.
+
+""" A rudimentary script that generates graphs of some benchmark results.
+It could be executed periodically or triggered by a benchmark run, a
+viff commit or something else.
+
+All sorts of statistics could be generated by scripts like this.
+"""
+
+import sys
+from database import Database
+import numpy as np
+import matplotlib.pyplot as plt
+
+def example1(database):
+ """Create a graph showing for each suite the revision on the x-axis and
+ the average execution time of Toft05 comparison for three players on the
+ y-axis (timings from host with player_id one is used).
+ """
+ vals = database.sql_query("""
+ SELECT Suite.revision, Suite.starttime, AVG(Result.value)
+ FROM Suite
+ INNER JOIN VIFFBenchmark AS b ON Suite.id = b.suite
+ INNER JOIN IntegerBenchmarkAttribute AS iba ON b.id = iba.benchmark
+ INNER JOIN Result ON b.id = Result.benchmark
+ WHERE b.name = 'ComparisonToft05'
+ AND iba.attribute = 'n'
+ AND iba.value = 3
+ AND Result.host = 1
+ AND Result.attribute = 'execution_time'
+ GROUP BY Suite.id, b.id;
+ """)
+
+ toft05_avgs = []
+ revisions = []
+ for revision, timestamp, average in vals:
+ print revision, timestamp, average
+ toft05_avgs.append(int(average/1000))
+ revisions.append(revision)
+ N = len(revisions)
+ ind = np.arange(N)
+ width = 0.35 # the width of the bars: can also be len(x) sequence
+ p1 = plt.bar(ind, toft05_avgs, width, color='r')
+ plt.ylabel('execution time / ms')
+ plt.title('VIFF Benchmark Results')
+ plt.xticks(ind+width/2., revisions )
+ plt.legend( (p1[0],), ('Toft05Comparison',) )
+ plt.show()
+ #savefig("fig1.png",dpi=(640/8))
+
+if __name__ == "__main__":
+ database = Database(host="localhost",
+ db="viff_benchmark",
+ user="root",
+ passwd=sys.argv[1])
+
+ example1(database)
+
+ # TODO: We would like hg commit dates to exist in database as well
+ # as the suite execution date. How?
+
+ # TODO: Consider replacing the raw SQL with calls to general methods
+ # in database.py.
+
+
+