Help with speeding up calculations

Help with speeding up calculations - Smath runs slow when calculating - Сообщения

#1 Опубликовано: 16.04.2013 11:32:11
sublim21

sublim21

3 сообщений из 36 понравились пользователям.

Группа: User

Hey all,

I've written a smath sheet for representing ellipses as a series of n vectors.

however, when i run the sheet it takes around 6-7 seconds to calculate on this computer.

I was wondering if someone could take a look at the code and see if there's something i'm missing that could speed up the calculations. I've attempted changing the code various ways to speed it up, but to no avail.

Much appreciated,

-Pete
approxEllipse_1.sm (23 КиБ) скачан 51 раз(а).
#2 Опубликовано: 16.04.2013 12:41:22
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

Apply an eval() function to theta, rad1 and rad2 (this speed up the worksheet from 15 s to 3 s on my notebook)


regards,

w3b5urf3r
approxEllipse_1.sm (23 КиБ) скачан 58 раз(а).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#3 Опубликовано: 16.04.2013 12:48:17
sublim21

sublim21

3 сообщений из 36 понравились пользователям.

Группа: User

thanks a lot man.

so why does eval make the calculations go faster?
#4 Опубликовано: 16.04.2013 12:59:37
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

Wrote

thanks a lot man.

so why does eval make the calculations go faster?



The eval() function force a local calculation, so all operations made before the eval are "forgotten" in following calculations (in that point remain a division of two numbers).

Another "best practice" it's to select and set all optimizations to numeric; this could take you some appreciable speed advantages.


best regards,

w3b5urf3r
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#5 Опубликовано: 16.04.2013 13:06:49
sublim21

sublim21

3 сообщений из 36 понравились пользователям.

Группа: User

duly noted. Much obliged man.
#6 Опубликовано: 16.04.2013 13:11:11
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

You're welcome
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#7 Опубликовано: 16.04.2013 13:29:53
Fridel Selitsky

Fridel Selitsky

520 сообщений из 451 понравились пользователям.

Группа: User

Wrote

Apply an eval() function to theta, rad1 and rad2 (this speed up the worksheet from 15 s to 3 s on my notebook)
regards,
w3b5urf3r


Additionally apply an eval() function to retMatк
regards,Ber7


approxEllipse_1M.sm (23 КиБ) скачан 48 раз(а).
#8 Опубликовано: 16.04.2013 13:50:27
sublim21

sublim21

3 сообщений из 36 понравились пользователям.

Группа: User

much obliged ber. It seems to me, that any heavy calculations done inside a function should be done with an eval statement.

when declaring the definition of a variable, eval should be used if its a calculation. like
a:=5*b
should be
a:=eval( 5 * b )

while,

a:=b
should NOT be
a:=eval( b )


By the way, both ber7 and websurfer are tremendous assets to the community. thanks for posting.
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений