File: plot.py

package info (click to toggle)
ffc 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 50,704 kB
  • sloc: cpp: 572,515; python: 15,790; makefile: 134; sh: 67
file content (80 lines) | stat: -rw-r--r-- 2,523 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
"This script plots the results found in bench.log."

# Copyright (C) 2010 Anders Logg
#
# This file is part of FFC.
#
# FFC is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# FFC 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 FFC. If not, see <http://www.gnu.org/licenses/>.
#
# First added:  2010-05-13
# Last changed: 2010-05-13

from pylab import *

# Read logfile
results = {}
try:
    output = open("bench.log").read()
except:
    output = open("results/bench.log").read()
for line in output.split("\n"):
    if not "," in line: continue
    test_case, test_option, timing = [w.strip() for w in line.split(",")]
    try:
        form, degree = test_case.split("_")
    except:
        form, dim, degree = test_case.split("_")
        form = form + "_" + dim
    if not form in results:
        results[form] = {}
    if not test_option in results[form]:
        results[form][test_option] = ([], [])
    results[form][test_option][0].append(int(degree))
    results[form][test_option][1].append(float(timing))

# Plot results
forms = sorted([form for form in results])
test_options = ["-r quadrature", "-r quadrature -O", "-r tensor", "-r tensor -O"]
bullets = ["x-", "o-", "*-", "s-"]
for (i, form) in enumerate(forms):
    figure(i)

    # Plot timings
    subplot(121)
    for (j, test_option) in enumerate(test_options):
        q, t = results[form][test_option]
        semilogy(q, t, bullets[j])
        hold(True)
    a = list(axis()); a[-1] = 50.0*a[-1]; axis(a);
    legend(test_options, loc="upper left")
    grid(True)
    xlabel('degree')
    ylabel(form)
    title('CPU time')

    # Plot speedups
    subplot(122)
    q0, t0 = results[form]["-r quadrature"]
    for (j, test_option) in enumerate(test_options):
        q, t = results[form][test_option]
        t = [t0[k] / t[k] for k in range(len(t))]
        semilogy(q, t, bullets[j])
        hold(True)
    a = list(axis()); a[-1] = 50.0*a[-1]; axis(a);
    legend(test_options, loc="upper left")
    grid(True)
    xlabel('degree')
    title("Speedup vs '-r quadrature'")

show()