ZSTRING (ISO-8859-1) 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-1 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-1 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"+38%848 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-1 Encoding

Table 3 (In ascending order of relative STRING_32 performance)
String routines Input ZSTRING STRING_32
replace_character"$D"1306-87%
to_utf_8"$A $D"12593-85%
append_string_generalA,D5212-83%
append_utf_8A,D13129-75%
as_string_8"$A $D"12934-75%
to_upper"$A $D"9602-64%
to_lower"$A $D"9443-63%
prepend_string_generalA,D4879-63%
translateD1322-53%
starts_withD17743-49%
last_index_ofD34818-7%
escaped (as XML)put_amp (D)329-1%
code (z_code)"$A $D"44114411
item"$A $D"16721679
index_ofD48684+2%
starts_with_generalD8581+5%
is_less (sort)D4267+7%
substring_index"$A $D"1573+9%
insert_stringD8603+10%
prune_all"$A $D"9162+14%
ends_with_generalD7974+16%
replace_substringD7961+20%
remove_substringD11869+24%
is_equalD14317+25%
prepend_stringA,D9667+25%
append_stringA,D10325+26%
ends_withD19785+26%
split, substring"$A $D"1199+26%
left_adjustpadded (A)13390+40%
right_adjustpadded (A)13565+40%
unescape (C lang string)escaped (D)1873+42%
replace_substring_allD1341+70%
as_string_32"$A $D"15153+80%

Mixed Latin-1 and Unicode Encoding

Table 4 (In ascending order of relative STRING_32 performance)
String routines Input ZSTRING STRING_32
append_string_generalA,B,C,D1997-57%
to_upper"$A $B $C $D"6420-51%
to_lower"$A $B $C $D"6172-48%
to_utf_8"$A $B $C $D"2689-40%
escaped (as XML)put_amp ("$B $C")960-14%
last_index_of"$B $C"39200-8%
item"$A $B $C $D"14831481
code (z_code)"$A $B $C $D"3772+6%
is_less (sort)B3889+7%
replace_character"$B $C"2410+7%
item"$B $C"13269+21%
prepend_string_generalA,B,C,D1226+22%
translate"$B $C"3054+24%
substring_index"$B $C $A"1961+25%
index_of"$B $C"35190+31%
substring_index"$A $B $C"1900+31%
code (z_code)"$B $C"23884+35%
split, substring"$A $B $C $D"877+35%
left_adjustpadded (C)13408+39%
starts_with"$B $C $A"12407+41%
right_adjustpadded (C)11405+46%
remove_substring"$A $B $C"9315+53%
ends_with"$A $B $C"12444+56%
append_stringA,B,C,A,B,C3305+58%
append_utf_8"$B $C"5477+59%
unescape (C lang string)escaped ("$B $C")5793+62%
is_equal"$A $B $C"11922+63%
prune_all"$B $C"5342+66%
ends_with_general"$A $B $C"5501+72%
insert_string"$B $C"3027+72%
starts_with_general"$B $C $A"5858+72%
prepend_stringA,B,C,A,B,C1635+77%
replace_substring"$A $B $C"2954+80%
as_string_32"$A $B $C $D"14247+81%
replace_substring_all"$A $B $C"1147+84%

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