Menu

Performance?

Anonymous
2006-09-04
2013-04-19
  • Anonymous

    Anonymous - 2006-09-04

    Is there a considerable performance hit for using functor based methodology?  I ask because I'm trying to reduce the "verbosity" of Java using functional programming techniques.

    Owen  http://backspaces.net/

     
    • Fred Daoud

      Fred Daoud - 2006-09-20

      When defining functions by implementing the interfaces, there isn't a significant difference in performance. However, using reflection does impact performance. In some cases, using the cglib implementation of reflection can improve performance.

      Frederic Daoud

       
      • Anonymous

        Anonymous - 2006-09-22

        Thanks for the clarification.

        My only performance concern is that if possible, reflection is used only once for a given collection iteration. 

        I am looking at large lists .. probably 50,000 on average.  If the reflection overhead only occurred once at the start of the iteration, and reused during the 50K instances, then the cost would be minimal.  But if reflection was used for each of the 50K instances in the list, its would be too great an overhead.

        Owen

         
        • Fred Daoud

          Fred Daoud - 2006-09-22

          Hi Owen,

          In your scenario, you would use the CgLibStdReflect mechanism (http://functionalj.sourceforge.net/javadocs-0.8-jdk15/info/javelot/functionalj/reflect/impl/CglibStdReflect.html)

          Let me clarify: you would be using cglib for reflection (make sure to include the cglib jar file in your classpath, either the one included in the FunctionalJ distribution or a compatible one from the cglib web site, http://cglib.sf.net\), and the StdReflect mechanism. This combination achieves what you described: the performance hit would only be when creating the function. Afterwards, no reflection to find the method would need to be done each time you call the function. Furthermore, cglib performance is superior to the JDK and this shows especially when calling the same reflected method many times.

          Hope this helps you. Thank you for your interest in FunctionalJ.

          Best regards,
          Frederic

           

Log in to post a comment.