Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

[·­Òë]High Performance JavaScript(017)

A Note on Benchmarking  ²âÊÔ»ù׼˵Ã÷
    Because a regex's performance can be wildly different depending on the text it's applied to, there's no straightforward way to benchmark regexes against each other. For the best result, you need to benchmark your regexes on test strings of varying lengths that match, don't match, and nearly match.
    ÒòΪÕýÔò±í´ïʽÐÔÄÜÒòÓ¦ÓÃÎı¾²»Í¬¶ø²úÉúºÜ´ó²îÒ죬ûÓмòµ¥Ã÷Á˵ķ½·¨¿ÉÒÔ²âÊÔÕýÔò±í´ïʽ֮¼äµÄÐÔÄܲî±ð¡£ÎªµÃµ½×îºÃµÄ½á¹û£¬ÄãÐèÒªÔÚ¸÷ÖÖ×Ö·û´®ÉϲâÊÔÄãµÄÕýÔò±í´ïʽ£¬°üÀ¨²»Í¬³¤¶È£¬Äܹ»Æ¥ÅäµÄ£¬²»ÄÜÆ¥ÅäµÄ£¬ºÍ½üËÆÆ¥ÅäµÄ¡£
    That's one reason for this chapter's lengthy backtracking coverage. Without a firm understanding of backtracking, you won't be able to anticipate and identify backtracking-related problems. To help you catch runaway backtracking early, always test your regexes with long strings that contain partial matches. Think about the kinds of strings that your regexes will nearly but not quite match, and include those in your tests.
    ÕâÒ²ÊDZ¾Õ³¤Æª´óÂÛ»ØËݵÄÔ­ÒòÖ®Ò»¡£Èç¹ûûÓÐÈ·ÇÐÀí½â»ØËÝ£¬¾ÍÎÞ·¨Ô¤²âºÍÈ·¶¨»ØËÝÏà¹ØÎÊÌ⡣Ϊ°ïÖúÄãÔçÈÕ°ÑÎÕ»ØËÝʧ¿Ø£¬×ÜÊÇÓðüº¬ÌØÊâÆ¥ÅäµÄ³¤×Ö·û´®²âÊÔÄãµÄÕýÔò±í´ïʽ¡£Õë¶ÔÄãµÄÕýÔò±í´ïʽ¹¹Ë¼Ò»Ð©½üËƵ«²»ÄÜÍêÈ«Æ¥ÅäµÄ×Ö·û´®£¬½«ËûÃÇÓ¦ÓÃÔÚÄãµÄ²âÊÔÖС£
More Ways to Improve Regular Expression Efficiency  Ìá¸ßÕýÔò±í´ïʽЧÂʵĸü¶à·½·¨
    The following are a variety of additional regex efficiency techniques. Several of the points here have already been touched upon during the backtracking discussion.
    ÏÂÃæÊÇһдÌá¸ßÕýÔò±í´ïʽЧÂʵļ¼Êõ¡£¼¸¸ö¼¼ÊõµãÒѾ­ÔÚ»ØËݲ¿·ÖÌÖÂÛ¹ýÁË¡£
Focus on failing faster
¹Ø×¢ÈçºÎÈÃÆ¥Åä¸ü¿ìʧ°Ü
    Slow regex processing is usually caused by slow failure rather than slow matching. This is compounded by the fact that if you're using a regex to match small parts of a large string, the regex will fail at many more positions than it will succeed. A change that makes a r


Ïà¹ØÎĵµ£º

javascriptЧÂʾ­Ñé̸(Ò»)

±¾ÎÄÖ÷ÒªÊdzöÓÚÓÐÅóÓÑʹÓÃÎÒÔ­À´Ð´µÄautocompleteµÄJS¿Ø¼þ¡£µ±Êý¾ÝÁ¿´óµÄʱºò£¬»á³öÏÖЧÂʼ«ÆäÂýµÄÇé¿ö£¬ÎÒÔÚÕâ¶Îʱ¼ä×ö³öµÄһЩ²âÊÔÒ²¼°Ò»Ð©¾­Ñ飬Óë´ó¼Ò·ÖÏí£¬Èç¹ûÓдíµÄµØ·½£¬»¹ÇëÖ¸³ö¡£
¾­¹ý²âÊÔ£¬ÎÒÃǻᷢÏÖÈçϵÄÇé¿ö»òÕß˵µÄ½áÂÛ£¬Èç¹ûÄúµÄ²âÊÔ½á¹ûÓëÎҵIJ»·û£¬Çë˵Ã÷Ô­Òò£¬ÒÔ±ãÏ໥ѧϰ¡£
1£©µ±Ò»¸ö½Ï´óµÄHTML×Ö· ......

JavaScriptʼþ´óÈ«

JavaScriptʼþ´óÈ«
 
 
click() ¶ÔÏó.click() ʹ¶ÔÏó±»µã»÷¡£
closed ¶ÔÏó.closed ¶ÔÏó´°¿ÚÊÇ·ñÒѹرÕtrue/false
clearTimeout(¶ÔÏó) Çå³ýÒÑÉèÖõÄsetTimeout¶ÔÏó
clearInterval(¶ÔÏó) Çå³ýÒÑÉèÖõÄsetInterval¶ÔÏó
confirm("ÌáʾÐÅÏ¢") µ¯³öÈ·ÈÏ¿ò£¬È·¶¨·µ»ØtrueÈ¡Ïû·µ»Øfalse
cursor:Ñùʽ ¸ü¸ÄÊó±êÑùÊ ......

JavaScript»ù´¡ÖªÊ¶1

JavascriptÊý¾ÝÀàÐÍ
ÓÉÓÚjavascriptÊÇÈõÀàÐÍÓïÑÔ£¬¼´¶¨Òå±äÁ¿Ê±²»±ØÉùÃ÷ÆäÀàÐÍ
¡£µ«Õâ²¢²»Òâζ×űäÁ¿Ã»ÓÐÀàÐÍ¡£ÒòΪ¸³ÖµÊ±»á×Ô¶¯Æ¥ÅäÊý¾ÝÀàÐÍ£¡
Ä¿Ç°Óõ½µÄ»ù±¾Êý¾ÝÀàÐÍ
number
boolean
string
var i
i="test";//Õâʱi¾Í³ÉÁËstringÀàÐÍ
var i
i=4;//Õâʱi¾Í³ÉÁËnumberÀàÐÍ
³£ÓöÔÏóÀàÐÍ<object> ......

[·­Òë]High Performance JavaScript(014)

Recursion Patterns  µÝ¹éģʽ
    When you run into a call stack size limit, your first step should be to identify any instances of recursion in the code. To that end, there are two recursive patterns to be aware of. The first is the straightforward recursive pattern represented ......

[·­Òë]High Performance JavaScript(016)

Regular Expression Optimization  ÕýÔò±í´ïʽÓÅ»¯
    Incautiously crafted regexes can be a major performance bottleneck (the upcoming section, "Runaway Backtracking" on page 91, contains several examples showing how severe this can be), but there is a lot you can do to improve re ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ