FLogger Ö§³ÖÈȼÓÔØ£¬FLogger ÄÚ²¿²¢Ã»ÓвÉÓÃʼþÇý¶¯·½Ê½£¨¼´ÐÂÔö¡¢Ð޸ĺÍɾ³ýÅäÖÃÎļþʱ²úÉúÏà¹Øʼþ֪ͨ FLogger ʵʱÈȼÓÔØ£©£¬¶øÊÇÒԹ̶¨ÆµÂʵķ½Ê½½øÐÐÈȼÓÔØ£¬¾ßÌåʵÏÖ¾ÍÊÇÿִÐÐÍê100´ÎË¢Å̺ó²Å½øÐÐÈȼÓÔØ£¨ÆµÂʿɵ÷£©£¬¹Ø¼ü´úÂëÈçÏ£º
int i = 0; while(bIsRun){ ¡¡¡¡¡¡¡¡try{ ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡//µÈ´ýÒ»¶¨Ê±¼ä ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Thread.sleep(200); ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡//Êä³öµ½Îļþ ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡flush(false); ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡//ÖØлñÈ¡ÈÕÖ¾¼¶±ð ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if(i++ % 100 == 0){ ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Constant.CFG_LOG_LEVEL = CommUtil.getConfigByString("LOG_LEVEL","0,1,2,3,4"); ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡//ÆäËûÅäÖÃÏîÈȼÓÔØ...... ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡i = 1; ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡} ¡¡¡¡¡¡¡¡}catch(Exception e){ ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡System.out.println("¿ªÆôÈÕÖ¾·þÎñ´íÎó..."); ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡e.printStackTrace(); ¡¡¡¡¡¡¡¡} }
Õâô×öÍêÈ«ÊÇΪÁ˱£³Ö´úÂëµÄ¾«¼òºÍ¹¦ÄܵĴ¿´âÐÔ¡£Ê¼þÇý¶¯ÈȼÓÔØÎÞÒÉÊǸüºÃµÄÈȼÓÔØ·½Ê½£¬µ«ÐèҪн¨¶îÍâµÄÏ̲߳¢Æô¶¯¶ÔÅäÖÃÎļþµÄʼþ¼àÌý£¬ÓÐÐËȤµÄͯЬ¿É×ÔÐÐʵÏÖ¡£
ÐÔÄܱ£Ö¤FLogger ³É¹¦Ö§³ÅÁËÈÕ½»Ò׶î°ÙÒÚ¼¶½»Ò×ϵͳµÄÈÕÖ¾·þÎñ£¬ËüµÄÐÔÄÜÊǾÀú¹ý¿¼ÑéµÄ¡£ÏÂÃæÎÒÃǾÍÀ´Äà FLogger ¸ú log4j ×ö¸ö¼òµ¥µÄÐÔÄܶԱȡ£
²âÊÔ»·¾³£ºIntel(R) Core(TM) i5-3470 CPU @ 3.20GHz 3.20 GHz 4.00 GB Memory 64λ²Ù×÷ϵͳ
²âÊÔ³¡¾°£ºµ¥Ìõ¼Ç¼72byte ¹²1000000Ìõ дµ¥¸öÈÕÖ¾Îļþ
FLogger ÅäÖÃÈçÏ£º
# ÈÕ־дÈëÎļþµÄ¼ä¸ôʱ¼ä WRITE_LOG_INV_TIME = 0 # µ¥¸öÈÕÖ¾ÎļþµÄ´óС SINGLE_LOG_FILE_SIZE = 104857600 # µ¥¸öÈÕÖ¾Îļþ»º´æµÄ´óС SINGLE_LOG_CACHE_SIZE = 0
ÒÔÉÏÅäÖñ£Ö¤ËùÓÐÈÕ־дÈëµ½µ¥¸öÎļþ£¬ÇÒ¾¡Á¿±£Ö¤Ã¿Ò»Ìõ¼Ç¼²»ÔÚÄÚ´æÖлº´æ£¬¼õÉÙ²âÊÔÎó²î¡£
²âÊÔ´úÂ룺
FLogger logger = FLogger.getInstance(); //FLogger //Logger logger = Logger.getLogger(Log4jTest.class); //log4j String record = "Performance Testing about log4j and cyfonly customized java project log."; //72×Ö½Ú long st = System.currentTimeMillis(); for(int i=0; i<1000000; i++){ ¡¡¡¡ logger.info(record); } long et = System.currentTimeMillis(); System.out.println("FLogger/log4j write 1000000 records with each record 72 bytes, cost :" + (et - st) + " millseconds");
ÈÕÖ¾ÄÚÈÝ£º
FLogger: [INFO] 2016-12-06 21:40:06:842 [main] Performance Testing about log4j and cyfonly customized java project log. log4j: [INFO ]2016-12-06 21:41:12,852, [main]Log4jTest:12, Performance Testing about log4j and cyfonly customized java project log.
²âÊÔ½á¹û£¨Ö´ÐÐ10´Îȡƽ¾ùÖµ£©£º
FLogger write 1000000 records with each record 72 bytes, cost :2144 millseconds log4j write 1000000 records with each record 72 bytes, cost :cost :12691 millseconds
˵Ã÷£º²âÊÔ½á¹ûΪÈÕ־ȫ²¿Ë¢Å̳ɹ¦µÄÐÞÕýʱ¼ä£¬¼ÓÉϸ÷ÖÖ»·¾³µÄÓ°Ï죬ÓÐÉÙÐíÎó²î£¬Ôڴ˽ö×ö¼òµ¥²âÊÔ£¬²¢²»ÊÇ×îÑϸñ×ƽµÄ²âÊԶԱȡ£ÓÐÐËȤµÄͯЬ¿É½øÐо«È·¶È¸ü¸ßµÄ²âÊÔ¡£»¶Ó˽ÏÂ̽ÌÖ£¬±¾ÈËQQ£º869827095¡£
¡¡