青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

Life is Good.

Enhance Tech and English
隨筆 - 65, 文章 - 20, 評論 - 21, 引用 - 0
數(shù)據(jù)加載中……

Boosting Lisp performance - cons vs append and foreach vs while/nth

From our PD- Nate Holt:

All,

 More and more of you are finding that you have to deal with this goofy language called AutoLISP. Here are a couple items I pulled together related to some lisp “best practices”. Both apply to optimizing performance when processing large “lists” of data.

Thanks,

Nate.

    CONS versus APPEND

The cons function adds an element to the beginning of a list. The append function can be used to give the equivalent of adding an element to the beginning or end of a list.

Using the cons function can be MUCH faster than using append to build up a large list.

We'll run two tests to create a dummy list of 10,000 integer numbers. The first test is using the "cons" function. Appload and type test1 [enter] at the command prompt.

(defun c:test1 ( / )
  (setq i 1)
  (setq lst nil) ; start out with a blank list
  (repeat 10000
    (setq lst (cons i lst)) ; add next element to beginning of list
    (setq i (1+ i))
  )
  (setq lst (reverse lst)) ; put list back into correct order
  (princ)
)

The second test yields the same result but uses the "append" function:

(defun c:test2 ( / )
  (setq i 1)
  (setq lst nil) ; start out with a blank list
  (repeat 10000
    (setq lst (append lst (list i))) ; append next element on to end of list
    (setq i (1+ i))
  )
  (princ)
)

The first test using "cons" builds the 10,000 element list in memory in less than 0.01 seconds (on my T61p).The second test using "append" builds the exact same 10,000 element list in memory but takes a full 3.55 seconds to execute ( ! ). Dealing with large lists, it appears that the "cons" function is many, many times faster.

·         FOREACH versus WHILE / NTH

Let's say you need to cycle through a huge list, one list element at a time. There are two different functions that can cycle through a list, "foreach" and "nth" combined with a "while" loop. When dealing with a very large list, the "foreach" function can be much faster than using a while loop / nth function to index through the list.

These tests use the 10,000 element list held in memory created be either of the above two tests. This next test uses "foreach" to cycle through the 10,000 element list.

(defun c:test3 ( / )
  ; use 10,000 element "lst" created by test1 or test2
  (setq find_int (getint "\nFind integer="))
  (setq foundit nil)
  (foreach x lst
    (if (AND (not foundit) (= x find_int))
      (progn
        (setq foundit T)
        (princ " found") 
    ) )   
  )
  (princ)
)

This next test does the same thing but uses a "while" loop and the "nth" function to index its way through the 10,000 element list:

(defun c:test4 ( / )
  ; use 10,000 element "lst" created by test1 or test2
  (setq find_int (getint "\nFind integer="))
  (setq foundit nil)
  (setq ix 0)
  (setq slen (length lst))
  (while (AND (not foundit)(< ix slen))
    (if (= (nth ix lst) find_int) ; look for match
      (progn ; Found the target element
        (setq foundit T)
        (princ " found") 
    ) )
    (setq ix (1+ ix))  
  )
  (princ)
)

For the test, looking for integer value 5000 (halfway into the list). The "foreach" function finds and exits in less than 0.01 second. The while loop using the "nth" function finds and exits in 0.07 seconds. Using foreach is significantly faster in processing this large list.

posted on 2008-11-10 10:49 Mike Song 閱讀(376) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲欧美一区二区精品久久久| 亚洲综合国产精品| 亚洲国产欧美精品| 国产一区二区精品| 国产精品男女猛烈高潮激情| 欧美日韩美女在线| 国产精品久久久久国产精品日日| 国产精品v日韩精品| 国产精品国产三级国产普通话三级 | 国产亚洲福利| 国产日韩欧美黄色| 在线播放豆国产99亚洲| 亚洲人成啪啪网站| 亚洲一区尤物| 美女亚洲精品| 亚洲毛片在线看| 午夜久久久久久| 另类av一区二区| 欧美日韩精品欧美日韩精品| 国产精品乱子乱xxxx| 黄色成人免费观看| 亚洲最新色图| 久久久久久久一区| 亚洲精品欧美激情| 久久理论片午夜琪琪电影网| 欧美精品在线播放| 国产视频精品免费播放| 亚洲欧洲视频| 午夜欧美视频| 亚洲精品国偷自产在线99热| 亚洲欧美日韩中文播放| 欧美激情在线有限公司| 国产一区二区中文字幕免费看| 日韩视频免费观看高清完整版| 欧美一级专区| 在线综合视频| 欧美国产视频一区二区| 国产欧美日韩亚州综合| 亚洲剧情一区二区| 美日韩丰满少妇在线观看| 中文精品视频| 欧美国产1区2区| 在线日韩中文字幕| 久久九九精品99国产精品| 一区二区日韩精品| 欧美激情在线播放| 亚洲日本黄色| 欧美成人综合在线| 欧美成人激情在线| 欧美jizz19性欧美| 欧美三区美女| 亚洲欧洲精品一区二区三区不卡 | 欧美一站二站| 国产精品成人国产乱一区| 亚洲精选视频免费看| 欧美~级网站不卡| 欧美一区二区三区视频在线| 国产精品高潮粉嫩av| 一区二区av在线| 91久久精品国产91久久性色| 久久裸体艺术| 亚洲国产裸拍裸体视频在线观看乱了| 久久人人看视频| 久久岛国电影| 精品91视频| 久久亚洲影音av资源网| 欧美专区中文字幕| 精品动漫一区| 欧美成人精品| 久久久综合香蕉尹人综合网| 国产无遮挡一区二区三区毛片日本| 一区二区三区欧美日韩| 亚洲精品免费在线| 欧美激情麻豆| 一本色道久久综合狠狠躁的推荐| 欧美v日韩v国产v| 欧美插天视频在线播放| 亚洲精品国精品久久99热| 亚洲黄色小视频| 欧美午夜宅男影院| 亚洲欧美制服中文字幕| 欧美在线免费观看亚洲| 亚洲第一综合天堂另类专| 亚洲风情在线资源站| 欧美另类69精品久久久久9999| 一本久道久久久| 亚洲欧美欧美一区二区三区| 国产午夜一区二区三区| 欧美国产精品一区| 欧美日韩一区国产| 久久久999| 欧美激情一区二区在线 | 欧美午夜久久久| 欧美一级理论性理论a| 久久国产精品久久久久久电车| 亚洲国产精品va| 夜夜嗨av一区二区三区四季av | 国产欧美一区二区精品性色| 久久精品在线观看| 久久午夜精品| 亚洲一区二区三区免费在线观看| 欧美在线不卡视频| 日韩视频免费观看高清在线视频| 亚洲一区免费观看| 亚洲激情小视频| 香蕉成人伊视频在线观看| 亚洲黄色毛片| 欧美一二三区在线观看| 日韩亚洲在线| 欧美专区日韩专区| 亚洲一区综合| 欧美高清不卡| 久久久久久久网| 国产精品盗摄一区二区三区| 欧美 亚欧 日韩视频在线| 国产精品欧美风情| 亚洲日本一区二区| 激情文学综合丁香| 亚洲欧美成人综合| 一区二区三区四区国产| 久久精品系列| 欧美主播一区二区三区美女 久久精品人 | 亚洲女人小视频在线观看| 91久久久久久| 久久青草久久| 久久久久青草大香线综合精品| 欧美性猛交xxxx乱大交蜜桃| 亚洲激情一区二区| 136国产福利精品导航网址应用| 亚洲一区在线观看视频| 亚洲一区亚洲| 国产精品久久久久毛片软件| 日韩午夜一区| 制服丝袜激情欧洲亚洲| 欧美高清视频在线| 亚洲国产毛片完整版 | 久久99伊人| 欧美伊人久久大香线蕉综合69| 国产精品播放| 亚洲香蕉在线观看| 亚洲综合精品| 国产精品推荐精品| 亚洲一区久久久| 久久精品日韩一区二区三区| 国产精品一区二区三区四区五区 | 亚洲天堂免费观看| 亚洲制服欧美中文字幕中文字幕| 欧美日本韩国一区二区三区| 亚洲人成毛片在线播放| 91久久在线观看| 欧美高清一区| 一本色道久久综合狠狠躁篇怎么玩| 亚洲一区二区三区视频播放| 国产精品高潮呻吟久久av无限| 国产精品乱人伦一区二区| 一本色道久久综合狠狠躁的推荐| 好吊妞**欧美| 久久久久久久综合色一本| 久热精品视频在线| …久久精品99久久香蕉国产| 久久亚洲精品视频| 亚洲国产精品电影| 亚洲伊人网站| 一色屋精品视频免费看| 欧美+日本+国产+在线a∨观看| 亚洲国产美女精品久久久久∴| 亚洲日本视频| 国产精品美女久久久| 久久9热精品视频| 91久久国产精品91久久性色| 亚洲一区二区精品在线观看| 国产午夜亚洲精品羞羞网站| 裸体女人亚洲精品一区| 一区二区三区欧美| 久久久蜜桃一区二区人| 亚洲精品日韩精品| 国产精品美女久久| 美日韩精品视频| 亚洲欧美一区二区在线观看| 欧美99在线视频观看| 午夜影视日本亚洲欧洲精品| 在线观看一区欧美| 国产精品久久久久久久久动漫| 久久精视频免费在线久久完整在线看| 亚洲欧洲一区二区三区在线观看| 亚洲欧美在线一区二区| 日韩视频在线一区| 国内精品一区二区三区| 欧美日韩视频一区二区| 免费日韩精品中文字幕视频在线| 亚洲图片欧洲图片日韩av| 亚洲高清三级视频| 久久在线91| 午夜在线电影亚洲一区| 日韩视频免费| 亚洲精品视频免费观看| 激情国产一区二区| 国产偷国产偷亚洲高清97cao| 欧美日韩中文精品| 欧美激情精品久久久久|