ZSTRING (ISO-8859-15) v STRING_32

Date: 3 Dec 2023

Benchmark Source Code

Input Test Data

See table below

$A = column A string is short latin
$B = column B string is short mix of unicode and latin
$C = column C string is 1 or 2 characters of Chinese unicode
$D = column D string is long latin string

Memory Consumption

Pure Latin-15 Encoding

Table 1 (In ascending order of relative STRING_32 performance)
Concatenated lines Input ZSTRING STRING_32
Lines 1 to 64"$A $D"-75%22752 bytes
First line only"$A $D"-55%352 bytes

Mixed Latin-15 and Unicode Encoding

Table 2 (In ascending order of relative STRING_32 performance)
Concatenated lines Input ZSTRING STRING_32
Lines 1 to 64"$A $B $C $D"-68%24960 bytes
First line only"$A $B $C $D"-46%384 bytes
Lines 1 to 64"$B"-45%1472 bytes
First line only"$B"-14%112 bytes
First line only"$C"+33%96 bytes
Lines 1 to 64"$C"+39%832 bytes

Runtime Performance

Each test iterates over 64 table rows and the number of executions in 500 ms is recorded
(The higher the number the better the performance)

Pure Latin-15 Encoding

Table 3 (In ascending order of relative STRING_32 performance)
String routines Input ZSTRING STRING_32
replace_character"$D"1257-85%
to_utf_8"$A $D"12878-85%
append_string_generalA,D4910-82%
append_utf_8A,D13340-75%
as_string_8"$A $D"9799-64%
prepend_string_generalA,D5021-64%
to_upper"$A $D"9586-62%
to_lower"$A $D"9131-58%
translateD1339-55%
starts_withD17239-47%
escaped (as XML)put_amp (D)353-9%
code (z_code)"$A $D"43884386
last_index_ofD3253432536
index_ofD45968+6%
starts_with_generalD8298+8%
substring_index"$A $D"1517+9%
is_less (sort)D4219+11%
insert_stringD9423+13%
item"$A $D"1355+18%
ends_with_generalD8083+20%
prepend_stringA,D9913+20%
split, substring"$A $D"1236+22%
is_equalD14893+23%
append_stringA,D10036+26%
prune_all"$A $D"8522+28%
replace_substringD7845+30%
remove_substringD11978+31%
ends_withD19026+32%
unescape (C lang string)escaped (D)1872+43%
left_adjustpadded (A)14991+44%
right_adjustpadded (A)14422+47%
replace_substring_allD1301+71%
as_string_32"$A $D"14532+80%

Mixed Latin-15 and Unicode Encoding

Table 4 (In ascending order of relative STRING_32 performance)
String routines Input ZSTRING STRING_32
append_string_generalA,B,C,D1868-54%
to_upper"$A $B $C $D"6333-47%
to_lower"$A $B $C $D"5962-42%
to_utf_8"$A $B $C $D"2637-37%
escaped (as XML)put_amp ("$B $C")932-5%
last_index_of"$B $C"36237+3%
code (z_code)"$A $B $C $D"3669+9%
is_less (sort)B3878+12%
replace_character"$B $C"2350+14%
item"$A $B $C $D"1202+20%
translate"$B $C"3164+23%
prepend_string_generalA,B,C,D1199+24%
substring_index"$B $C $A"1866+25%
split, substring"$A $B $C $D"914+29%
item"$B $C"11435+32%
substring_index"$A $B $C"1802+32%
index_of"$B $C"35198+34%
code (z_code)"$B $C"22785+41%
starts_with"$B $C $A"11904+44%
left_adjustpadded (C)14191+46%
right_adjustpadded (C)11564+56%
append_utf_8"$B $C"5484+57%
remove_substring"$A $B $C"9517+57%
append_stringA,B,C,A,B,C3117+60%
unescape (C lang string)escaped ("$B $C")5981+60%
ends_with"$A $B $C"11564+61%
is_equal"$A $B $C"11192+66%
starts_with_general"$B $C $A"5704+72%
ends_with_general"$A $B $C"5515+73%
prune_all"$B $C"4951+73%
prepend_stringA,B,C,A,B,C1706+75%
insert_string"$B $C"3156+76%
as_string_32"$A $B $C $D"13603+81%
replace_substring"$A $B $C"2993+83%
replace_substring_all"$A $B $C"1169+85%

I Ching Hexagram Test Strings

Table 5
A B C D
Hex. #1QiánThe Creative, Creating, Pure Yang, Inspiring Force, Dragon
Hex. #2KūnThe Receptive, Accepting, Pure Yin, Field, Yielding
Hex. #3ZhūnDifficulty at the Beginning, Rallying, Birth Throes, Sprouting, The World Tree
Hex. #4MéngYouthful Folly, Inexperience, Juvenile Ignorance, Enveloping, Royal Maiden
Hex. #5Waiting, Nourishment, Anticipation, Attending
Hex. #6SòngConflict, Contention, Dispute, Pleading
Hex. #7ShīThe Army, The Militia, Legions, Leader
Hex. #8Holding Together, Union, Belonging, Closeness, Grouping, Calling the Spirits
Hex. #9Xiǎo Chù小畜Small Accumulates, The Taming Power of the Small, Raising Small Beasts, Lesser Domestication, Gathering the Ghosts
Hex. #10Treading, Conduct, Respectful Conduct, Fulfillment, Mating with the Tiger
Hex. #11TàiPeace, Interplay, Pervading, Great Rituals
Hex. #12Standstill, Stagnation, Separating, Obstruction, Stop! Obstruction
Hex. #13Tóng Rén同人Fellowship with Men, Fellowship with Others, Fellowship, Harmonizing People
Hex. #14Dà Yǒu大有Possession in Great Measure, Big Domain, Great Holdings, Great Being, Great Possessions
Hex. #15QiānModesty, Authenticity, Humbling, The Grey One
Hex. #16Enthusiasm, Readiness, Contentment, Providing For, Riding the Elephant
Hex. #17SuíFollowing
Hex. #18Work on What Has Been Spoiled, Decay, Detoxifying, Ills to Be Cured, Corruption, Pestilence, Renovating
Hex. #19LínApproach, Taking Charge, Overseeing, Nearing
Hex. #20GuānContemplation, View, Viewing, Perspective
Hex. #21Shì Kè噬嗑Biting Through, Bite Together, The Sacred Meal
Hex. #22Grace, Adornment, Elegance, Adorning, Bringing Home the Bride
Hex. #23Splitting Apart, Decomposing, Peeling, Stripping
Hex. #24Return, Returning, The Turning Point
Hex. #25Wú Wàng無妄Innocence, The Unexpected, Without Pretense, No Errancy, Disentangling
Hex. #26Dà Chù大畜The Taming Power of the Great, Raising Great Beasts, Great Domestication, Great Accumulates, Gathering the Spirit
Hex. #27The Corners of the Mouth, Providing Nourishment, Hungry Mouth, Nourishment, Jaws, The Tiger's Mouth
Hex. #28Dà Guò大過Preponderance of the Great, Greatness in Excess, Major Superiority, Great Traverses
Hex. #29KǎnThe Abysmal, Water, Exposure, The Constant Sink Hole, Repeating Pit, Ghost River
Hex. #30The Clinging, Fire, Arising, Cohesion, Radiance, Bright Omens
Hex. #31XiánInfluence, Wooing, Reciprocity, Conjoining, Uniting in Spirit
Hex. #32HéngDuration, Continuity, Perseverance, Fixing the Omen, Persevering
Hex. #33DùnRetreat, Distancing, Withdrawl, Retiring, Young Pig
Hex. #34Dà Zhuàng大壯The Power of the Great, Big and Strong, Great Strength, Great Invigorating Strength
Hex. #35JìnProgress, Expansion, Advance, Flourishing, A Rising Sun
Hex. #36Míng Yí明夷Darkening of the Light, Brightness Obscured, Suppression of the Light, Brightness Hiding, Calling Bird
Hex. #37Jiā Rén家人The Family, The Clan, Family Members, Dwelling People
Hex. #38KuíOpposition, Estrangement, Contrariety, Diverging, The Shadow Lands
Hex. #39JiǎnObstruction, Impasse, Adversity, Limping, Difficulties
Hex. #40XièDeliverance, Release, Loosening
Hex. #41SǔnDecrease, Decreasing, Diminution, Diminishing, The Offering
Hex. #42Increase, Increasing, Augmenting, The Blessing
Hex. #43GuàiBreak-through, Resoluteness, Decisiveness, Resolution, Deciding and Parting
Hex. #44GòuComing to Meet, Dissipation, Encounter, Coupling, Royal Bride
Hex. #45CuìGathering Together, Gathering, Gathering Them, Massing, Collectedness, Great Works
Hex. #46ShēngPushing Upward, Advancement, Climbing, Ascending the Sacred Mountain
Hex. #47KùnOppression, Exhaustion, Impasse, Confining
Hex. #48JǐngThe Well
Hex. #49Revolution, Molting, Seasonal Change, Radical Change, Skinning
Hex. #50DǐngThe Cauldron, The Vessel, Transformation
Hex. #51ZhènThe Arousing, Shock, Thunder, Arousal, Quake, Shake, Rousing
Hex. #52GènKeeping Still, Mountain, Stillness, Restraint, Bound, Stilling
Hex. #53JiànDevelopment, Gradual Progress, Gradual Advance, Marrying Woman
Hex. #54Guī Mèi歸妹The Marrying Maiden, Marrying the Maiden, Little Sister's Marriage
Hex. #55FēngAbundance, Fullness, Abounding, Receiving the Mandate
Hex. #56Treading, Conduct, Respectful Conduct, Mating with the Tiger
Hex. #57XùnThe Gentle, The Penetrating, Wind, Adaptation, Compliance, Subtle Penetration, Spreading the Fates
Hex. #58DuìThe Joyous, Lake, Satisfaction, Joy, Open, Expression
Hex. #59HuànDispersion, Dissolution, Scattering, Dispersing, Gushing
Hex. #60JiéLimitation, Boundaries, Control, Articulating the Crossings
Hex. #61Zhōng Fú中孚Inner Truth, The Truth Within, Inner Trust, Centring and Connecting
Hex. #62Xiǎo Guò小過Preponderance of the Small, Smallness in Excess, Minor Superiority, Small Traverses, The Flying Bird
Hex. #63Jì Jì既濟After Completion, Already Complete, Ferrying Complete, Already Crossing
Hex. #64Wèi Jì未濟Before Completion, Not Yet Complete, Ferrying Incomplete, Not Yet Crossing