/[escript]/trunk/escript/py_src/benchmark.py
ViewVC logotype

Diff of /trunk/escript/py_src/benchmark.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/escript/py_src/benchmark.py revision 435 by gross, Thu Jan 19 03:57:30 2006 UTC temp_trunk_copy/escript/py_src/benchmark.py revision 1384 by phornby, Fri Jan 11 02:29:38 2008 UTC
# Line 1  Line 1 
1  filter# $Id:$  filter# $Id:$
2    
 #  
 #      COPYRIGHT ACcESS 2004 -  All Rights Reserved  
 #  
 #   This software is the property of ACcESS.  No part of this code  
 #   may be copied in any form or by any means without the expressed written  
 #   consent of ACcESS.  Copying, use or modification of this software  
 #   by any unauthorised person is illegal unless that  
 #   person has a software license agreement with ACcESS.  
 #  
   
3  """  """
4  A simple framework to run benchmarks under OPENMP and to summarize the results in tables for instance in HTML  A simple framework to run benchmarks under OPENMP and to summarize the results in tables for instance in HTML
5    
6  @var __author__: name of author  @var __author__: name of author
7  @var __licence__: licence agreement  @var __license__: licence agreement
8  var __url__: url entry point on documentation  @var __copyright__: copyrights
9    @var __url__: url entry point on documentation
10  @var __version__: version  @var __version__: version
11  @var __date__: date of the version  @var __date__: date of the version
12  """  """
13    
14  __author__="Lutz Gross, l.gross@uq.edu.au"  __author__="Lutz Gross, l.gross@uq.edu.au"
15  __licence__="contact: esys@access.uq.edu.au"  __copyright__="""  Copyright (c) 2006 by ACcESS MNRF
16                        http://www.access.edu.au
17                    Primary Business: Queensland, Australia"""
18    __license__="""Licensed under the Open Software License version 3.0
19                 http://www.opensource.org/licenses/osl-3.0.php"""
20  __url__="http://www.iservo.edu.au/esys/escript"  __url__="http://www.iservo.edu.au/esys/escript"
21  __version__="$Revision:$"  __version__="$Revision$"
22  __date__="$Date:$"  __date__="$Date$"
23    
24  import os,socket,time,sys  import os,socket,time,sys,traceback
25  from esys.escript import setNumberOfThreads  from esys.escript import setNumberOfThreads
26    
27  class BenchmarkSuite(object):  class BenchmarkSuite(object):
28     """     """
29     framework to run a bunch of L{Benchmark}s with the object to create a table of statistics.     framework to run a bunch of L{Benchmark}s with the object to create a table of statistics.
30     @var MAX_LEVEL: maximum number of level in headers for output  
31       @cvar MAX_LEVEL: maximum number of level in headers for output
32     """     """
33     MAX_LEVEL=5     MAX_LEVEL=5
34     def __init__(self,name=None):     def __init__(self,name=None):
# Line 173  class Benchmark(object): Line 169  class Benchmark(object):
169         """         """
170         self.__problems.append(problem)         self.__problems.append(problem)
171    
172     def addOptions(self,Options):     def addOptions(self,options):
173         """         """
174         adds a options to the benchmark         adds a options to the benchmark
175    
176         @param options: adds a new option to the bechmark         @param options: adds a new option to the bechmark. If options==None they are are ignored
177         @type problem: L{Options}         @type options: L{Options}
178         """         """
179         self.__options.append(Options)         if options!=None: self.__options.append(options)
180    
181     def run(self,scale=1):     def run(self,scale=1):
182         """         """
# Line 211  class Benchmark(object): Line 207  class Benchmark(object):
207                print "%s with %s threads started."%(r.__class__,s)                print "%s with %s threads started."%(r.__class__,s)
208                for p in self.__options:                for p in self.__options:
209                    setNumberOfThreads(s)                    setNumberOfThreads(s)
210                    row.append(r.run(p))                    try:
211                         row.append(r.run(p))
212                      except:
213                         traceback.print_exc(file=sys.stdout)
214                         row.append(None)
215                t0=time.time()-t0                t0=time.time()-t0
216                print "%s with %s threads finished (walltime =%s sec)."%(r.__class__,s,t0)                print "%s with %s threads finished (walltime =%s sec)."%(r.__class__,s,t0)
217            self.__results.append(row)            self.__results.append(row)
# Line 250  class Benchmark(object): Line 250  class Benchmark(object):
250            for o in self.__options:            for o in self.__options:
251                   if len(rn)==0:                   if len(rn)==0:
252                       h0+="<TH ALIGN=\"center\">%s</TH>"%str(o)                       h0+="<TH ALIGN=\"center\">%s</TH>"%str(o)
253                         colspan=1
254                   elif len(rn)==1:                   elif len(rn)==1:
255                       h0+="<TH ALIGN=\"center\">%s</TH>"%str(o)                       h0+="<TH ALIGN=\"center\">%s</TH>"%str(o)
256                         colspan=1
257                       empty_h1=False                       empty_h1=False
258                   else:                   else:
259                       h0+="<TH ALIGN=\"center\" COLSPAN=%s>%s</TH>"%(len(rn),str(o))                       colspan=len(rn)
260                         h0+="<TH ALIGN=\"center\" COLSPAN=%s>%s</TH>"%(colspan,str(o))
261                   h1+=h1_seg                   h1+=h1_seg
262            out+=h0+"</TR>\n"+h1+"</TR>\n"            out+=h0+"</TR>\n"+h1+"</TR>\n"
263            c=0            c=0
264            for r in range(len(self.__results)):            for r in range(len(self.__results)):
265               out+="<TR><TH ALIGN=\"right\">%s</TH>"%str(self.__problems[r])               out+="<TR><TH ALIGN=\"right\">%s</TH>"%str(self.__problems[r])
266               if isinstance(self.__scale,list): out+="<TD ALIGN=\"right\">%s</TD>"%self.__scale[c]               if isinstance(self.__scale,list):
267                     out+="<TD ALIGN=\"right\">%s</TD>"%self.__scale[c]
268               for col in self.__results[r]:               for col in self.__results[r]:
269                     for e in filter(col): out+="<TD ALIGN=\"right\">%s</TD>"%e                     if col==None:
270                          out+="<TD ALIGN=\"center\" COLSPAN=%s>failed.</TD>"%colspan
271                       else:
272                          for e in filter(col): out+="<TD ALIGN=\"right\">%s</TD>"%e
273               out+="</TR>\n"               out+="</TR>\n"
274               c+=1               c+=1
275            out+="</TABLE>"            out+="</TABLE>"
# Line 308  class BenchmarkProblem(object): Line 315  class BenchmarkProblem(object):
315         @type options: L{Options}         @type options: L{Options}
316         @return: run characteristics         @return: run characteristics
317         @rtype: any type that can be read by the L{BenchmarkFilter} applied to it.         @rtype: any type that can be read by the L{BenchmarkFilter} applied to it.
318         @remark: this function has to overwritten by a particular problem         @note: this function has to overwritten by a particular problem
319         """         """
320         raise NotImplementedError         raise NotImplementedError
321         return []         return []
# Line 331  class BenchmarkFilter(object): Line 338  class BenchmarkFilter(object):
338                
339         @return: names the list of the names to be used when the results of the run() call are printed         @return: names the list of the names to be used when the results of the run() call are printed
340         @rtype: C{list} of C{str}         @rtype: C{list} of C{str}
341         @remark: this function has to overwritten by a particular problem         @note: this function has to overwritten by a particular problem
342         """         """
343         raise NotImplementedError         raise NotImplementedError
344         return []         return []
# Line 344  class BenchmarkFilter(object): Line 351  class BenchmarkFilter(object):
351         @type result: any type that is produced by the L{BenchmarkProblem} it is applied to         @type result: any type that is produced by the L{BenchmarkProblem} it is applied to
352         @return: a list of strings selected from result         @return: a list of strings selected from result
353         @rtype: C{list} of C{str}         @rtype: C{list} of C{str}
354         @remark: this function has to overwritten by a particular problem         @note: this function has to overwritten by a particular problem
355         """         """
356         raise NotImplementedError         raise NotImplementedError
357         return []         return []

Legend:
Removed from v.435  
changed lines
  Added in v.1384

  ViewVC Help
Powered by ViewVC 1.1.26