@startup - I dont using any kind of AV (and no, with AV is not equal first and second time, because AV first time scan and secure file, then second time dont scan, because AV knows that file is clear and secured, until you restart PC, or if you are using some very old AV that always scaning), and i dont think the problem is in LUA, but you dont need to agree with me. You can make RAM Disk (for seek time 0MS and speed around 6GB/sec), without any EXE file, and go test it.
@Shrek - Yeah, that is probably the main reason, but what im trying to say is simple, why "AMS" cant cache whole his EXE file at start up? Like, load all "10" windowes (what you created in AMS visualy) on the start up, not an each one when its needed. I mean, for small software that will be great, start EXE and load everything in RAM, for bigger software i understand why it must be more RAM restricted/conserved, but for around 5MB, why save RAM and take a delay (even its anyway too fast).
@Imagine Programming - You have evidences on the internet, most on LUA Community. I know we talking about several threads here, but you again didnt get it, or i didnt explained it in a good way. 6% is for some short/low/fast jobs (i dont talking about table with 1M rows or text with 100M random characters), but for more higer processes it goes up to 60%, it means 0% up to 60% additional speed just by using local. And i said, for short jobs, additional speed like 60% is like nothing, like 1% in a time, but for something more (i said for example rendering because its one of extreme process that can take several MS for low things, up to several milions years for something very hard what can do only super computers, like SGI company who rendering Hollywoods 3D graphics in several minutes, because 10xPC in LANs will took lots of years, and product needs to be ready today) it can be way much faster then eg. 1% in time, and when you get eg. 50% additional speed, its like 1/4 days shorter, and that is a big thing, not big like 150MS to 100MS, because you cant see the differences, because its too fast. But for sure, other short things can get that additional speed, but very hard to get it, as you say, it depends on what you are doing.
BTW You know, if someone using some old PC, where he always have eg. 200MS delay because HDDs seek for 10 files (with slow RAM and lots of CLs), he cant see it, and that is instantly for him (because he dont know what is the faster then that, instantly means something like under "1MS"), first time will be 200MS, second time 50MS, but someone who using eg. SSD where 10 files is loaded in 0.2MS (with faster RAM and lower CLs), and got 200MS delay for first time and 50MS for second time is kinda same thing, same speed, and scary. And about this, my question is why AMS dont have option to cache whole application at start up, it will remove any kind of delays (made by disk readings and memory loadings) for everyone.
Announcement
Collapse
No announcement yet.
why this code runs faster ???
Collapse
X
-
Originally posted by EnGuardian View PostWell, first thing, lots of LUA programmers already tested global and local variables speed, you can find it out on the internet, and they got it, local variables is 40%-60% faster then global. As i say, 60% faster doesnt mean anything for several MS and cheap processes, but for longer processes its nice to know how to get additional speed.
You talking about CRC as heavy process code, but i dont think so, CRC will take several MS, and i mean for heavy processes some code that will take for example 5 minutes to execute, not a 5MS. For example things like rendering.
You say first time 220MS, second time 130MS. I belive in that (even second time sounds still long), but you didnt get it. You probably tested empty things, like empty window, try to set more things on it, objects and in code more variables, for example to get some configuration window with lots of options, first time it will be 220MS+that things, its nothing, but if you are doing something a little bigger, its annoying, so yeah, it will be on every PC, always, but "modem" users will sow it better because of bigger seek time, and other things.
I know lots of about memory, Windows, and lots of other things, but we dont talk about OS or RAM here. I know AMS doing fine, but if it can cache something after the first use, why it cant cache something for futurer work (like start application, wait 2 seconds, if its a way a biger project, even a loading of several seconds, and everthing is ready to use from cache and RAM), like some programs does. The point is, user can make code to reserve variables in RAM at start up to speed up future things, etc., but for windowses and that kind of stuffs, user cant do anything.
Code:local start1 = os.clock(); globalVar = {}; for i = 1, 1e6 do globalVar[#globalVar + 1] = "Global Hello World!!"..i; end local end1 = os.clock(); local start2 = os.clock(); local localVar = {}; for i = 1, 1e6 do localVar[#localVar + 1] = "Local Hello World!!"..i; end local end2 = os.clock(); local duration1 = (end1 - start1) * 1000; local duration2 = (end2 - start2) * 1000; local difference = Math.Abs(duration1 - duration2); local percentage = 100 * (difference / duration2) Dialog.Message("time1", duration1.."ms"); Dialog.Message("time2", duration2.."ms"); Dialog.Message("difference", difference.."ms"); Dialog.Message("increase", Math.Round(percentage, 2).."%");
I have also implemented CRC checksums without the lookup tables, which calculate the polynomial results real-time, which makes the algorithm heavier.
I also didn't test empty windows, I tested it on IMXLH (which has a lot of code going into the windows) and all sorts of Dialogs. I also tested it in several AMS projects of mine, with many dynamic objects. Once again, my tests contradict your claims. The duration is still not noticeable on my system, nor on my main rig and my girlfriend's PC and older Dell laptop.
I'm sure you know stuff about memory, but I specialize myself in data processing techniques and optimizing these and I assure you that the delays you are talking about are a little exaggerated. I developed MemoryEx and IMXLH, so I know my fair share about memory implementations in programming as well. I built an assembler in MemoryEx to be able to program algorithmic data processing functions directly into AMS Lua, but that is because Lua isn't well fit for really fast data processing. (local or global, it's still an interpreted managed language)
For example; I've been developing a fun-project in AMS by using Draw, this project creates multiple canvas objects onto the Window and draws extended graphs to the windows. This application does not take 2 seconds to fire up, it takes about 300ms to create the window and draw the first information to the graphs. So here's your rendering code, for 6 graphs, fully dynamic, each time new information is available.
http://i.imgur.com/FtwrZEj.png - I assure you, there's a lot of code being executed before this window is shown and the graphs are drawn, but it starts up instantly.Last edited by Imagine Programming; 07-11-2014, 06:49 AM.
Leave a comment:
-
File and folder browsing opening times have a lot to do with the icon cache as well.
Leave a comment:
-
Hi EnGuardian
i disagree with you
first try open folders that not contains many exe files
i thing the delay because of your av (prove ?? ok first and second time must be equal)
the problem may be from lua
BTW
did lua have a message boxes to compare with ??
good morning !!
Leave a comment:
-
Well, first thing, lots of LUA programmers already tested global and local variables speed, you can find it out on the internet, and they got it, local variables is 40%-60% faster then global. As i say, 60% faster doesnt mean anything for several MS and cheap processes, but for longer processes its nice to know how to get additional speed.
You talking about CRC as heavy process code, but i dont think so, CRC will take several MS, and i mean for heavy processes some code that will take for example 5 minutes to execute, not a 5MS. For example things like rendering.
You say first time 220MS, second time 130MS. I belive in that (even second time sounds still long), but you didnt get it. You probably tested empty things, like empty window, try to set more things on it, objects and in code more variables, for example to get some configuration window with lots of options, first time it will be 220MS+that things, its nothing, but if you are doing something a little bigger, its annoying, so yeah, it will be on every PC, always, but "modem" users will sow it better because of bigger seek time, and other things.
I know lots of about memory, Windows, and lots of other things, but we dont talk about OS or RAM here. I know AMS doing fine, but if it can cache something after the first use, why it cant cache something for futurer work (like start application, wait 2 seconds, if its a way a biger project, even a loading of several seconds, and everthing is ready to use from cache and RAM), like some programs does. The point is, user can make code to reserve variables in RAM at start up to speed up future things, etc., but for windowses and that kind of stuffs, user cant do anything.
Leave a comment:
-
Originally posted by Cybergraph View Post... also because (tell me if I'm wrong) we all are not designing applications needed to control and check precision of atomic clocks...
Leave a comment:
-
Originally posted by Imagine Programming View PostThe time it lasts longer the first time differs about 50ms - 100ms, a user on a modern system will not even notice it. So not on every PC, always.
Also, when you declare a variable which holds an empty table, an empty table will be created in memory. Each time when you add a variable to that table, it will have to re-allocate the memory required, allocate memory for a new variable, assign this to the array or hash index for a Lua table and store everything in memory.
So for a table value, it doesn't really matter, considering each key / item in the table will have to be initialized just like any other variable. Don't forget that all variables (local or global) will just be keys inside a table object. The local variables in Lua 5.1 will reside in the function environment (which is a table) and the global variables will reside in _G (which is also a table). Local variables will always be slightly faster than global variables due to the check for variables in the scopes up to the global scope, but the use of global variables is not recommended at all in Lua.
Keeping that in mind, I've written a lot of Lua code in my life and I can tell you that generating CRC tables and other complex heavy code which store values in global tables have never been proven to be much slower than doing so for local tables. If you want a speed advantage scope-wise, localize functions and variables, but a global variable or table here and there won't matter much.
Also, a dialog opening every so slightly slower the first time after the application started has nothing to do with AMS. For example, when I do this in PureBasic or C++, the first opening takes a little bit longer. (Not 1 or 2 seconds, a few ms). This is probably due to Windows API allocating memory for the window and performing the required steps for showing the window. This also happens when I open a secondary child window in PureBasic or C++
All the things you describe are not like that for every user. Also, I had to actually measure the delay and it was about 100ms more the first opening. This is normal, memory has to be allocated. The same goes for every window that will open. The first time it opened it took 220ms and the second time it opened it took 130ms...
Leave a comment:
-
The time it lasts longer the first time differs about 50ms - 100ms, a user on a modern system will not even notice it. So not on every PC, always.
Also, when you declare a variable which holds an empty table, an empty table will be created in memory. Each time when you add a variable to that table, it will have to re-allocate the memory required, allocate memory for a new variable, assign this to the array or hash index for a Lua table and store everything in memory.
So for a table value, it doesn't really matter, considering each key / item in the table will have to be initialized just like any other variable. Don't forget that all variables (local or global) will just be keys inside a table object. The local variables in Lua 5.1 will reside in the function environment (which is a table) and the global variables will reside in _G (which is also a table). Local variables will always be slightly faster than global variables due to the check for variables in the scopes up to the global scope, but the use of global variables is not recommended at all in Lua.
Keeping that in mind, I've written a lot of Lua code in my life and I can tell you that generating CRC tables and other complex heavy code which store values in global tables have never been proven to be much slower than doing so for local tables. If you want a speed advantage scope-wise, localize functions and variables, but a global variable or table here and there won't matter much.
Also, a dialog opening every so slightly slower the first time after the application started has nothing to do with AMS. For example, when I do this in PureBasic or C++, the first opening takes a little bit longer. (Not 1 or 2 seconds, a few ms). This is probably due to Windows API allocating memory for the window and performing the required steps for showing the window. This also happens when I open a secondary child window in PureBasic or C++
All the things you describe are not like that for every user. Also, I had to actually measure the delay and it was about 100ms more the first opening. This is normal, memory has to be allocated. The same goes for every window that will open. The first time it opened it took 220ms and the second time it opened it took 130ms...
Leave a comment:
-
The same problem delay have LUA with global variables, not because local variables is faster because limits, so global variables is slow for active working, but when you creating a variable, there is a delay, and thats why code is faster if you type first variable = {}; (that means you created that variable as empty, it took a space in RAM, and that is much faster then creating new variable with fully informations), then you do variable = something else + code to work out with that variable (now, its much faster to edit existing variable in RAM, if its local, it will be more faster in editing).
For cheap things like buttons, paragraphs, etc., it will be still fast, and not a big problem (AMS have that delay, but i think its a RAM configuration (Memory Management (Automatic/Maximize Speed/Conserve Memory; all that options is = Conserve Memory)) bug in AMS, not by LUA), or for some low processes, additional speed is not needed, but for some generators or higher work out processes, additional speed of ~60% only based on LUA code is a good way to get almost double speed up for longer progresses, or if you running LUA with CUDA, that percentage is way too higher and way too fast.
Leave a comment:
-
I said 2 seconds as example, the point is, 1st time (when you start application), there is delay (always, on every PC, 100%), then for any another time (when you going to do second time the same job), its instantly. If you do some RAM cleaning/optimizing/etc. stupid things, then click the button, you will figure out there will be more delay, and highly chance that skin/style will not appear on new window (new window will be without a custom skin, or even without default OS skin).
Im working around on 2xSSDs, OCZ and Intel, and 1x WD Black, so if there is delay more then 0.1MS, its slow for me, so i can notice it when its not instantly, even if you are talking about RAM, but even if you are on slow HDD, slow RAM, or even on RAM Disk and some servers HDDs, etc., you can notice the same thing in the same way for sure, you can test it. Another example, make 1x main window (with button to open DialogEx), and 1x dialogex with some random text, buttons, images, etc. Now, start your application. Press button to open dialogex window, and concentrate your mind/eyes on that delay, how much time it need to show you a another window. You will see, there is delay as always on 1st time, first, there will be delay for creation, after a creation, your new window will become empty, without a color and anything on it, it usualy takes very low delay that can be easy sow on older computers (but the new machines have the same thing), then, your window will be shown propertly. Now, close that dialogex, and press button again, you will see, this time, it will be instantly, in a speed of a light, like thunter, boom, in 0MS, there will be everything shown, and every next time you press the same button to do the same job, it will be instantly, until you close the application and start it again, then you will have the same thing, 1st time with delay, every next time instant. The most delay record going to the file/folder browse.
Leave a comment:
-
EnGuardian - 2 seconds? Really? I see the Dialogs instantly.
The best way to debug really fast with graphical feedback is to use a console btw. Use Windows API to allocate a console and print your information to that console. Otherwise generate a logfile using the Lua's io functions, not with the AMS TextFile functions.
Leave a comment:
-
If you need to process something that dont need to be fully globaly available, then use local variables for that, because its much faster then global (and global variables is default in LUA, in all other languages local variables is as default).
For Debug im using Debug.ShowWindow and Debug.SetTraceMode, looks OK. You can also use something like Paragraph/Input/etc. Text thing like Status Bar, it will be OK too, but using new Windows to get some information is very slow, even you set AMS to work for max. speed (everything will be preloaded into a RAM, and ready to use), its not working for first time, first time when you call that windows, you need to wait application to create it in RAM, and its around 1-2 second, after that is created, same window with different text will be open in 0 second, because its ready to use from RAM.
You can test it with Dialog.FileBrowse and Dialog.FolderBrowse, because there is delay 2 seconds. Make in AMS 1 button with Dialog.FileBrowse/Dialog.FolderBrowse. Run applicatin, click the button, you will figure out that window needs 2-3 seconds to open. Close it, and press again button, there it is, you will open that window in 0 second.
Leave a comment:
-
thanks Imagine Programming for advice :yes
notice
all what i care was my program speed (in the concat function)
so
i use an input for that (input.settext)
after that i feel so comfortable about the program speed
i simply delete the input from my project
no problem if the dialog or /Debug message was slow
no need for them
thanks again :yes
Leave a comment:
-
If you want to debug faster, I would suggest the Debug dialog (even though that can be extremely slow too if you send data to the debug dialog as well). (Debug.ShowWindow(true) and Debug.Print(str)).
Another way is to debug to a file (untested):
Code:local log = io.open("logfile.log", "wb"); if(log)then -- loop here my_table = {} for i = 1,300 do num = Math.Random(111111111, 999999999); Table.Insert(my_table, i, num); end Concatenated = Table.Concat(my_table, "_", 1, TABLE_ALL); -- log result log:write(Concatenated.."\r\n"); end
Leave a comment:
-
to make sure display the result (Concated) in an input instate of the dialog message
you will know that is no difference
Leave a comment:
Leave a comment: