I changed some of my variables from global to procedure vars, now the time for me to complete one load is slower.
Is global vars faster than procedure/function vars? or I changed something within my script.
I changed some of my variables from global to procedure vars, now the time for me to complete one load is slower.
Is global vars faster than procedure/function vars? or I changed something within my script.
Oh Hai Dar



Local vars must be initialized every time their function or procedure is called, but changing to local vars from global vars should not in any way affect the overall speed of your script, unless you are calling those functions/procedures millions of times each load (and even if you are, it would still probably not make a big difference in speed)... It must be something else that is making your script run slower.
afaik, golbal vars slowdown compile time, and local vars slowdown procs/ functions, albiet not by much, if at all![]()
<TViYH> i had a dream about you again awkwardsaw
Malachi 2:3
Awkward (I can't believe I just pressed tab after typing 'Awk'.. >_>), that would logically make sense, although I think this is a different problem. Going from local to global or global to local shouldn't change anything that's noticeable. I'm sure it's something else, Main.
This is fucked up
I restart scar and it continues... WTFSCAR Code:Achieved 864 log per Hour or 116724 exp per hour.
Achieved 863 log per Hour or 116621 exp per hour.
Achieved 863 log per Hour or 116511 exp per hour.
Achieved 862 log per Hour or 116408 exp per hour.
Achieved 861 log per Hour or 116305 exp per hour.
Achieved 860 log per Hour or 116196 exp per hour.
Achieved 859 log per Hour or 116096 exp per hour.
Achieved 859 log per Hour or 115994 exp per hour.
Achieved 858 log per Hour or 115888 exp per hour.
Achieved 857 log per Hour or 115786 exp per hour.
Achieved 856 log per Hour or 115686 exp per hour.
Achieved 856 log per Hour or 115584 exp per hour.
Achieved 855 log per Hour or 115482 exp per hour.
Oh Hai Dar
Show us the script..
Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
Originally Posted by #srl
"A programmer is just a tool which converts caffeine into code"
Wait did it change after you restarted? If so then it was just a SCAR error.
SCAR Code:Procedure Mainloop;
Begin
Rt:=0;
Marktime(Rt);
If Openbank then
Begin
Banking;
GTH;
lt:=0;
repeat
Light;
Disguise('Lighting log #'+inttostr(lt)+'.');
until (lt=28)
GTB;
Walktobank;
Writeln('Achieved '+Inttostr(86400000000/rt)+' log per Hour or '+Inttostr(11664000000000/rt)+' exp per hour.');
End;
End;
I think the marktime is whats causing it
Oh Hai Dar
Well that's not the whole script. The MarkTime alone wouldn't do anything because it takes no time at all.

It's gotta be something with your logic, although I can't find anything in that snippet you gave us.
Does it change during the script run? Or after every time you start it up again?
Global vars should be avoided much as possible.

For debugging purposes. If there's a problem with something you have to look through the whole script do check variables effectively (if they're global). However, if it's local, they don't interact with each other, and they stay in place, which makes it much simpler to debug.![]()
I guess.. so you have a lot of boolean functions?
Oh Hai Dar
What?
What languages.. o.O Last I checked, in most languages its frowned upon.
"They are usually considered bad practice precisely because of their nonlocality: a global variable can potentially be modified from anywhere, (unless they reside in protected memory) and any part of the program may depend on it. A global variable therefore has an unlimited potential for creating mutual dependencies, and adding mutual dependencies increases complexity. See Action at a distance. However, in a few cases, global variables can be suitable for use. For example, they can be used to avoid having to pass frequently-used variables continuously throughout several functions."
http://en.wikipedia.org/wiki/Global_variable
In theory, locals are slower based on initiation time. But, in general you should try to pass around parameters through functions and out/var parameters. Its much easier to find where you errors are if you can isolate the location of change.
Writing an SRL Member Application | [Updated] Pascal Scripting Statements
My GitHub
Progress Report:13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you have serious physchological problems 13:46 <@BenLand100> HE GETS IT! 13:46 <@BenLand100> HE FINALLY GETS IT!!!!1
There are currently 1 users browsing this thread. (0 members and 1 guests)