/[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

revision 387 by gross, Tue Dec 20 00:37:20 2005 UTC revision 637 by gross, Thu Mar 23 10:55:31 2006 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
26    
27  class BenchmarkSuite(object):  class BenchmarkSuite(object):
28     """     """
# Line 120  class BenchmarkSuite(object): Line 116  class BenchmarkSuite(object):
116             out+=self[i].getHTML(filter=filter,level=min(level+1,self.MAX_LEVEL))             out+=self[i].getHTML(filter=filter,level=min(level+1,self.MAX_LEVEL))
117             out+="<p>\n"             out+="<p>\n"
118         if level==1:         if level==1:
119             out+="<hr><p align=\"center\">by %s at %s</p>\n"%(os.getlogin(),time.strftime('%X %x %Z'))             try:
120                   name=os.getlogin()
121                   out+="<hr><p align=\"center\">by %s at %s</p>\n"%(name,time.strftime('%X %x %Z'))
122               except OSError:
123                   out+="<hr><p align=\"center\">%s</p>\n"%(time.strftime('%X %x %Z'))
124                  
125             out+="</BODY></HTML>\n"             out+="</BODY></HTML>\n"
126         return out         return out
127    
# Line 167  class Benchmark(object): Line 168  class Benchmark(object):
168         """         """
169         self.__problems.append(problem)         self.__problems.append(problem)
170    
171     def addOptions(self,Options):     def addOptions(self,options):
172         """         """
173         adds a options to the benchmark         adds a options to the benchmark
174    
175         @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
176         @type problem: L{Options}         @type problem: L{Options}
177         """         """
178         self.__options.append(Options)         if options!=None: self.__options.append(options)
179    
180     def run(self,scale=1):     def run(self,scale=1):
181         """         """
# Line 201  class Benchmark(object): Line 202  class Benchmark(object):
202               s=scale               s=scale
203            row=[]            row=[]
204            if s>0:            if s>0:
205                  t0=time.time()
206                  print "%s with %s threads started."%(r.__class__,s)
207                for p in self.__options:                for p in self.__options:
208                    os.environ['OMP_NUM_THREADS']=str(s)                    setNumberOfThreads(s)
209                    row.append(r.run(p))                    try:
210                         row.append(r.run(p))
211                      except:
212                         traceback.print_exc(file=sys.stdout)
213                         row.append(None)
214                  t0=time.time()-t0
215                  print "%s with %s threads finished (walltime =%s sec)."%(r.__class__,s,t0)
216            self.__results.append(row)            self.__results.append(row)
217     def getHTML(self,filter,level=1):     def getHTML(self,filter,level=1):
218         """         """
# Line 240  class Benchmark(object): Line 249  class Benchmark(object):
249            for o in self.__options:            for o in self.__options:
250                   if len(rn)==0:                   if len(rn)==0:
251                       h0+="<TH ALIGN=\"center\">%s</TH>"%str(o)                       h0+="<TH ALIGN=\"center\">%s</TH>"%str(o)
252                         colspan=1
253                   elif len(rn)==1:                   elif len(rn)==1:
254                       h0+="<TH ALIGN=\"center\">%s</TH>"%str(o)                       h0+="<TH ALIGN=\"center\">%s</TH>"%str(o)
255                         colspan=1
256                       empty_h1=False                       empty_h1=False
257                   else:                   else:
258                       h0+="<TH ALIGN=\"center\" COLSPAN=%s>%s</TH>"%(len(rn),str(o))                       colspan=len(rn)
259                         h0+="<TH ALIGN=\"center\" COLSPAN=%s>%s</TH>"%(colspan,str(o))
260                   h1+=h1_seg                   h1+=h1_seg
261            out+=h0+"</TR>\n"+h1+"</TR>\n"            out+=h0+"</TR>\n"+h1+"</TR>\n"
262            c=0            c=0
263            for r in range(len(self.__results)):            for r in range(len(self.__results)):
264               out+="<TR><TH ALIGN=\"right\">%s</TH>"%str(self.__problems[r])               out+="<TR><TH ALIGN=\"right\">%s</TH>"%str(self.__problems[r])
265               if isinstance(self.__scale,list): out+="<TD ALIGN=\"right\">%s</TD>"%self.__scale[c]               if isinstance(self.__scale,list):
266                     out+="<TD ALIGN=\"right\">%s</TD>"%self.__scale[c]
267               for col in self.__results[r]:               for col in self.__results[r]:
268                     for e in filter(col): out+="<TD ALIGN=\"right\">%s</TD>"%e                     if col==None:
269                          out+="<TD ALIGN=\"center\" COLSPAN=%s>failed.</TD>"%colspan
270                       else:
271                          for e in filter(col): out+="<TD ALIGN=\"right\">%s</TD>"%e
272               out+="</TR>\n"               out+="</TR>\n"
273               c+=1               c+=1
274            out+="</TABLE>"            out+="</TABLE>"

Legend:
Removed from v.387  
changed lines
  Added in v.637

  ViewVC Help
Powered by ViewVC 1.1.26