Skip to content

Commit d335ca4

Browse files
authored
Use Magna Carta instead of The Financier (#42095)
1 parent dd40539 commit d335ca4

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

docs/standard/base-types/best-practices-regex.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ To summarize, we recommend that you:
122122

123123
It's difficult to determine the exact threshold at which the slower execution speeds of interpreted regular expressions outweigh gains from their reduced startup time. It's also difficult to determine the threshold at which the slower startup times of source-generated or compiled regular expressions outweigh gains from their faster execution speeds. The thresholds depend on various factors, including the complexity of the regular expression and the specific data that it processes. To determine which regular expressions offer the best performance for your particular application scenario, you can use the <xref:System.Diagnostics.Stopwatch> class to compare their execution times.
124124

125-
The following example compares the performance of compiled, source-generated, and interpreted regular expressions when reading the first 10 sentences and when reading all the sentences in the text of Theodore Dreiser's *The Financier*. As the output from the example shows, when only 10 calls are made to regular expression matching methods, an interpreted or source-generated regular expression offers better performance than a compiled regular expression. However, a compiled regular expression offers better performance when a large number of calls (in this case, over 13,000) are made.
125+
The following example compares the performance of compiled, source-generated, and interpreted regular expressions when reading the first 10 sentences and when reading all the sentences in the text of William D. Guthrie's *Magna Carta, and Other Addresses*. As the output from the example shows, when only 10 calls are made to regular expression matching methods, an interpreted or source-generated regular expression offers better performance than a compiled regular expression. However, a compiled regular expression offers better performance when a large number of calls (in this case, over 13,000) are made.
126126

127127
[!code-csharp[Conceptual.RegularExpressions.BestPractices#5](./snippets/regex/csharp/compare1.cs#5)]
128128

docs/standard/base-types/snippets/regex/csharp/compare1.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public async static Task RunIt()
2121
int ctr;
2222

2323
string text =
24-
await s_client.GetStringAsync("https://www.gutenberg.org/cache/epub/1840/pg1840.txt");
24+
await s_client.GetStringAsync("https://www.gutenberg.org/cache/epub/64197/pg64197.txt");
2525

2626
// Read first ten sentences with interpreted regex.
2727
Console.WriteLine("10 Sentences with Interpreted Regex:");
@@ -122,17 +122,17 @@ public async static Task RunIt()
122122
/* The example displays output similar to the following:
123123
124124
10 Sentences with Interpreted Regex:
125-
10 matches in 00:00:00.0050027
125+
10 matches in 00:00:00.0104920
126126
10 Sentences with Compiled Regex:
127-
10 matches in 00:00:00.0181372
127+
10 matches in 00:00:00.0234604
128128
10 Sentences with Source-generated Regex:
129-
10 matches in 00:00:00.0049145
129+
10 matches in 00:00:00.0060982
130130
All Sentences with Interpreted Regex:
131-
13,682 matches in 00:00:00.1588303
131+
3,427 matches in 00:00:00.1745455
132132
All Sentences with Compiled Regex:
133-
13,682 matches in 00:00:00.0859949
133+
3,427 matches in 00:00:00.0575488
134134
All Sentences with Source-generated Regex:
135-
13,682 matches in 00:00:00.2794411
135+
3,427 matches in 00:00:00.2698670
136136
*/
137137
// </Snippet5>
138138
}

0 commit comments

Comments
 (0)