On 6 fév, 15:31, Ben Noordhuis <i...@bnoordhuis.nl> wrote: > On Mon, Feb 6, 2012 at 14:46, Etienne <et.mara...@gmail.com> wrote: > > Hi, > > > In a Pyramid (web framework in Python) web application, I compile a C+ > > + library with SWIG and the program runs in 10s. > > > I would like to migrate the application to node.js (0.6.5) and I have > > put the library without change in a node-addon, that I compile with > > node-waf. > > The file wscript: > > def set_options(opt): > > opt.tool_options("compiler_cxx") > > > def configure(conf): > > conf.check_tool("compiler_cxx") > > conf.check_tool("node_addon") > > > def build(bld): > > obj = bld.new_task_gen("cxx", "shlib", "node_addon") > > obj.target = "serie" > > obj.source = "serie.cc" > > > The program runs in 20s. > > Have you any idea for that slowness? That occurs on my personnal > > computer (mac os x snow Leopard) and also on the Webfaction server on > > linux (node 0.6.5 also). > > Etienne, you need to provide a lot more detail. What kind of C++ > library is it, how and with what compiler flags did you compile it, > have you profiled it, etc.
That is a small library with 2 main functions written in C. The first dealing 52 cards with tests, and the second one is a loop which generates a list of deals. In 10s, the program generate 4000000 deals with pyramid and 2000000 with node. Here ara the flags for the various compilations: 1/ distutils call GCC42 on mac os x snow Leopard: /usr/bin/gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -O2 - DNDEBUG -g -fwrapv -O3 -Wall 2/ node waf call g++ on mac os x snow Leopard: env {'CCFLAGS_MACBUNDLE': ['-fPIC'], 'program_PATTERN': '%s', 'CPPPATH_NODE': '/usr/local/Cellar/node/0.6.5/include/node', 'CXX_SRC_F': '', 'LIBPATH_ST': '-L%s', 'DEST_CPU': 'x86_64', 'CXXFLAGS': ['-g'], 'CPPFLAGS_NODE': ['-D_GNU_SOURCE'], 'LIBPATH_NODE': '/usr/local/Cellar/node/0.6.5/lib', 'CPP': '/usr/bin/ cpp', 'ARFLAGS': 'rcs', 'SHLIB_MARKER': '', 'CXXFLAGS_DEBUG': ['-g'], 'CPPPATH_ST': '-I%s', 'LIBDIR': '/Users/rouqui/.node_libraries', 'SONAME_ST': '', 'STATICLIB_ST': '-l%s', 'PREFIX_NODE': '/usr/local/ Cellar/node/0.6.5', 'RPATH_ST': '-Wl,-rpath,%s', 'CC_VERSION': ('4', '2', '1'), 'LIB_ST': '-l%s', 'CXX_TGT_F': ['-c', '-o', ''], 'CXXLNK_SRC_F': '', 'FULLSTATIC_MARKER': '-static', 'LINK_CXX': ['/usr/ bin/g++'], 'CXXLNK_TGT_F': ['-o', ''], 'CXXFLAGS_RELEASE': ['-O2'], 'STATICLIB_MARKER': '', 'RANLIB': '/usr/bin/ranlib', 'AR': '/usr/bin/ ar', 'staticlib_PATTERN': 'lib%s.a', 'staticlib_LINKFLAGS': [], 'CXXDEFINES_ST': '-D%s', 'shlib_LINKFLAGS': ['-dynamiclib'], 'CXXFLAGS_NODE': ['-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64'], 'CXX_NAME': 'gcc', 'LINKFLAGS_MACBUNDLE': ['-bundle', '-undefined', 'dynamic_lookup'], 'CXX': ['/usr/bin/g++'], 'COMPILER_CXX': 'g++', 'STATICLIBPATH_ST': '-L%s', 'PREFIX': '/usr/local', 'DEST_OS': 'darwin', 'NODE_PATH': '/Users/rouqui/.node_libraries', 'shlib_CXXFLAGS': ['-fPIC', '-compatibility_version', '1', '- current_version', '1'], 'shlib_PATTERN': 'lib%s.dylib', 'macbundle_PATTERN': '%s.bundle', 'CCFLAGS': ['-g'], 'CCFLAGS_NODE': ['-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64']} 3/ distutils on webfaction server gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe -Wall -Wp,- D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer- size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables - D_GNU_SOURCE -fPIC -fPIC 4/ node-waf on webfaction server {'CCFLAGS_MACBUNDLE': ['-fPIC'], 'program_PATTERN': '%s', 'CPPPATH_NODE': '/home/emarache/include/node', 'CXX_SRC_F': '', 'LIBPATH_ST': '-L%s', 'DEST_CPU': 'x86', 'CXXFLAGS': ['-g'], 'CPPFLAGS_NODE': ['-D_GNU_SOURCE'], 'LIBPATH_NODE': '/home/emarache/ lib', 'CPP': '/usr/bin/cpp', 'ARFLAGS': 'rcs', 'SHLIB_MARKER': '-Wl,- Bdynamic', 'CXXFLAGS_DEBUG': ['-g'], 'CPPPATH_ST': '-I%s', 'LIBDIR': '/ home/emarache/.node_libraries', 'SONAME_ST': '-Wl,-h,%s', 'STATICLIB_ST': '-l%s', 'PREFIX_NODE': '/home/emarache', 'RPATH_ST': '- Wl,-rpath,%s', 'CC_VERSION': ('4', '1', '2'), 'DEST_BINFMT': 'elf', 'LIB_ST': '-l%s', 'CXX_TGT_F': ['-c', '-o', ''], 'CXXLNK_SRC_F': '', 'FULLSTATIC_MARKER': '-static', 'LINK_CXX': ['/usr/bin/g++'], 'CXXLNK_TGT_F': ['-o', ''], 'CXXFLAGS_RELEASE': ['-O2'], 'STATICLIB_MARKER': '-Wl,-Bstatic', 'RANLIB': '/usr/bin/ranlib', 'AR': '/usr/bin/ar', 'staticlib_PATTERN': 'lib%s.a', 'staticlib_LINKFLAGS': ['-Wl,-Bstatic'], 'CXXDEFINES_ST': '-D%s', 'shlib_LINKFLAGS': ['- shared'], 'CXXFLAGS_NODE': ['-D_LARGEFILE_SOURCE', '- D_FILE_OFFSET_BITS=64'], 'CXX_NAME': 'gcc', 'LINKFLAGS_MACBUNDLE': ['- bundle', '-undefined', 'dynamic_lookup'], 'CXX': ['/usr/bin/g++'], 'COMPILER_CXX': 'g++', 'STATICLIBPATH_ST': '-L%s', 'PREFIX': '/usr/ local', 'DEST_OS': 'linux', 'NODE_PATH': '/home/ emarache/.node_libraries', 'shlib_CXXFLAGS': ['-fPIC', '-DPIC'], 'shlib_PATTERN': 'lib%s.so', 'macbundle_PATTERN': '%s.bundle', 'CCFLAGS': ['-g'], 'CCFLAGS_NODE': ['-D_LARGEFILE_SOURCE', '- D_FILE_OFFSET_BITS=64']} -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en