[MOAB-dev] r2942 - in MOAB/trunk/tools/iMesh/python: . doc perf

jvporter at wisc.edu jvporter at wisc.edu
Tue Jun 9 19:29:44 CDT 2009


Author: jvporter
Date: 2009-06-09 19:29:43 -0500 (Tue, 09 Jun 2009)
New Revision: 2942

Removed:
   MOAB/trunk/tools/iMesh/python/perf/Makefile
Modified:
   MOAB/trunk/tools/iMesh/python/doc/build.rst
   MOAB/trunk/tools/iMesh/python/doc/conf.py
   MOAB/trunk/tools/iMesh/python/setup.cfg.example
   MOAB/trunk/tools/iMesh/python/setup.py
Log:
* Remove platform-dependent performance test build stuff
* Bump up to PyTAPS v. 1.0


Modified: MOAB/trunk/tools/iMesh/python/doc/build.rst
===================================================================
--- MOAB/trunk/tools/iMesh/python/doc/build.rst	2009-06-09 22:53:05 UTC (rev 2941)
+++ MOAB/trunk/tools/iMesh/python/doc/build.rst	2009-06-10 00:29:43 UTC (rev 2942)
@@ -9,10 +9,10 @@
 
 The PyTAPS setup script supports importing definitions from the
 `iMesh-Defs.inc` file. In order to make use of this, specify the command-line
-options ``--imesh-dir=PATH`` to the `build_ext` command. For example, if your
-`iMesh-Defs.inc` is located in `/usr/local/iMesh/lib/iMesh-Defs.inc`, then
-``--imesh-dir`` should be `/usr/local/iMesh`.  This options may also be
-specified in the `setup.cfg` file:
+options ``--imesh-dir=PATH`` to the `build_ext` and `perf_build` commands. For
+example, if your `iMesh-Defs.inc` is located in
+`/usr/local/iMesh/lib/iMesh-Defs.inc`, then ``--imesh-dir`` should be
+`/usr/local/iMesh`.  This options may also be specified in the `setup.cfg` file:
 
 .. literalinclude:: ../setup.cfg.example
    :language: ini
@@ -43,6 +43,48 @@
 argument to `setup.py`. The test command also accepts a verbosity level (an
 integer), specified with ``-v`` or ``--verbosity``.
 
+Performance Testing
+===================
+
+To run performance tests on the package comparing the speed of a pure-C
+usage of ITAPS with PyTAPS, you may pass ``perf`` as a command to `setup.py`.
+The performance test requires an input file to test. You may also specify the
+number of times to repeat the tests::
+
+  python setup.py perf --file=/path/to/file --count=N
+
+The performance tests consist of two sub-commands, described below.
+
+Building the Performance Test
+-----------------------------
+
+This command builds the C portion of the performance tests. The following
+options are allowed:
+
++--------------------------+--------+---------------------------------------+
+| ``--include-dirs=PATHS`` | ``-I`` | list of directories to search for     |
+|                          |        | include files                         |
++--------------------------+--------+---------------------------------------+
+| ``--library-dirs=PATHS`` | ``-L`` | list of directories to search for     |
+|                          |        | library files                         |
++--------------------------+--------+---------------------------------------+
+| ``--libraries=LIBS``     | ``-l`` | list of libraries to link to          |
++--------------------------+--------+---------------------------------------+
+| ``--imesh-dir=PATH``     | N/A    | root location of iMesh implementation |
++--------------------------+--------+---------------------------------------+
+
+Running the Performance Test
+----------------------------
+
+This command executes the performance tests. The following options are allowed
+(as with ``perf``):
+
++-----------------+--------+-------------------------------------------+
+| ``--file=PATH`` | ``-F`` | file or directory containing test file(s) |
++-----------------+--------+-------------------------------------------+
+| ``--count=N``   | ``-c`` | number of times to repeat each test       |
++-----------------+--------+-------------------------------------------+
+
 Building Documentation
 ======================
 

Modified: MOAB/trunk/tools/iMesh/python/doc/conf.py
===================================================================
--- MOAB/trunk/tools/iMesh/python/doc/conf.py	2009-06-09 22:53:05 UTC (rev 2941)
+++ MOAB/trunk/tools/iMesh/python/doc/conf.py	2009-06-10 00:29:43 UTC (rev 2942)
@@ -47,7 +47,7 @@
 # The short X.Y version.
 version = '1.0'
 # The full version, including alpha/beta/rc tags.
-release = '1.0b1'
+release = '1.0'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.

Deleted: MOAB/trunk/tools/iMesh/python/perf/Makefile
===================================================================
--- MOAB/trunk/tools/iMesh/python/perf/Makefile	2009-06-09 22:53:05 UTC (rev 2941)
+++ MOAB/trunk/tools/iMesh/python/perf/Makefile	2009-06-10 00:29:43 UTC (rev 2942)
@@ -1,6 +0,0 @@
-all: perf.c
-	gcc -o perf perf.c -I/home/porterj/moab/include \
-	-L/home/porterj/moab/lib -L/usr/local/hdf5serial/lib \
-	-liMesh -lm -lgcc_s -lc -lMOAB -lnetcdf_c++ -lnetcdf -lhdf5 -lstdc++ \
-	-O2 -DNDEBUG -pthread -g -Wall -Wstrict-prototypes -fPIC \
-	-fno-strict-aliasing -fwrapv
\ No newline at end of file

Modified: MOAB/trunk/tools/iMesh/python/setup.cfg.example
===================================================================
--- MOAB/trunk/tools/iMesh/python/setup.cfg.example	2009-06-09 22:53:05 UTC (rev 2941)
+++ MOAB/trunk/tools/iMesh/python/setup.cfg.example	2009-06-10 00:29:43 UTC (rev 2942)
@@ -1,3 +1,5 @@
 [build_ext]
 include-dirs = /path/to/include
-imesh-dir = /path/to/imesh
\ No newline at end of file
+imesh-dir    = /path/to/imesh
+[perf_build]
+imesh-dir    = /path/to/imesh
\ No newline at end of file

Modified: MOAB/trunk/tools/iMesh/python/setup.py
===================================================================
--- MOAB/trunk/tools/iMesh/python/setup.py	2009-06-09 22:53:05 UTC (rev 2941)
+++ MOAB/trunk/tools/iMesh/python/setup.py	2009-06-10 00:29:43 UTC (rev 2942)
@@ -13,10 +13,8 @@
         post(self)
     return tmp
 
-def new_run(self):
-    if self.imesh_dir:
-        defs = parse_makefile( os.path.join(self.imesh_dir,
-                                            'lib/iMesh-Defs.inc') )
+def add_imesh_defs(imesh_dir, self):
+        defs = parse_makefile( os.path.join(imesh_dir, 'lib/iMesh-Defs.inc') )
 
         lib_match = re.compile(r'(?:(?<=\s)|^)-([lL])\s*(\S*)')
         for match in lib_match.finditer( defs['IMESH_LIBS'] ):
@@ -32,11 +30,16 @@
 def new_init(self):
     self.imesh_dir = None
 
-build_ext.user_options.append(('imesh-dir=', None, 'blah blah'))
-build_ext.initialize_options = pair_fun(new_init, build_ext.initialize_options)
-build_ext.run = pair_fun(new_run, build_ext.run)
+def new_fin(self):
+    if self.imesh_dir:
+        add_imesh_defs(self.imesh_dir, self)
 
+build_ext.user_options.append(('imesh-dir=', None,
+                               'root directory for iMesh interface'))
+build_ext.initialize_options = pair_fun(build_ext.initialize_options, new_init)
+build_ext.finalize_options   = pair_fun(build_ext.finalize_options,   new_fin)
 
+
 iBase = Extension('itaps.iBase',
                   depends      = ['common.h', 'iBase_Python.h'],
                   sources      = ['iBase.c']
@@ -50,9 +53,9 @@
                   )
 
 class TestCommand(Command):
-    description = 'Execute a variety of unit tests'
+    description = 'execute a variety of unit tests'
     user_options = [
-        ('verbosity=', 'v', 'verbosity level')
+        ('verbosity=', 'v', 'verbosity level'),
         ]
 
     def initialize_options(self):
@@ -83,10 +86,10 @@
 
 
 class DocCommand(Command):
-    description = 'Build documentation'
+    description = 'build documentation'
     user_options = [
         ('builder=', 'b', 'documentation builder'),
-        ('target=',  't', 'target directory')
+        ('target=',  't', 'target directory'),
         ]
 
     def initialize_options(self):
@@ -110,10 +113,10 @@
         os.chdir(old)        
 
 class PerfCommand(Command):
-    description = 'Execute performance tests'
+    description = 'build/execute performance tests'
     user_options = [
-        ('file=',  'f', 'test file'),
-        ('count=', 'c', 'number of times to test')
+        ('file=',  'F', 'file or directory containing test file(s)'),
+        ('count=', 'c', 'number of times to test'),
         ]
 
     def initialize_options(self):
@@ -130,17 +133,88 @@
             raise DistutilsOptionError('"count" option must be an integer')
 
     def run(self):
+        for cmd_name in self.get_sub_commands():
+            self.run_command(cmd_name)
+
+    sub_commands = [
+        ('perf_build', None),
+        ('perf_run',   None),
+        ]
+
+class PerfBuildCommand(Command):
+    description = 'build performance tests'
+
+    sep_by = " (separated by '%s')" % os.pathsep
+    user_options = [
+        ('include-dirs=', 'I',
+         'list of directories to search for header files' + sep_by),
+        ('libraries=', 'l',
+         'external C libraries to link with'),
+        ('library-dirs=', 'L',
+         'directories to search for external C libraries' + sep_by),
+        ('imesh-dir=', None, 'root directory for iMesh interface'),
+        ]
+
+    def initialize_options(self):
+        self.include_dirs = []
+        self.library_dirs = []
+        self.libraries = []
+        self.imesh_dir = None
+
+    def finalize_options(self):
+        if self.imesh_dir:
+            add_imesh_defs(self.imesh_dir, self)
+
+    def run(self):
         root = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
                                              '../perf'))
         old = os.getcwd()
+        os.chdir(root)
 
+        from distutils.ccompiler import new_compiler
+        self.compiler = new_compiler()
+
+        objs = self.compiler.compile(['perf.c'], include_dirs=self.include_dirs)
+        self.compiler.link_executable(objs, 'perf',
+                                      library_dirs=self.library_dirs,
+                                      libraries=self.libraries)
+
+        os.chdir(old)
+
+class PerfRunCommand(Command):
+    description = 'execute performance tests'
+    user_options = [
+        ('file=',  'F', 'file or directory containing test file(s)'),
+        ('count=', 'c', 'number of times to test'),
+        ]
+
+    def initialize_options(self):
+        self.file = None
+        self.count = 20
+
+    def finalize_options(self):
+        self.set_undefined_options('perf',
+                                   ('file', 'file'),
+                                   ('count', 'count') )
+
+        if not self.file:
+            raise DistutilsOptionError('"file" must be specified')
+
+        try:
+            self.count = int(self.count)
+        except ValueError:
+            raise DistutilsOptionError('"count" option must be an integer')
+
+    def run(self):
+        root = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
+                                             '../perf'))
+        old = os.getcwd()
         os.chdir(root)
-        os.system('make all')
         os.system('python perf.py -c%d "%s"' % (self.count, self.file))
-        os.chdir(old)
+        os.chdir(old) 
 
 setup(name = 'PyTAPS',
-      version = '1.0b1',
+      version = '1.0',
       description = 'Python bindings for iBase and iMesh interfaces',
       author = 'Jim Porter',
       author_email = 'jvporter at wisc.edu',
@@ -153,7 +227,10 @@
       ext_modules = [iBase, iMesh],
       py_modules = ['itaps.helpers'],
 
-      cmdclass = { 'test' : TestCommand,
-                   'doc'  : DocCommand,
-                   'perf' : PerfCommand }
+      cmdclass = { 'test'       : TestCommand,
+                   'doc'        : DocCommand,
+                   'perf'       : PerfCommand,
+                   'perf_build' : PerfBuildCommand,
+                   'perf_run'   : PerfRunCommand
+                   }
       )



More information about the moab-dev mailing list