Uploaded image for project: 'Velocity'
  1. Velocity
  2. VELOCITY-979

Performance issue with comparing strings in Velocity

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.3
    • None
    • Engine
    • None

    Description

      Most Velocity compare expressions eventually use ASTComparisonNode which at first attempts to treat data types as numbers:

       
      Boolean result = compareNumbers(left, right);
      if (result == null)

      { result = compareNonNumber(left, right); }

       
      There is fairly large overhead when attempting to create BigDecimal from non-numeric strings used in comparison in the DuckType.asNumber:
       
      if (coerceType)
      {
      String string = asString(value);// coerce to string
      if (string != null)

      { return new BigDecimal(string); }

      }
       
      The exception is created capturing stack, etc. On large volume of compare operations it's very visible.
       

      Attachments

        Activity

          People

            Unassigned Unassigned
            a701440 Alex
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: