Uploaded image for project: 'Commons JEXL'
  1. Commons JEXL
  2. JEXL-186

Performance regression in arithmetic operations compared to JEXL 2.1

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0
    • Fix Version/s: 3.1
    • Labels:
      None

      Description

      Compared to JEXL 2.1.1, arithmetic operations are slower in 3.0.

      The culprit is the logic around operators overloading; when the JexlArithmetic does not overload any operator, discovering whether it overloads one is repeated each time an interpreter is created (which is a costly introspection operation).

      As a workaround, one ca use an arithmetic that does overload an operator (for instance size) as in:

          public static class JMeterArithmetic extends JexlArithmetic {
              public JMeterArithmetic(boolean astrict) {
                  super(astrict);
              }
      
              /**
               * A workaround to create an operator overload
               * @param jma an improbable parameter class
               * @return 1
               */
              public int size(JMeterArithmetic jma) {
                  return 1;
              }
          }
      

      And use an instance of that class at engine creation time as in:

              JexlEngine jexl = new JexlBuilder()
                          .cache(512)
                          .silent(true)
                          .strict(true)
                          .arithmetic(new JMeterArithmetic(true))
                          .create();
      

        Attachments

        1. PerfJexl2.java
          0.9 kB
          Henri Biestro
        2. PerfJexl2.java
          2 kB
          Philippe Mouawad
        3. PerfJexl3.java
          1 kB
          Henri Biestro
        4. PerfJexl3.java
          2 kB
          Philippe Mouawad

          Activity

            People

            • Assignee:
              henrib Henri Biestro
              Reporter:
              p.mouawad@ubik-ingenierie.com Philippe Mouawad
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: