粗略测试log4net的文件日志打印耗费的时间。
一般的PC,amd athlon xp2000+,同时还开着Visual Studio 2005 Team Suit等。
log (length=14,count=100 spent ms=62)表示打印一个长度14的字符串,打印次数100,耗费时间62ms。
一组测试如果打到一个日志文件上,文件大小没有超过5M。
第三组时间耗费很多,主要是RollingFileAppender的maximumFileSize设置太小,测试过程中频繁地创建文件造成的。
第二组比第一组多一个RollingFileAppender,时间耗费增加不到一倍。
感觉log4net性能很不错。
第一组。
ConsoleAppender,FileAppender
2006-08-05 21:45:34,453 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=14,count=100) spent ms=62
2006-08-05 21:45:34,484 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=14,count=1000) spent ms=31
2006-08-05 21:45:34,859 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=14,count=10000) spent ms=375
2006-08-05 21:45:34,859 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=34,count=100) spent ms=0
2006-08-05 21:45:34,890 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=34,count=1000) spent ms=32
2006-08-05 21:45:35,265 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=34,count=10000) spent ms=375
2006-08-05 21:45:35,265 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=129,count=100) spent ms=0
2006-08-05 21:45:35,312 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=129,count=1000) spent ms=46
2006-08-05 21:45:35,734 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=129,count=10000) spent ms=422
第二组。
ConsoleAppender,FileAppender,RollingFileAppender(<maximumFileSize value="10MB" />)
2006-08-05 21:51:58,093 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=14,count=100) spent ms=47
2006-08-05 21:51:58,156 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=14,count=1000) spent ms=62
2006-08-05 21:51:58,765 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=14,count=10000) spent ms=610
2006-08-05 21:51:58,765 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=34,count=100) spent ms=0
2006-08-05 21:51:58,828 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=34,count=1000) spent ms=62
2006-08-05 21:51:59,453 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=34,count=10000) spent ms=625
2006-08-05 21:51:59,453 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=129,count=100) spent ms=0
2006-08-05 21:51:59,531 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=129,count=1000) spent ms=78
2006-08-05 21:52:00,234 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=129,count=10000) spent ms=703