Author Topic: Resources  (Read 1443 times)

0 Members and 1 Guest are viewing this topic.

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 744
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Resources
« on: 08 September, 2004, 15:48:12 »
I would like to get some exact information on minimizing the resource (CPU & RAM) usage of a script.

offtopic: sorry for so many questions, but i had a whole summer to collect them :D :D :D
Everything could have been anything else and it would have just as much meaning.

PtokaX forum

Resources
« on: 08 September, 2004, 15:48:12 »

Herodes

  • Guest
(No subject)
« Reply #1 on: 08 September, 2004, 17:48:03 »
One think to watch for is the loops

Code: [Select]
for i,v in table do
-- toDo() :)
end

while 1 do
--- toDo()
end

repeat
--- toDo()
until (condition_met)
these are all cpu consuming ... but they are usually used in quick parts ...

Another thing that should be avoided is the global variables ...
You can see the globals of your script by using the following bit ...
Code: [Select]
for i , v in globals() do
   if type(v) == "number" or type(v) == "string" then
   SendToAll(i.." with a value of "..v.." and it is a "..type(v))
   end
end
Note: this snippet can be terribly better ;)

and from the outcome of that by observing how each variable is used you can start eliminating one by one if possible ...

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 744
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
(No subject)
« Reply #2 on: 08 September, 2004, 18:44:30 »
I have made almost all variables local, and im using the least loops. Also i tried 2 avoid pattern matching wherever it was possible. Can something more be done?
Everything could have been anything else and it would have just as much meaning.

PtokaX forum

(No subject)
« Reply #2 on: 08 September, 2004, 18:44:30 »