| Lua mod for 1.2.0.2 | |
|
|
|
Author | Message |
---|
UKnowMe?
Messages : 51 Joined/Date d'inscription : 2012-10-08 Location/Localisation : Germany
Gema stats farthest jump:
| Subject: Re: Lua mod for 1.2.0.2 Sun Dec 01, 2013 10:19 am | |
| Bet you didn't either. Run this test-code and see: with locals you need 9 seconds, with globals 13. And of course I will call a function 100 times for 100 function results in a server. - Code:
-
function test() local math_rand = math.random for i=1,100 do math_rand(5) end end
function test_global() for i=1,100 do math.random(5) end end
print "testing local" local starttime = os.time() for i=1,6000 do test() end local endtime = os.time() print("Took " .. (endtime - starttime) .. " seconds")
print "testing global" starttime = os.time() for i=1,6000 do test_global() end endtime = os.time() print("Took " .. (endtime - starttime) .. " seconds") Of course this test isn't precise because it uses os.time(), but you can replace it with socket.gettime() * 1000 if you want a exact result. Also: - Quote :
- It is good programming style to use local variables whenever possible. Local variables help you avoid cluttering the global environment with unnecessary names. Moreover, the access to local variables is faster than to global ones.
- gear4 wrote:
- I just meant I prefer shorter scripts because I can make it give me better performance in a shorter amount of time
If I understood that sentence correctly, you are saying that you prefer short scripts because you need less time to optimize? - gear4 wrote:
- I prefer to do my work quickly so I get done with it quickly so I have more time to play other games like WoW and Skyrim
That is IMHO a bad idea, to get work done quickly so you can play games. Why do we even have an implementation if it wasn't made properly and might have bugs which weren't found? If you do work, do it good, not fast. | |
|
| |
gear4
Messages : 28 Joined/Date d'inscription : 2013-04-03 Age : 27 Location/Localisation : English
Gema stats farthest jump:
| Subject: Re: Lua mod for 1.2.0.2 Sun Dec 01, 2013 11:50 am | |
| - UKnowMe? wrote:
- Of course this test isn't precise because it uses os.time(), but you can replace it with socket.gettime() * 1000 if you want a exact result.
still not precise enough, I want MS - UKnowMe? wrote:
-
- Quote :
- It is good programming style to use local variables whenever possible. Local variables help you avoid cluttering the global environment with unnecessary names. Moreover, the access to local variables is faster than to global ones.
such speed difference much slow global's aren't slow enough to be given a shit EDIT: I just noticed it's 0.xxxxxxx seconds; sorry for that. imagine it's *1000 so I don't have to upload another pic - UKnowMe? wrote:
- gear4 wrote:
- I just meant I prefer shorter scripts because I can make it give me better performance in a shorter amount of time
If I understood that sentence correctly, you are saying that you prefer short scripts because you need less time to optimize? yep, because I can read most of them easier - UKnowMe? wrote:
- gear4 wrote:
- I prefer to do my work quickly so I get done with it quickly so I have more time to play other games like WoW and Skyrim
That is IMHO a bad idea, to get work done quickly so you can play games. Why do we even have an implementation if it wasn't made properly and might have bugs which weren't found? If you do work, do it good, not fast. actually I have more things to do though just not mentioned. in those 16 hours, a total of 4 hours went towards bugtesting, every command, every event | |
|
| |
UKnowMe?
Messages : 51 Joined/Date d'inscription : 2012-10-08 Location/Localisation : Germany
Gema stats farthest jump:
| Subject: Re: Lua mod for 1.2.0.2 Mon Dec 02, 2013 1:11 pm | |
| That might be that there is not much difference, but I just tested it with math.rand. Now imagine an associative table with about 3000 entries, and each entry with a table as value. You want to iterate over it. I remember it got a lot faster when I used local copies. As an example: Some months ago (it was around March/April afaik) Park posted his Lua-Code in a password protected Gobby-Server. I don't know if you knew Park's Server, but it had a lot of commands. At the time I joined him scripting he used to iterate over the global table. We then changed it to iterate over a local copy, and the script got noticeable faster. And I think that's the point of using locals. It should give you a noticeable performance speed, not one in milliseconds. (I think before changing it the script took about 1.5s to execute, afterwards it was about 500ms I would say.) If I have time I'm gonna test your LuaJIT mod using Park's old server scripts, but for that I need multiple masterserver support. | |
|
| |
gear4
Messages : 28 Joined/Date d'inscription : 2013-04-03 Age : 27 Location/Localisation : English
Gema stats farthest jump:
| Subject: Re: Lua mod for 1.2.0.2 Mon Dec 02, 2013 1:38 pm | |
| link ? so I can laugh. I'm on Windows atm and I don't like testing on Windows so I'm not compiling here, although I x-comp on my Debian box and it works fine so I've got that going for me [edit] ok I dunno what you meant but I assumed you meant this, so I used it and got this: | |
|
| |
UKnowMe?
Messages : 51 Joined/Date d'inscription : 2012-10-08 Location/Localisation : Germany
Gema stats farthest jump:
| Subject: Re: Lua mod for 1.2.0.2 Mon Dec 02, 2013 3:19 pm | |
| Sure, I will give you a link to a closed source project... And as I mentioned: The value was a table, too, and these tables values were accessed and operations were done on these values. And one last thing: If you now things better, give a reason why it is better. Not just give a code and say "That's total bullshit, man". Proof why it is better to do something that way. | |
|
| |
gear4
Messages : 28 Joined/Date d'inscription : 2013-04-03 Age : 27 Location/Localisation : English
Gema stats farthest jump:
| Subject: Re: Lua mod for 1.2.0.2 Mon Dec 02, 2013 4:10 pm | |
| proof is in the testing mate. also, I've gotten multiple masters working | |
|
| |
Park
Messages : 272 Joined/Date d'inscription : 2011-11-04
Gema stats farthest jump:
| Subject: Re: Lua mod for 1.2.0.2 Tue Dec 03, 2013 6:36 am | |
| that closed project must not be my server`s files.
ac supply 1.2 should neither be publicly or privately available to anyone exept us (or those i trust, or lets say know eachother !)
idc about your ports to whatever u made uknowme, but i hope my scripts are not on any shithub nor publicly or privately available / shared unless i allow it.
and for the record, i dont want it shared, e.g. with gear5 | |
|
| |
gear4
Messages : 28 Joined/Date d'inscription : 2013-04-03 Age : 27 Location/Localisation : English
Gema stats farthest jump:
| Subject: Re: Lua mod for 1.2.0.2 Tue Dec 03, 2013 12:16 pm | |
| I made that entire "module", and I just made it as an example to show how cool and easy Lua can be. you don't have to share you stuff if you don't want, I'm not forcing you to. if you mean the source files, though, sveark published his source, and that's what made it possible to make this an almost 1:1 port. also, if you do share something with me, and you don't want me to share it with anyone else, then just tell me and I'll not share it (I expect the same from my old helpers with my closed-source anticheat and enhancement (now dead though) for Cube 2)
Last edited by gear4 on Tue Dec 03, 2013 12:19 pm; edited 1 time in total | |
|
| |
Park
Messages : 272 Joined/Date d'inscription : 2011-11-04
Gema stats farthest jump:
| Subject: Re: Lua mod for 1.2.0.2 Tue Dec 03, 2013 12:18 pm | |
| i dont mean you, nor your script, nor sveark nor his source. uknowme will know what im talking about (and some others ofc.) | |
|
| |
UKnowMe?
Messages : 51 Joined/Date d'inscription : 2012-10-08 Location/Localisation : Germany
Gema stats farthest jump:
| Subject: Re: Lua mod for 1.2.0.2 Tue Dec 03, 2013 2:24 pm | |
| Yep, I know it. And I didn't posted it anywhere. But gear4, I was talking about an associative table with associative tables as values, not indexed tables with a single number as value. And I'll test it asap, but I won't be using Park's code for a public server (better write my own one). | |
|
| |
UKnowMe?
Messages : 51 Joined/Date d'inscription : 2012-10-08 Location/Localisation : Germany
Gema stats farthest jump:
| Subject: Re: Lua mod for 1.2.0.2 Sat Dec 07, 2013 5:33 pm | |
| You should have test your server before. You get disconnected because of an protocol error: local protocol: 1201 server protocol: 0
Oh and it seems like your version doesn't like socket: ".\lua\extra\socket\http.lua:11: loop or previous error loading module 'socket'" | |
|
| |
gear4
Messages : 28 Joined/Date d'inscription : 2013-04-03 Age : 27 Location/Localisation : English
Gema stats farthest jump:
| Subject: Re: Lua mod for 1.2.0.2 Sat Dec 07, 2013 6:09 pm | |
| noticed that bug (friend's pc), but I did put a "note" in the commit log, saying "untested", and yes, my version does like socket, since my server uses socket to monitor internal calls. also, I don't have a Windows PC anymore to test, so I have to commit before testing | |
|
| |
UKnowMe?
Messages : 51 Joined/Date d'inscription : 2012-10-08 Location/Localisation : Germany
Gema stats farthest jump:
| Subject: Re: Lua mod for 1.2.0.2 Sun Dec 08, 2013 4:25 am | |
| Well but sockets don't work for me, but they did work with Sveark's version. Does HTTP socket work for you? | |
|
| |
gear4
Messages : 28 Joined/Date d'inscription : 2013-04-03 Age : 27 Location/Localisation : English
Gema stats farthest jump:
| Subject: Re: Lua mod for 1.2.0.2 Sun Dec 08, 2013 11:22 am | |
| | |
|
| |
UKnowMe?
Messages : 51 Joined/Date d'inscription : 2012-10-08 Location/Localisation : Germany
Gema stats farthest jump:
| Subject: Re: Lua mod for 1.2.0.2 Sat Dec 14, 2013 4:15 pm | |
| Did you test them also with your binaries? Because they don't work for me. | |
|
| |
gear4
Messages : 28 Joined/Date d'inscription : 2013-04-03 Age : 27 Location/Localisation : English
Gema stats farthest jump:
| Subject: Re: Lua mod for 1.2.0.2 Sat Dec 14, 2013 4:38 pm | |
| yea, they work. I tried clang and gcc, on both Windows (mingw/clang) and Ubuntu | |
|
| |
Sponsored content
| Subject: Re: Lua mod for 1.2.0.2 | |
| |
|
| |
| Lua mod for 1.2.0.2 | |
|