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

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 閱讀(376) 評論(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>
            亚洲高清中文字幕| 最新国产成人在线观看| 亚洲欧美综合一区| 久久夜色精品一区| 中国成人亚色综合网站| 久久视频国产精品免费视频在线| 欧美国产一区二区三区激情无套| 欧美a一区二区| 久久久久久久久伊人| 巨乳诱惑日韩免费av| 亚洲毛片视频| 欧美国产亚洲另类动漫| 久久久一区二区三区| 久久久www成人免费毛片麻豆| 亚洲第一网站免费视频| 亚洲高清不卡一区| 夜夜爽www精品| 亚洲无线视频| 亚洲免费视频成人| 亚洲免费在线观看| 亚洲视频一二| 亚洲资源在线观看| 99riav久久精品riav| 久久久久久久综合日本| 宅男噜噜噜66一区二区| 久久午夜av| 亚洲国产裸拍裸体视频在线观看乱了| 久久狠狠久久综合桃花| 欧美在线视频播放| 亚洲黄色片网站| 亚洲曰本av电影| 亚洲黄色小视频| 亚洲视频精品在线| 性娇小13――14欧美| 国产精品国产三级国产普通话三级 | 久久久精品一区二区三区| 99热免费精品在线观看| 1024国产精品| 亚洲一级黄色av| 久久爱www.| 亚洲精品在线三区| 国产一区亚洲| 亚洲国产清纯| 艳女tv在线观看国产一区| 欧美在线视频a| 国产欧美一区二区三区在线看蜜臀| 亚洲在线视频| 亚洲精品一区二区在线| 久久精品最新地址| 91久久精品www人人做人人爽| 六月丁香综合| 一区二区三区欧美亚洲| 欧美视频久久| 日韩午夜激情av| 欧美第一黄网免费网站| 欧美一区二区三区久久精品| 国产一区二区三区四区在线观看| 亚洲免费视频一区二区| 国产一区二区高清视频| 国产在线视频欧美一区二区三区| 国产精品你懂的在线欣赏| 亚洲视频导航| 麻豆精品视频在线观看| 欧美日韩视频在线第一区| 宅男噜噜噜66一区二区| 中文一区字幕| 亚洲精品久久久久久久久久久| 日韩一级裸体免费视频| 裸体一区二区三区| 亚洲女性裸体视频| 久久久久久69| 欧美激情精品久久久久久蜜臀 | 欧美在线观看网站| 午夜精品久久久久久久男人的天堂 | 亚洲国产精品一区二区www在线| 中国成人黄色视屏| 亚洲精品三级| 欧美在线观看天堂一区二区三区| 国产一区二区久久| 久久国产精品99精品国产| 久久亚洲精选| 一本色道久久综合亚洲91| 一本色道久久综合亚洲精品不卡 | 亚洲国产欧美另类丝袜| 亚洲特黄一级片| 国产精品美女主播在线观看纯欲| 亚洲国产婷婷综合在线精品| 亚洲精品国产精品国产自| 久久视频在线视频| 性视频1819p久久| 最新国产成人av网站网址麻豆| 亚洲欧洲日韩女同| 欧美中在线观看| 久久久青草婷婷精品综合日韩| 亚洲精品影视在线观看| 欧美三级中文字幕在线观看| 亚洲欧美中文日韩v在线观看| 欧美日韩国产成人高清视频| 久久超碰97人人做人人爱| 欧美一区国产在线| 亚洲黄色高清| 一区二区三区在线免费观看| 久久精品国产第一区二区三区最新章节| 蜜桃久久精品一区二区| 亚洲欧美国内爽妇网| 欧美日韩一区在线播放| 欧美影院在线| 亚洲视频在线观看一区| 久久精品道一区二区三区| 欧美**人妖| 亚洲欧美在线一区| 国产精品揄拍500视频| 99精品视频免费| 欧美午夜精品久久久久久超碰| 榴莲视频成人在线观看| 亚洲国产日韩一区二区| 亚洲午夜视频| 99热这里只有精品8| 国产欧美日韩一级| 美女主播视频一区| 亚洲欧美日韩中文播放| 亚洲制服av| 亚洲免费伊人电影在线观看av| 亚洲视频999| 国产精品久久久久天堂| av成人老司机| 亚洲性感美女99在线| 亚洲福利国产精品| 亚洲日本电影| 夜夜嗨av一区二区三区| 99亚洲一区二区| 国内精品视频在线播放| 亚洲国产裸拍裸体视频在线观看乱了中文| 亚洲午夜精品一区二区| 国产精品综合| 亚洲国产高清在线观看视频| 1000部国产精品成人观看| 亚洲高清自拍| 亚洲国产精品一区制服丝袜| 欧美一区二区视频在线| 亚洲美女av黄| 中日韩美女免费视频网址在线观看 | 一区二区激情小说| 欧美一区深夜视频| 欧美有码视频| 久久成人久久爱| 亚洲精品字幕| 一区二区三区四区国产| 久久久www| 国产精品成av人在线视午夜片| 在线免费观看视频一区| 亚洲激情电影在线| 一本色道久久综合狠狠躁篇的优点 | 亚洲黄色三级| 欧美性大战久久久久久久蜜臀| 精品动漫一区| 在线视频一区二区| 一本色道久久综合一区| 久久国产日韩| 亚洲永久精品大片| 久久久999精品| 欧美另类一区| 欧美一区二区精品在线| 欧美一区二区在线免费观看| 欧美女主播在线| 亚洲精品国产精品国产自| 榴莲视频成人在线观看| 亚洲欧美激情四射在线日| 国产精品中文字幕欧美| 亚洲午夜电影网| 午夜在线成人av| 伊人久久大香线| 欧美一区深夜视频| 久久av一区二区| 国产欧美日韩三区| 亚洲国产视频一区二区| 欧美韩日一区二区三区| 亚洲九九精品| 亚洲网站啪啪| 亚洲高清资源综合久久精品| 麻豆成人综合网| 一本色道久久综合亚洲精品不卡| 欧美国产免费| 免费观看亚洲视频大全| 久久久亚洲午夜电影| 一区二区三区四区五区在线 | 老司机一区二区| 日韩午夜免费| 欧美黄在线观看| 欧美国产视频在线观看| 国产情人节一区| 99视频国产精品免费观看| 91久久在线观看| 久久婷婷丁香| 校园激情久久| 欧美三级在线视频| 欧美高清在线一区| 亚洲午夜久久久| 在线观看中文字幕不卡| 亚洲第一区色|