Common Log File System in windows 2008 性能测试
CLFS 是windows 服务器系统内置支持的日志系统
可以直接使用System.IO.Logging 命名空间下面的相关类来操作
写入速度测试
环境:windows2008R2 sp1 (不要在xp上测试..这东西不支持的)
没有raid
8g 内存
CPU: E5440
写入1百万条日志
每条512KB
预计日志大小至少512M
最终耗时22秒...
平均每秒4万多条
测试代码很烂....如下所示
string fullPath = @"c:\log\1.log";
int extentSize = 20 * 1024 * 1024;
int logCount = 1 * 1000 * 100;
LogStore _store = new LogStore(fullPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
LogRecordSequence _sequence = new LogRecordSequence(_store, 1 * 1024 * 1024, 1024);
_sequence.RetryAppend = true;
if (_store.Extents.Count == 0)
{
_store.Extents.Add(fullPath, extentSize);
}
string logContent = @"
123123123FKLSDFJKLEJLJWER:KJRL:EJRL:KJEL:KRJL:KJL:WEUROPJFLKDJFKLSDKLFJSDFL:JFLJJKUHKKL*T^N12345KLHK
123123123FKLSDFJKLEJLJWER:KJRL:EJRL:KJEL:KRJL:KJL:WEUROPJFLKDJFKLSDKLFJSDFL:JFLJJKUHKKL*T^N12345KLHK
123123123FKLSDFJKLEJLJWER:KJRL:EJRL:KJEL:KRJL:KJL:WEUROPJFLKDJFKLSDKLFJSDFL:JFLJJKUHKKL*T^N12345KLHK
123123123FKLSDFJKLEJLJWER:KJRL:EJRL:KJEL:KRJL:KJL:WEUROPJFLKDJFKLSDKLFJSDFL:JFLJJKUHKKL*T^N12345KLHK
123123123FKLSDFJKLEJLJWER:KJRL:EJRL:KJEL:KRJL:KJL:WEUROPJFLKDJFKLSDKLFJSDFL:JFLJJKUHKKL*T^N12345KLHK
123123123FKLSDFJKLEJLJWER:KJRL:EJRL:KJEL:KRJL:KJL:WEUROPJFLKDJFKLSDKLFJSDFL:JFLJJKUHKKL*T^N12345KLHK
123123123FKLSDFJKLEJLJWER:KJRL:EJRL:KJEL:KRJL:KJL:WEUROPJFLKDJFKLSDKLFJSDFL:JFLJJKUHKKL*T^N12345KLHK
123123123FKLSDFJKLEJLJWER:KJRL:EJRL:KJEL:KRJL:KJL:WEUROPJFLKDJFKLSDKLFJSDFL:JFLJJKUHKKL*T^N12345KLHK
123123123FKLSDFJKLEJLJWER:KJRL:EJRL:KJEL:KRJL:KJL:WEUROPJFLKDJFKLSDKLFJSDFL:JFLJJKUHKKL*T^N12345KLHK
123123123FKLSDFJKLEJLJWER:KJRL:EJRL:KJEL:KRJL:KJL:WEUROPJFLKDJFKLSDKLFJSDFL:JFLJJKUHKKL*T^N12345KLHK
1
".Substring(0, 512);
byte[] bytes = Encoding.UTF8.GetBytes(logContent);
Console.WriteLine("Start CLFS Test");
Console.WriteLine("Log Content Bytes:" + bytes.Length + " Byte");
Console.WriteLine("Log Count:" + logCount);
Console.WriteLine("Log File Size:" + logCount * bytes.Length + " Byte");
_sequence.Append(new ArraySegment<byte>(bytes), SequenceNumber.Invalid, SequenceNumber.Invalid, RecordAppendOptions.ForceAppend);
Stopwatch sw = Stopwatch.StartNew();
for (int i = 0; i < logCount; i++)
{
// _sequence.BeginAppend(new ArraySegment<byte>(bytes), SequenceNumber.Invalid,SequenceNumber.Invalid,,
_sequence.Append(new ArraySegment<byte>(bytes), SequenceNumber.Invalid, SequenceNumber.Invalid, RecordAppendOptions.None);
}
sw.Stop();
Console.WriteLine("Cost " + sw.ElapsedMilliseconds + " ms");
Console.WriteLine("Log Write Speed " + logCount * 1000 / sw.ElapsedMilliseconds + " Records / per second");
Console.WriteLine("Data Write Speed " + logCount * bytes.Length * 1000 / sw.ElapsedMilliseconds + " MB / per second");
return;