log4net的文件日誌打印時間測試

粗略測試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

/n
第三組。
ConsoleAppender,FileAppender,RollingFileAppender(<maximumFileSize value/u003d"10KB" />)
2006-08-05 21:20:03,625 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length/u003d14,count/u003d100) spent ms/u003d1703/n
2006-08-05 21:20:20,953 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length/u003d14,count/u003d1000) spent ms/u003d17328
2006-08-05 21:23:14,953 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length/u003d14,count/u003d10000) spent ms/u003d174000/n
2006-08-05 21:23:17,015 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length/u003d34,count/u003d100) spent ms/u003d2063
2006-08-05 21:23:38,437 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length/u003d34,count/u003d1000) spent ms/u003d21421/n
2006-08-05 21:27:12,046 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length/u003d34,count/u003d10000) spent ms/u003d213610
2006-08-05 21:27:16,500 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length/u003d129,count/u003d100) spent ms/u003d4453/n
2006-08-05 21:28:00,015 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length/u003d129,count/u003d1000) spent ms/u003d43516
2006-08-05 21:35:16,734 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length/u003d129,count/u003d10000) spent ms/u003d436718/n
/n
 
/n
",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
第三組。
ConsoleAppender,FileAppender,RollingFileAppender(<maximumFileSize value="10KB" />)
2006-08-05 21:20:03,625 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=14,count=100) spent ms=1703
2006-08-05 21:20:20,953 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=14,count=1000) spent ms=17328
2006-08-05 21:23:14,953 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=14,count=10000) spent ms=174000
2006-08-05 21:23:17,015 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=34,count=100) spent ms=2063
2006-08-05 21:23:38,437 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=34,count=1000) spent ms=21421
2006-08-05 21:27:12,046 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=34,count=10000) spent ms=213610
2006-08-05 21:27:16,500 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=129,count=100) spent ms=4453
2006-08-05 21:28:00,015 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=129,count=1000) spent ms=43516
2006-08-05 21:35:16,734 [1] ERROR Test.SimpleClass [(null)] <(null)> - log (length=129,count=10000) spent ms=436718
 
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章