using System; using System.Linq; using System.Text; namespace Glass.PerformanceTests { /// /// Texts written for the benchmark, each aimed at a different cost of laying text out. /// public static class Texts { public const string Label = "Save changes"; /// /// As short as a real label gets, to find the floor of whatever per-call setup cost doesn't shrink with /// the text. /// public const string TinyLabel = "OK"; /// /// A short CJK phrase, comparable in length to : CJK prose's per-ideograph break /// opportunities and a short text's fixed setup cost are two separate weaknesses: this isolates whether /// they compound. /// public const string CjkLabel = "清晨的集市总是最热闹的时候。"; /// /// About a kilobyte of English prose with the punctuation real text has: quotes, dashes, an ellipsis, /// parentheses, hyphenated words, times, and a hard line break. /// public const string Prose = "The caravan left Tarsis at dawn — forty wagons, a hundred mules, and more merchants than anyone " + "cared to count. By noon the road had narrowed to a ribbon of dust, and the scouts (two brothers from " + "the coast, both half-deaf) reported riders to the east. \"Bandits?\" asked the quartermaster. " + "Nobody answered; nobody needed to. They'd all heard the stories: villages emptied overnight, " + "well-guarded convoys found scattered across the flats, their cargo gone and their oxen slaughtered. " + "Still, the pay was good… very good, in fact, for a three-week journey to the salt mines of Vey.\n" + "Captain Méra ordered the wagons into a ring. \"Nobody sleeps tonight,\" she said, checking the " + "powder in her pistol for the third time. \"If they come, they come at moonrise — that's how " + "the old raiders did it, and these ones learned from the old raiders.\" The mules brayed; somewhere " + "a child laughed, then was hushed. Fires were banked low. Watchmen took their posts at 9:00, 11:30 " + "and 2:00, with orders to fire once for riders and twice for anything else."; /// /// The prose repeated out to about 20 KB, for how cost scales with length. /// public static readonly string Document = string.Join("\n\n", Enumerable.Repeat(Prose, 20)); /// /// Chinese prose, where every ideograph is a break opportunity. /// public const string CjkProse = "清晨的集市总是最热闹的时候。" + "卖菜的老人把新鲜的白菜和萝卜整齐地摆在竹筐里," + "旁边的年轻人正在大声招呼过往的行人。" + "远处传来自行车的铃声,孩子们背着书包从小巷里跑出来,手里还拿着刚买的包子。" + "一位穿蓝色外套的女士停在水果摊前,仔细挑选着苹果和橘子," + "摊主笑着说今天的橘子特别甜。" + "太阳慢慢升高,街道上的人越来越多,空气中弥漫着豆浆和油条的香味。" + "到了中午,集市渐渐安静下来,商贩们开始收拾摊位,准备回家吃饭。"; /// /// About a kilobyte of game UI text dense with numbers: ratios, percentages, prices, times, dates, negative /// numbers, ranges and coordinates, where UAX #14's number rules (LB23 to LB25) do most of the work. /// public const string Numbers = "Level 42 (XP 12,450/15,000, 83%)\n" + "HP: 125/300 MP: 48/60 Stamina: 97.5% Armor: +14 Speed: -3\n" + "Gold: $1,284.50 Gems: 36 Keys: 3 Bounty: €2,500 or £1,950\n" + "Day 214, 09:45 (2026-09-24) Temperature: 21°C Wind: 12–18 km/h\n" + "Position: (1,024.5, -377.25) Depth: 3.2m Heading: 270°\n" + "Crafting: 3× iron ingot (12 kg), 2× oak plank (4.5 kg) = 45.0 kg total\n" + "Market: wheat 12.40 → 13.15 (+6.05%), ore 88.00 → 81.20 (-7.73%), silk 240.00 (0.00%)\n" + "Rank: 1st of 1,024; streak 17 days; best run 00:42:17.350; last run 00:45:02.118\n" + "Damage: 350–420 (x1.5 crit, 25% chance); DPS 612.8; resist 15/15/15/40\n" + "Quest 7 of 12: deliver 250 crates by 18:00 on day 216, reward 1,500g + 3 reputation\n" + "Inventory: 48/60 slots, 312.75/400.00 kg, repair cost 1,240g (-15% guild discount)\n" + "Population: 12,408 (+3.2% this week); taxes 4.5%; upkeep 2,310g/day; reserves 48,260g\n" + "Caravan 3/5: 40 wagons, 112 mules, ETA 2d 06h (84.5 km at 1.6 km/h); insurance 7.5% ($3,120)\n" + "Trade log: bought 1,200 salt @ 0.85 = 1,020.00; sold 950 @ 1.12 = 1,064.00; net +44.00 (4.3%)"; public static string BuildHexRun(int length) { var random = new Random(1); var returnMe = new StringBuilder(length); while (returnMe.Length < length) { returnMe.Append("0123456789abcdef"[random.Next(16)]); } return returnMe.ToString(); } /// /// Letters and digits with no break opportunity anywhere, like a hash or a key pasted into a label, so every /// line of it is a forced split. /// public static readonly string HexRun = BuildHexRun(512); } }