/[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 385 by gross, Mon Dec 19 06:12:14 2005 UTC revision 435 by gross, Thu Jan 19 03:57:30 2006 UTC
# Line 27  __version__="$Revision:$" Line 27  __version__="$Revision:$"
27  __date__="$Date:$"  __date__="$Date:$"
28    
29  import os,socket,time,sys  import os,socket,time,sys
30    from esys.escript import setNumberOfThreads
31    
32  class BenchmarkSuite(object):  class BenchmarkSuite(object):
33     """     """
# Line 90  class BenchmarkSuite(object): Line 91  class BenchmarkSuite(object):
91    
92         @param scale: defines the number of (OpenMP) threads to be used. If scale is a scalar all benchmarks         @param scale: defines the number of (OpenMP) threads to be used. If scale is a scalar all benchmarks
93                       are run with scale number of threads. If scale is a C{list}, the p-th problem in each of the benchmarks                       are run with scale number of threads. If scale is a C{list}, the p-th problem in each of the benchmarks
94                       in the suite is run with scale[p] threads. In the case, len(scale) has to be less or equal to the                       in the suite is run with scale[p] threads. If scale[p]<1 teh p-th problem is omitted.
                      largest benchmark in the suite.  
95         @type scale: C{int} or C{list} of C{int}s.         @type scale: C{int} or C{list} of C{int}s.
96         """         """
97         self.__scale=scale               self.__scale=scale      
# Line 121  class BenchmarkSuite(object): Line 121  class BenchmarkSuite(object):
121             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))
122             out+="<p>\n"             out+="<p>\n"
123         if level==1:         if level==1:
124             out+="<hr><p align=\"center\">by %s at %s</p>\n"%(os.getlogin(),time.strftime('%X %x %Z'))             try:
125                   name=os.getlogin()
126                   out+="<hr><p align=\"center\">by %s at %s</p>\n"%(name,time.strftime('%X %x %Z'))
127               except OSError:
128                   out+="<hr><p align=\"center\">%s</p>\n"%(time.strftime('%X %x %Z'))
129                  
130             out+="</BODY></HTML>\n"             out+="</BODY></HTML>\n"
131         return out         return out
132    
# Line 184  class Benchmark(object): Line 189  class Benchmark(object):
189    
190         @param scale: defines the number of (OpenMP) threads to be used. If scale is a scalar all benchmarks         @param scale: defines the number of (OpenMP) threads to be used. If scale is a scalar all benchmarks
191                       are run with scale number of threads. If scale is a C{list}, the p-th problem in each of the benchmarks                       are run with scale number of threads. If scale is a C{list}, the p-th problem in each of the benchmarks
192                       in the suite is run with scale[p] threads. In the case, len(scale) has to be less or equal to the                       in the suite is run with scale[p] threads. If scale[p]<1 teh p-th problem is omitted.
                      largest benchmark in the suite.  
193         @type scale: C{int} or C{list} of C{int}s.         @type scale: C{int} or C{list} of C{int}s.
194         """         """
195         if isinstance(scale,list):         if isinstance(scale,list):
196             if len(scale)<len(self.__problems):             c_max=min(len(scale),len(self.__problems))
197                raise ValueError,"scale list is too small. must be greater or equal to the number of problems in the benchmark"         else:
198               c_max=len(self.__problems)
199         self.__filter=filter         self.__filter=filter
200         self.__scale=scale         self.__scale=scale
201         self.__results=[]         self.__results=[]
202         c=0         for c in range(c_max):
203         for r in self.__problems:            r=self.__problems[c]
204            if isinstance(scale,list):            if isinstance(scale,list):
205               s=scale[c]               s=scale[c]
206            else:            else:
207               s=scale               s=scale
208            row=[]            row=[]
209            for p in self.__options:            if s>0:
210                os.environ['OMP_NUM_TREADS']=str(s)                t0=time.time()
211                row.append(r.run(p))                print "%s with %s threads started."%(r.__class__,s)
212                  for p in self.__options:
213                      setNumberOfThreads(s)
214                      row.append(r.run(p))
215                  t0=time.time()-t0
216                  print "%s with %s threads finished (walltime =%s sec)."%(r.__class__,s,t0)
217            self.__results.append(row)            self.__results.append(row)
           c+=1  
218     def getHTML(self,filter,level=1):     def getHTML(self,filter,level=1):
219         """         """
220         returns the results of the last benchmark run in HTML format.         returns the results of the last benchmark run in HTML format.

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

  ViewVC Help
Powered by ViewVC 1.1.26