Author Topic: What's the fastest way to transfer string of coordinates to list of points ?  (Read 6062 times)

0 Members and 1 Guest are viewing this topic.

JohnK

  • Administrator
  • Seagull
  • Posts: 10646
<post removed>
« Last Edit: November 09, 2011, 08:14:09 AM by Se7en »
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Dividing file into pieces is not that important since Lee supported us with excellent one .

Did dividing the file work for you?

Coder

  • Swamp Rat
  • Posts: 827
Dividing file into pieces is not that important since Lee supported us with excellent one .

Did dividing the file work for you?

Worked perfectly without a piece of doubt .

Thank you so much Lee , you made my day .

pBe

  • Bull Frog
  • Posts: 402
Hacked together to divide the file:

Code: [Select]
(defun c:dividefile ( / fn i j l lines rf wf )

   .....)

Nice Lee.

Question: Which approach eats up more memory,
Reading the file collect the list THEN entamke the point as opposed to entmake the point while reading the file?

Code: [Select]
(defun c:test ( / f l )
    (if
        (and
    (setq f (findfile "d:\\My Documents\\pts.txt"))
            (setq f (open f "r"))
        )
        (progn
            (while (setq l (read-line f))
                (entmake (list '(0 . "POINT") (read (strcat "( 10 " l ")"))))
            )
            (setq f (close f))
        )
    )
    (princ)
)

Code: [Select]
(defun c:test2 ( / f l pt)
    (if
        (and
    (setq f (findfile "d:\\My Documents\\pts.txt"))
            (setq f (open f "r"))
        )
        (foreach pt_
(progn
            (while (setq l (read-line f))
                (setq pt (cons (read (strcat "( 10 " l ")")) pt))
            )
            (setq f (close f))
  pt
  )

      (entmake (list '(0 . "POINT") pt_)))
        )
    (princ)
)

I'm not talking about speed but memory usage (or is it one and the same?)
Does the longer the file stays open the more memory usage?





Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Dividing file into pieces is not that important since Lee supported us with excellent one .

Did dividing the file work for you?

Worked perfectly without a piece of doubt .

Thank you so much Lee , you made my day .

Excellent  :-)

Hacked together to divide the file:

Code: [Select]
(defun c:dividefile ( / fn i j l lines rf wf )

   .....)

Nice Lee.

It was only quickly written, but cheers pBe  :-)

Question: Which approach eats up more memory,
Reading the file collect the list THEN entamke the point as opposed to entmake the point while reading the file?

Without any testing, I would have said that creating the points whilst iterating through the file would be both quicker and use less memory. Quicker for obvious reasons since the list of points is being iterated once instead of twice; and using less memory since no memory needs to be allocated to store the vast list of points in a variable; also, I should imagine there is a lot of memory usage as the list is being created since the list is constantly expanded and so more memory must be allocated.

Does the longer the file stays open the more memory usage?

I don't believe the 'length of time' will affect the memory usage of reading the file; I suspect you were referring to the number of processes that are occurring between reading each line of the file - in one code you are using memory to creating a list variable, in the other you are using memory to create Point Entities; neither will affect the memory allocated for reading the file.



/Speaking from a non-computer-science background.