Thanks Thorsten.

I haven't dug into the source yet but my guess would be that mksh is
performing numerous (re)allocations to make space for appended data,
rather than using a more optimistic (but space consuming) method, e.g.
growing the target buffer size to double its current requirement.

-- 
You received this bug notification because you are a member of mksh
Mailing List, which is subscribed to mksh.
Matching subscriptions: mkshlist-to-mksh-bugmail
https://bugs.launchpad.net/bugs/1855167

Title:
  Comparatively poor += performance

Status in mksh:
  Confirmed

Bug description:
  Heavy use of += notably impacts script performance.  Consider the
  following micro-benchmark (pattered after real script content):

      i=0 s=
      while ((i < 30000)); do
        ((++i))
        s+=$i
      done

  which creates 138,894 character long string.  On my system (macOS
  10.14.6, 3.5 GHz i7), this takes ~8 seconds in mksh, compared with
  ksh's ~0.1s and bash 5's ~0.3s.  Here're `real' timing figures from
  my most recent run (these figures are quite stable):

  - mksh r57: 0m8.17s
  - ksh 93u+ 2012-08-01: 0m0.10s
  - bash 5.0.11(1)-release: 0m0.30s

  It's no surprise that ksh93 is much faster, given its heavy
  optimisation.  Striking, though, is the poor performance of mksh
  relative to the latest bash.

To manage notifications about this bug go to:
https://bugs.launchpad.net/mksh/+bug/1855167/+subscriptions

Reply via email to