Version 6 (modified by vadim.godunko, 11 years ago) ( diff )



Implementation of Universal_String use several techniques to speedup performance and minimize memory footprint:

  • string data stored in UTF-16 encoded form internally, so it occupies two times less memory then Wide_Wide_String for most modern languages.
  • use of implicit sharing (also known as copy-on-write) technology allows Universal_String to have constant time of assignment operation.
  • use of atomic operations to handle reference counter makes Universal_String as safe in multitasking context as other Ada types.
  • use of special algorithms and utilization of SIMD operations (when available) significantly improve performance.

Performance comparison

Here is comparison of performance between Ada.Strings.Wide_Unbounded and League.Strings packages. Number is a speedup of operations on Universal_String comparing to corresponding operation on Unbounded_Wide_String.

Operation GNAT GPL 2010/League GNAT GPL 2010/League
(portable, 64 bits) (x86_64)
(1/10/100/1000/10000 bytes) (1/10/100/1000/10000 bytes)
Object initialization 1.57 1.53
Assignment of empty string 1.91 1.84
Assignment of non-empty string 1.03 1.06
Compare for equality 4.63/6.40/9.46/11.76/11.88 4.12/6.56/15.49/19.95/15.09
Compare for less 1.16/1.02/1.56/1.50/1.50 1.08/1.09/2.55/3.55/2.79
Append of string 1.30 1.30
Note: See TracWiki for help on using the wiki.