Edit Thank you to multiple people's answers which incrementally lead to the solution. Disabling my anti-virus allowed any of the previously suspicious delimiters to now finish instantly. I noticed that my BitDefender was off by one minor version to the version on one of my other properly-functioning computers. I've reinstalled it, verified the versions match on my other computer, and everything is working normally.
Original
Just today, I have found that it is taking a really long time to write trivial files that have a handful of commas compared to others. I've only tested out a few but have found that comma, period, backslash take a long time while tabs, $, or @ do not.
List<string> lines = new List<string>();
string delimiter = ",";
string example = string.Join(delimiter, new[] { "qwasdasdasde", "qwasdasdasde", "qwasdasdasde", "qwasdasdasde", "qwasdasdasde", "qwasdasdasde", "qwasdasdasde" });
for (int i = 0; i < 30; i++)
{
lines.Add(example);
}
Console.WriteLine($"Delimiter: '{delimiter}'");
for (int i = 1; i <= 10; i++)
{
Stopwatch stopwatch = Stopwatch.StartNew();
File.WriteAllLines("test.txt", lines);
stopwatch.Stop();
Console.WriteLine($"Trial {i}: {stopwatch.Elapsed}");
}
Here's the output of running with a comma delimiter which outrageously does not finish instantly.
Delimiter: ','
Trial 1: 00:00:00.6407826
Trial 2: 00:00:00.6414110
Trial 3: 00:00:00.6520452
Trial 4: 00:00:00.6511121
Trial 5: 00:00:00.6879321
Trial 6: 00:00:00.6000476
Trial 7: 00:00:00.6409915
Trial 8: 00:00:00.6424960
Trial 9: 00:00:00.6544160
Trial 10: 00:00:00.6418019
Here's the output running with "@", which finishes so quickly that I couldn't kill the process even if I tried.
Delimiter: '@'
Trial 1: 00:00:00.0033232
Trial 2: 00:00:00.0020682
Trial 3: 00:00:00.0007879
Trial 4: 00:00:00.0020546
Trial 5: 00:00:00.0009417
Trial 6: 00:00:00.0006485
Trial 7: 00:00:00.0016277
Trial 8: 00:00:00.0006289
Trial 9: 00:00:00.0006502
Trial 10: 00:00:00.0005868
I tried this on other computers and they all finished instantaneously regardless of delimiter. What in the world could be happening?
Edit: Results from Enigmativity's code below I ran this for 10 iterations because it was taking too long given the very weird issue I'm having. As you can see, most of them are pretty instant but oddly not for comma, period and '<'
'@' 00:00:00.0251197
'#' 00:00:00.0207233
'$' 00:00:00.0373336
'<' 00:00:06.6117783
',' 00:00:06.6047638
'\' 00:00:00.0335935
'.' 00:00:08.8566411
'\t' 00:00:00.0388599
' ' 00:00:00.0295777