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

Life is Good.

Enhance Tech and English
隨筆 - 65, 文章 - 20, 評(píng)論 - 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 閱讀(379) 評(píng)論(0)  編輯 收藏 引用


只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   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>
            久久久久久久久久久久久久一区 | 一区二区三区精品视频| 国产精品久久一级| 欧美大片在线观看一区二区| 欧美一级大片在线免费观看| 亚洲作爱视频| 亚洲国产日韩欧美综合久久| 久久精品视频亚洲| 亚洲欧美日韩精品久久奇米色影视| 亚洲国产高清一区| 海角社区69精品视频| 欧美视频在线观看免费网址| 免费欧美日韩| 久久综合九九| 久久精品91久久久久久再现| 亚洲欧美日韩中文播放| 亚洲婷婷综合久久一本伊一区| 亚洲电影免费| 欧美v国产在线一区二区三区| 欧美制服丝袜| 欧美一级视频| 亚洲欧美清纯在线制服| 亚洲性感激情| 一本色道**综合亚洲精品蜜桃冫| 亚洲国产精品999| 亚洲电影视频在线| 一区二区三区在线观看视频| 国产一区二区黄色| 国产亚洲欧美aaaa| 国产在线乱码一区二区三区| 国产三级精品三级| 国产视频精品xxxx| 国产综合av| 国内久久精品| 在线播放精品| 亚洲国产第一页| 亚洲国产欧美不卡在线观看| 亚洲电影免费观看高清完整版| 在线观看成人网| 亚洲激情网址| 亚洲乱亚洲高清| 中文精品99久久国产香蕉| 亚洲视频一二| 欧美影院成年免费版| 欧美一区二区三区的| 久久久777| 蜜桃av噜噜一区| 欧美激情bt| 99国产麻豆精品| 亚洲欧美日韩国产综合精品二区| 欧美一区二区三区视频免费播放| 久久精品2019中文字幕| 麻豆精品视频在线观看| 欧美日韩大片| 国产精品永久免费观看| 狠色狠色综合久久| 亚洲日本免费| 午夜国产一区| 麻豆91精品| 亚洲娇小video精品| 亚洲视频第一页| 欧美在线欧美在线| 欧美va亚洲va国产综合| 欧美日韩一区二区高清| 国产亚洲永久域名| 亚洲精品乱码久久久久久| 亚洲一区综合| 裸体歌舞表演一区二区 | 欧美一区二区视频观看视频| 久久久久久一区二区三区| 欧美激情视频网站| 国产免费一区二区三区香蕉精| 狠狠色综合色综合网络| aa级大片欧美三级| 欧美综合国产| 亚洲第一福利在线观看| 亚洲永久精品大片| 女人香蕉久久**毛片精品| 国产精品久久久久久久第一福利| 精品不卡在线| 亚洲一区免费视频| 欧美国产专区| 亚洲欧美综合精品久久成人| 欧美好吊妞视频| 国内精品视频在线播放| 一区二区三区久久久| 米奇777超碰欧美日韩亚洲| 99视频精品全国免费| 久久噜噜噜精品国产亚洲综合| 欧美乱妇高清无乱码| 狠狠狠色丁香婷婷综合久久五月| 一本色道久久综合亚洲二区三区| 久久综合99re88久久爱| 在线午夜精品| 欧美成人视屏| 激情综合色丁香一区二区| 亚洲在线观看视频| 亚洲黄色三级| 久久久久综合| 国产偷久久久精品专区| 亚洲婷婷综合久久一本伊一区| 免费高清在线一区| 欧美亚洲一区在线| 国产精品久久久久久亚洲调教| 亚洲美女中文字幕| 免费观看在线综合| 欧美一区二区三区在| 国产精品久99| 亚洲一区二区三区成人在线视频精品| 欧美不卡三区| 久久精品国产亚洲精品| 国产精品尤物福利片在线观看| 一区二区91| 亚洲欧洲精品一区二区| 美女视频黄 久久| 黄色成人在线网站| 久久久国产精品一区| 亚洲综合日韩在线| 国产精品久久久一本精品| 亚洲视频在线观看免费| 亚洲日本电影| 欧美日本精品一区二区三区| 亚洲日韩中文字幕在线播放| 欧美激情亚洲自拍| 久久只有精品| 亚洲欧洲另类国产综合| 亚洲国产99精品国自产| 鲁大师成人一区二区三区| 亚洲福利视频二区| 欧美电影在线| 欧美成人久久| 99re热精品| 99在线|亚洲一区二区| 欧美日韩一区二区国产| 亚洲一区二区三区四区五区黄| 日韩视频免费| 欧美日韩综合在线| 亚洲欧美日韩国产综合精品二区| 亚洲午夜电影| 国产精品一区一区三区| 久久久久久久97| 久久亚洲春色中文字幕| 亚洲欧洲中文日韩久久av乱码| 亚洲福利视频一区二区| 欧美日韩喷水| 欧美亚洲在线| 久久久久久夜精品精品免费| 亚洲国产日日夜夜| 亚洲精品一区二区在线| 国产精品s色| 久久久国产精彩视频美女艺术照福利| 久久成人久久爱| 亚洲全部视频| 一本久久综合| 国产在线欧美日韩| 亚洲大片精品永久免费| 欧美日韩国产一区精品一区| 西瓜成人精品人成网站| 久久久99免费视频| 一本色道久久88综合亚洲精品ⅰ | 欧美二区在线| 欧美日韩国产91| 久久超碰97中文字幕| 麻豆成人综合网| 亚洲一二区在线| 久久se精品一区二区| 亚洲三级视频在线观看| 亚洲图片在线观看| 在线日韩电影| 一区二区三区日韩欧美精品| 国产亚洲欧洲一区高清在线观看| 欧美大成色www永久网站婷| 欧美日韩亚洲一区二区三区在线| 久久精品国产77777蜜臀| 欧美www在线| 欧美中文字幕不卡| 欧美成人在线网站| 欧美在线视频在线播放完整版免费观看| 久久综合999| 亚洲欧美精品伊人久久| 久久精品国产精品亚洲| 中文在线不卡| 老鸭窝毛片一区二区三区| 亚洲制服av| 欧美福利视频在线观看| 久久国产精品久久精品国产| 欧美精品免费播放| 久久一日本道色综合久久| 国产精品chinese| 欧美激情一区在线| 国产日韩视频| 一区二区欧美日韩| 亚洲人久久久| 久久精视频免费在线久久完整在线看| 一本色道久久88综合亚洲精品ⅰ| 久久久国产精品亚洲一区| 亚洲在线视频网站| 欧美高清视频| 牛人盗摄一区二区三区视频| 国产日韩欧美在线播放不卡|