Thanks for reporting it. At first sight, it looks as if in 9.4, the first time substring() is called on a particular string, the code determines whether the string contains any non-BMP characters, and remembers this information for subsequent calls. In 9.5 it seems this optimization is not working. Are you using EE with bytecode generation for this test?

Substring has O(n) performance if it is not known whether the string contains non-BMP characters.

Michael Kay

On 26 May 2013, at 20:33, Gunther Rademacher wrote:

Thanks for Saxon! As I know there are some performance related
changes, I ran some new tests to see whether it will help my code to
achieve performance figures similar to those measured with
The tests brought up that fn:substring might be much more expensive
than it used to be. This small test will demonstrate:
    declare variable $n external;
      let $input := string-join(for $i in 1 to $n return "x", "")
      for $i in 1 to $n
      return substring($input, $i, 1)
For $n=100000, it  - attakes 6 seconds, and for $n=200000, it takes 25 seconds.
When run on, the times are 25 msec and 50 msec, respectively.
Best regards
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt!
saxon-help mailing list archived at