Jump to content

Slow execution from command line, but not from the IDE


Recommended Posts

Posted

Good morning friends, could someone help me with the following problem:
i have a code that i run in the Lisp IDE, code that deals with matrix analysis, additions, subtractions, replacement of row and column values and even inverses of those matrices; which takes about 10 seconds, but when i run the code once the .lsp is loaded i run the same operations from the command line and the operations are performed in 90 to 100 seconds, does anyone know why that happens and how i could fix it, thanks for your answers.

Posted

Kinda hard to tell with out the code.

  • Thanks 1
Posted

Good morning friends, thanks for the answer, i do not place the code because the problem occurs only in a part of the whole project, also this part of the code pulls data from other sub routines, and it is complex to place it here, but instead i put this code to test what i mention:

 

(defun c:speed ()
	(setq i 0)
	(setq n 10000000)
	(repeat	n

	  (if (= (1+ i) n)
	    (alert (strcat "Arrive at:" (rtos n)))
	  )

	  (setq i (1+ i))
	)
)

Run it from the ide and it takes 8 seconds, then load it and run it from the command line and it takes about 30 seconds; another thing i noticed is that if you put it in .fas and load it it runs faster than if you load it from the IDE, almost with the same speed with which it is executed from the IDE.

Posted (edited)

There is nothing there that wouldn't take 1 or 2milliseconds to compute. my 2¢ their is something in the sub routines that is either not cleaning its variable data between commands. so if every time you type the command it takes longer and longer. because its looking at more and more data.

Or its very slow when its looking at existing data. If every time you run the command after the first time its taking longer but ruffly the same amount of time no matter how many times you run the command. you would need to optimize your code.

 

(defun c:speed (/ i n start stop)  ;need to delcare local variables so they are cleared when lisp ends
  (setq start (getvar "millisecs"))
  (setq i 0)
  (setq n 10000000)
  (repeat n
    (if (= (1+ i) n)
      (progn
        (setq stop (getvar "millisecs"))
        (setq x (- stop start))
        (alert (strcat "Arrive at: " (itoa n) "\nSpeed lisp finished in " (itoa x) " ms"))
      )
    )
    (setq i (1+ i))
  )
  (princ)
)

 

10,000,000 loops only takes  422 ms on my pc.

Edited by mhupp
  • Like 1
Posted

Thanks for the reply and for the code, on my pc it gives:
66375 ms from the command line.
8234 ms from inside the IDE
i can that the difference in execution speed is given by the difference between the characteristics of the hardware in your pc and mine, but if there is a difference in execution speed depending on where you run it from, if from the IDE or the command line.

Posted (edited)

66 second to run the speed lisp? your pc might need an upgrade. This work computer was mid range when the bought it 8 years go. if you have windows hit Ctrl+Shift+Esc to bring up the task manager. CPU, Memory, and disk usage shouldn't be over 50% if you just have a drawing open.

 

Edited by mhupp
  • Agree 1
Posted

I'd also check that what you think are local variables are defined in the defun line - like MHUPP says, sounds like it is picking up a value from elsewhere when you are not expecting it to be.

 

What happens if you open the drawing - no LISPs running - and run these ones straight off from the command line before you do anything else?

  • Like 1
Posted

Thanks for the answers friends, i tried with the suggestions and i got the following results

 

72812 ms pasting the code in the command line
41453 ms executing speed on the command line
8235 ms running from the IDE

 

I tried on another computer and got similar results, my conclusion is that anyway running a program from the IDE or in fas is much faster than from the command line or pasting the code in it; about the huge difference in speed between your pcs and mine must be because of the hardware, i will try to buy one with higher capacity, thank you very much for your help.

Posted

Only think i can thing of is i upgraded the hard drive to SSD about 1.5 years ago. but everything should be running in memory.

Compiled code will always run faster too.

Posted (edited)

fas is "Compiled Fast-Load AutoLISP"

The machine automatically optimizes it in a form that is easy to understand and fast.

 

machine cannot understand lisp with alphabet in fact. every that code needs translation. 

 

Edited by exceed
  • Like 2
Posted

My $0.05 I7 laptop 16GB not real new.

 

image.png.28ed2155fe08712fbc8cf5916e164c3f.png

 

Yes I had code took 5 minutes progressively improved, now takes around 6 seconds, we are talking up to low thousands of objects.

 

Another project is 2 minutes the cad operator around 1 day to do same, so you work out the cost saving, is 2 minutes to long ? Yes you can watch the fly spec appearing on the screen. Yes got paid for code.

Posted
2 minutes ago, BIGAL said:

 

Another project is 2 minutes the cad operator around 1 day to do same, so you work out the cost saving, is 2 minutes to long ? Yes you can watch the fly spec appearing on the screen. Yes got paid for code.

 

You're to good, need to slow that one down - barely enough time to put the kettle on in 2 minutes, you need to optimise that for hot-drink multitasking

Posted

What else will the cad operator do for the other 7.5 Hours but have a coffee. :beer: or something stronger.

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...