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

Life is Good.

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

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) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   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>
            欧美黄色aaaa| 欧美精品v日韩精品v韩国精品v| 欧美日韩一区在线视频| 日韩亚洲精品视频| 亚洲精品一品区二品区三品区| 欧美黄色免费| 中文在线一区| 亚洲一区二区三区三| 国产精品网站视频| 久久亚洲春色中文字幕| 久久久精品2019中文字幕神马| 影音先锋久久| 亚洲激情影视| 欧美日韩视频免费播放| 午夜在线视频一区二区区别| 欧美有码在线观看视频| 91久久国产精品91久久性色| 99日韩精品| 国产亚洲一本大道中文在线| 久久亚洲色图| 亚洲国产美女| 一区二区三区视频在线播放| 国产日韩成人精品| 亚洲成色777777在线观看影院| 久久综合电影一区| 欧美激情乱人伦| 欧美一区午夜视频在线观看| 久久久久欧美精品| 在线亚洲一区观看| 久久久久久一区| 一本色道久久加勒比88综合| 午夜精品久久久久久久久久久久| 亚洲激情精品| 亚洲欧美日韩精品综合在线观看| 亚洲国产精品久久久久秋霞影院 | 亚洲成人在线网站| 亚洲美女电影在线| 国产亚洲精品福利| 亚洲精品在线一区二区| 国内外成人免费视频| 亚洲乱码精品一二三四区日韩在线| 国产日韩成人精品| 亚洲精品日本| 亚洲电影免费观看高清完整版在线| 99在线|亚洲一区二区| 一区二区在线视频| 亚洲欧美日韩中文播放| 99视频精品在线| 久久综合狠狠综合久久综合88| 亚洲午夜女主播在线直播| 久久这里有精品视频| 欧美影院久久久| 国产精品高清在线| 亚洲欧洲日韩在线| 91久久综合| 久久久久久久综合色一本| 欧美一区二区在线视频| 欧美日韩中文精品| 亚洲激情综合| 亚洲精品乱码久久久久| 久久精品视频在线看| 久久精品91久久香蕉加勒比| 欧美新色视频| 999亚洲国产精| 亚洲网站在线播放| 欧美日韩另类视频| 99国产精品国产精品久久| 亚洲伦理一区| 欧美日韩国产不卡在线看| 亚洲国产91精品在线观看| 亚洲电影免费观看高清| 久久亚洲春色中文字幕| 欧美暴力喷水在线| 亚洲福利视频一区| 欧美不卡视频| 亚洲全部视频| 亚洲一区二区三区午夜| 国产精品麻豆欧美日韩ww | 午夜精品一区二区三区在线播放| 欧美理论电影在线播放| 亚洲国产精品久久久久秋霞蜜臀 | 久久成人精品视频| 国产主播精品| 欧美a一区二区| 亚洲精品国产精品乱码不99 | 国产视频综合在线| 久久另类ts人妖一区二区| 免费看av成人| 99精品视频免费| 国产精品欧美久久久久无广告| 亚洲欧美在线高清| 久久综合伊人77777蜜臀| 亚洲国产一区二区a毛片| 欧美久久视频| 亚洲欧美文学| 欧美激情一区二区三区全黄| 亚洲精品久久| 国产精品永久免费在线| 久久久精品tv| 99视频一区二区| 久久蜜臀精品av| 日韩视频一区二区| 国产精品一卡二卡| 麻豆freexxxx性91精品| 一区二区国产在线观看| 久久女同互慰一区二区三区| 亚洲美女区一区| 国产日韩欧美一区| 欧美—级在线免费片| 亚洲欧美日韩在线观看a三区| 欧美国产先锋| 欧美在线综合| 一区二区高清在线| 影音先锋久久精品| 国产精品久久一级| 欧美国产精品一区| 欧美一区二区三区成人| 亚洲精品资源美女情侣酒店| 久久久精品五月天| 亚洲欧美国产77777| 亚洲国产99精品国自产| 国产精品一区二区久久 | 在线视频精品一| 欧美顶级少妇做爰| 久久aⅴ国产紧身牛仔裤| 亚洲免费观看高清完整版在线观看| 国产欧美一区二区精品忘忧草 | 亚洲少妇自拍| 亚洲国产精品成人| 久久免费精品视频| 亚洲男女自偷自拍| 99re亚洲国产精品| 亚洲日本va午夜在线影院| 黄色小说综合网站| 国产欧美一区二区三区视频| 欧美网站在线| 国产精品家教| 欧美日韩午夜剧场| 欧美日本不卡| 欧美激情精品久久久久| 六十路精品视频| 美女视频黄免费的久久| 久久久久久久久久久久久女国产乱| 欧美一区二区三区视频免费播放| 亚洲在线观看视频| 亚洲图片自拍偷拍| 亚洲图片欧洲图片av| 中文一区在线| 亚洲欧美中文在线视频| 亚洲一区免费| 欧美一级片在线播放| 欧美在线观看www| 久久久久国产精品麻豆ai换脸| 欧美一区二区视频在线| 欧美在线三级| 老司机午夜精品| 欧美美女操人视频| 国产精品久久| 国产一区二区0| 国内久久视频| 亚洲二区视频| 99re6热在线精品视频播放速度| 亚洲久久视频| 亚洲主播在线观看| 欧美中文在线视频| 毛片一区二区三区| 欧美激情免费观看| 日韩视频在线观看免费| 亚洲人成绝费网站色www| 亚洲最黄网站| 久久久999精品免费| 免费91麻豆精品国产自产在线观看| 欧美夫妇交换俱乐部在线观看| 欧美日韩情趣电影| 国产精品一区免费视频| 一区二区视频欧美| 一本在线高清不卡dvd | 一区二区三区中文在线观看 | 亚洲免费观看高清完整版在线观看熊| 一区二区精品| 久久国产福利国产秒拍| 蜜臀av性久久久久蜜臀aⅴ四虎| 亚洲电影视频在线| 亚洲一区二区日本| 久久久久久久一区二区三区| 欧美精品免费视频| 国内精品国产成人| 一本久道久久综合狠狠爱| 欧美专区福利在线| 亚洲人体1000| 久久精品国产精品亚洲精品| 欧美另类99xxxxx| 国产一区二区无遮挡| 一本大道av伊人久久综合| 久久久噜噜噜久久中文字幕色伊伊| 亚洲精品国精品久久99热一| 欧美在线观看一区二区| 欧美手机在线视频| 亚洲日本中文字幕区| 久久米奇亚洲|