Announcement

Collapse
No announcement yet.

why this code runs faster ???

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    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...
    Precisely, who cares about those few milliseconds? If people want to consume as little CPU time as possible, they should go ahead and program in Assembler
    Bas Groothedde
    Imagine Programming :: Blog

    AMS8 Plugins
    IMXLH Compiler

    Comment


    • #17
      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.

      Comment


      • #18
        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 !!

        Comment


        • #19
          File and folder browsing opening times have a lot to do with the icon cache as well.

          Comment


          • #20
            Originally posted by EnGuardian View Post
            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.
            Mate, come up with some evidence for your claims. If you will be performing extremely illogical speed tests (like the programmers will do, to test the difference), you will get a difference yes. But not with basic things. For example, test this code in which I add 1 million entries in a table with different values. The speed increase over here for locals is only 6% on my system. For 1 million new string variables in a table, string concatenations, table indexing operations and table count operations, this can be disregarded. I already agreed to the speed difference, but a 40% to 60% speed increase is based on mere assumption, as the speed increase entirely depends on what you are doing.

            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).."%");
            Also, I'm not sure how much you understand from CRC, but I have been implementing several hashing and checksum algorithms in Lua. One of them is CRC, not just CRC32, but CRC32 with multiple polynomials and multiple implementations (KERMIT, CCITT, CRC-16, DNP, Sick etc) and generating those polynomial tables take time.

            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.
            Bas Groothedde
            Imagine Programming :: Blog

            AMS8 Plugins
            IMXLH Compiler

            Comment


            • #21
              @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.

              Comment


              • #22
                There is a global/local tests direct in LUA, without AMS. Now i made some simple fast temple to test it in AMS (i didnt run any tests before in AMS). I also tried with Repeat function, and its little faster, like the same.

                Code is simple clicking by AMS:
                Code:
                function StartGlobalTest()
                
                	time = System.GetTime(TIME_FMT_MIL);
                	Paragraph.SetText("Result Global", "Started: " .. time);
                	stats = Paragraph.GetText("Result Global");
                
                	x = 0;
                	while (x < 10000000) do
                		Paragraph.SetText("Result", x);
                		x = x + 1;
                	end
                
                	time = System.GetTime(TIME_FMT_MIL);
                	Paragraph.SetText("Result Global", stats .. "\nEnded:   " .. time);
                
                end
                Code:
                function StartLocalTest()
                
                	time = System.GetTime(TIME_FMT_MIL);
                	Paragraph.SetText("Result Local", "Started: " .. time);
                	stats = Paragraph.GetText("Result Local");
                
                	local x = 0;
                	while (x < 10000000) do
                		Paragraph.SetText("Result", x);
                		x = x + 1;
                	end
                
                	time = System.GetTime(TIME_FMT_MIL);
                	Paragraph.SetText("Result Local", stats .. "\nEnded:   " .. time);
                
                end
                In GUI like:


                I run 4 tests, to 10K, 1M and 10M and 100M.


                Global took 6 seconds, local took 5 seconds. In percentage, its +20%, but i will ignore this because its still fast, 5 or 6 seconds, doesnt matter, numbers are low, its still fast, and it can be MS timing, like 5900MS and 6100MS.


                Global took 16 seconds, local 14 seconds. In percentage its +14.29%, and still fast, 2 seconds in process cant be noticed, even its little more.


                Global made up in 1:49, local in 1:34. Its +15.96% faster, or -15 seconds, and i think 15 seconds of life wasting on waiting is not nice in 2 minutes.


                Global in 17:12, local in 15:28, faster for 1:44, or +11.21%, not much faster, but for bigger numbers it means something.

                I will test it on my one of desktops PC latter, the older one where i tested LUA long time ago (on Sempron 2500+). I dont using it now, but i know configuration, its now AMD Barton 3500+, PCI2AGP Asus AH3650 with 512MB, 3x1GB DDR2 RAM, Ultra 400 NB on Asus A7N8XV2.0 with some Seagate PATA HDD of 250GB, so i will report results ASAP, if he didnt died yet.

                Comment


                • #23
                  BTW Maybe older LUA have more differences in global/local then the new one.

                  Comment


                  • #24
                    Everything you put as code in your AMS application is cached at startup, I think, but if its not its not a difficult task to achieve.

                    Comment


                    • #25
                      Code yes (or 99%), all other things (like objects) is not.



                      Comment


                      • #26
                        Page data is not global code and it is global code where functions are recommended to go.

                        Comment


                        • #27
                          Also, I don't think you understood me EnGuardian. Your claims and numbers are all arbitrary. I participate in the Lua community, I talk with the developers every now and then, so I've seen these tests and once again, those are still not accurate. You'll never know precisely how long specific code will run, until you run it.

                          Also, I understood you very well, I was simply stating the fact that your claims and numbers are never precise data for measuring the difference.

                          Also, once again, the 200ms number you seem to be pulling from a funny hat is again an arbitrary number, it's absolutely impossible that all users with old systems have that amount of delay. Again, it depends on the unique situation, the older laptop I tested the code on (with a IDE drive and quite old RAM ) displayed the dialogs and windows just as fast as on my faster laptop, it just took a few milliseconds longer to start the application.

                          This discussion may go on forever, but I think you're missing my point here. I'm not trying to prove the delay a false fact. I even stated that there will always be a delay between locals and globals, I'm simply trying to get you to take a broader 'investigation' field and stop pulling arbitrary numbers out of nowhere. It's misinformation, I don't like that.
                          Bas Groothedde
                          Imagine Programming :: Blog

                          AMS8 Plugins
                          IMXLH Compiler

                          Comment


                          • #28
                            OFC That is fine, i just talking about caching "everything" on start up.

                            Comment


                            • #29
                              Originally posted by EnGuardian View Post
                              OFC That is fine, i just talking about caching "everything" on start up.
                              Yes, with arbitrary numbers! I don't want people to think that Lua is slow or that global variables are "slow", it's all relative to what is being done and on what system it is running. (and in what engine, using specific modules etc etc).
                              Bas Groothedde
                              Imagine Programming :: Blog

                              AMS8 Plugins
                              IMXLH Compiler

                              Comment


                              • #30
                                I didnt say LUA is slow, i said that i like any bonus speed up by typing only a stupid thing of 5 letters (local), what i actualy doing only for some processes like repeat, search, etc., and for something where i like to be the same variable name (because it looks better and more clear), so variable1 in one code will not be the same variable1 in another part of code, and i like inverted thing about global and local, and i dont know why most languages using local as default, so its a problem when you need that variable later and you cant figure out where is an error, and error is that local variable is not available for other part of code.

                                For me, LUA is most fastest programming language, for example, the first and main CUDA code is made in LUA, why, because GPU can process a way too fast that other languages cant hold, because GPUs are milion times faster then CPUs. Today you have CUDA written in C++, Java, etc., all other programing languages, but, you probably sow it, like encoders/converters, turn on CUDA options and you will get +20% more converting speed. I mean, you will use with your CPU additional 100 GPUs cores that have 100 times more FLOPS then your CPU and milion times faster then CPU to get, only, 20% boost? Yeah, that is probably because its CUDA powered by something that is not LUA. Like in games, OK 3D particles is a different story full of stupidity, but making GUI in game of LUA is way too faster and too light then others, so it must be.

                                Comment

                                Working...
                                X