cachetest/test.py
Go to the documentation of this file.00001
00002 from ufl import *
00003 from sfc import jit
00004 from time import time
00005
00006 _t = None
00007 def tic():
00008 global _t
00009 _t = time()
00010
00011 def toc():
00012 global _t
00013 t = time() - _t
00014 _t = None
00015 return t
00016
00017 def timeit(input):
00018 tic()
00019 jit(input)
00020 t = toc()
00021 return t
00022
00023 for take in range(3):
00024 print "="*80
00025 print "Take", take
00026 avg = 0.0
00027 n = 0
00028 for cell in (interval, triangle, tetrahedron):
00029 for degree in range(1, 3):
00030
00031 e = FiniteElement("CG", cell, degree)
00032 for input in (e, [e]):
00033 t = timeit(input)
00034 print "Time for %s: %.4f s" % (repr(input), t)
00035 avg += t
00036 n += 1
00037
00038 input = FiniteElement("CG", cell, degree) + FiniteElement("CG", cell, degree+1)
00039 t = timeit(input)
00040 print "Time for %s: %.4f s" % (repr(input), t)
00041 avg += t
00042 n += 1
00043
00044 input = TensorElement("CG", cell, degree) + VectorElement("CG", cell, degree+1) + FiniteElement("CG", cell, degree+2)
00045 t = timeit(input)
00046 print "Time for %s: %.4f s" % (repr(input), t)
00047 avg += t
00048 n += 1
00049
00050 avg /= n
00051 print "Average for take", take, "is", avg
00052