Hello,
I'm developing work service(.net 5) application. It will use StreamWriter.WriteLine() method to write string to a file.
According to my tests, I found that there was a half gap in running time when the work service run on windows and linux(redhat).
On windows: 20000 ms+
On linux: 40000 ms+
I want it to run on Linux as well as on windows.
The following is the code sample:
private static void WriteLineTest()
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
StreamWriter writer = new StreamWriter(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "testLine.csv"), false, Encoding.Default,bufferSize: 65536);
for (int i = 0; i < 3000000; i++)
{
StringBuilder builder = new StringBuilder();
for (int j = 0; j < 30; j++)
{
builder.Append("Col: ").Append(j);
}
writer.WriteLine(builder);
}
writer.Close();
stopwatch.Stop();
Console.WriteLine("WriteLineTest: " + stopwatch.ElapsedMilliseconds + " ms.");
}
Or, If you know any other hign performance I/O library, please feel free to share it with me.
Thanks,
Steven