Skip to main content

Performance checkpoint

Challenge on lesson: Checkpoint: performance

CHALLENGE
Difficulty: advanced+25 XP

Two implementations are provided in the harness: SlowPath concatenates strings in a loop; FastPath uses string.Create. Implement static string RepeatChar(char c, int n) that builds an n-char string of c using string.Create (zero intermediate allocations), and static long Measure(Func<int> work, int iterations) that returns total allocated bytes across iterations invocations with ONE warmup call first (the warmup is graded: without it the JIT's first-call allocations corrupt the result).

Back to lesson: Checkpoint: performance