←  Beta Testing

ComputerCraft | Programmable Computers for Minecraft

»

ComputerCraft Beta Versions - Download and...

Locked

Bomb Bloke's Photo Bomb Bloke 10 Apr 2015

Thought I might do some speed tests - it seems that window-based rendering is faster, but unfortunately not by much. It's difficult to measure the difference. Benchmark rendering scores go something like this on my system:

1.73 - Text: 10.45, Color: 29.95, Advanced: 19.45
1.73 (no multishell) - Text: 1.95, Color: 2.05, Advanced: 3.6
1.74pr20 - Text: 9.55, Color: 30.95, Advanced: 15.2
1.74pr20 (no multishell) - Text: 1.95, Color: 2.1, Advanced: 3.65

Bearing in mind that the numbers deviate a little bit with each run (typically less than ~0.5), the most obvious change is that the "advanced" score is down four points (bearing in mind that "low" is supposed to mean "good").

Under general use (eg writing a whole line with unchanging text / background colours), term.write() and term.blit() operate at very nearly the same speed - running a few tests, I found the winner to be quite random. On the other hand, if you want to print a string while quickly switching between colours (eg a unique text / background colour for every character in your line), blit offers a dramatic speed boost. For example, it's about ten times faster with an eight character string... and the difference would increase as the string got longer.

Windows naturally make use of term.blit() now (for the purpose of redrawing lines), but you really won't see much of a speed difference there unless there are multiple colours in use on the same line. The aforementioned benchmark script never creates such a scenario, so that happens to be mostly useless for the purpose of demonstrating the change.
Quote

dan200's Photo dan200 10 Apr 2015

View PostElvishJerricco, on 10 April 2015 - 01:40 PM, said:

View Postdan200, on 10 April 2015 - 12:36 PM, said:

Lua 5.2 has environments, you just can't change them after the function is created. You set them either using the 4th parameter to load (when compiling a function from code), or using the _ENV pattern I showed in the previous post (when declaring a new function). Everyone concerned they're losing something they absolutely need would do well to read what the lua manual has to say on the topic: http://www.lua.org/m...manual.html#2.2

I know very well how to use environments with 5.2. The issue is definitely minor and very niche, I'm not arguing against that. I'm merely pointing out that minor and niche is non-zero, and I have personally found several uses for setting environments on non-top-level-functions. Again, it's not major, so moving to 5.2 isn't the end of the world or anything. But it does take some justification.

again: you can create non-top-level-functions with custom environments using _ENV

View PostBomb Bloke, on 10 April 2015 - 01:52 PM, said:

Thought I might do some speed tests - it seems that window-based rendering is faster, but unfortunately not by much. It's difficult to measure the difference. Benchmark rendering scores go something like this on my system:

1.73 - Text: 10.45, Color: 29.95, Advanced: 19.45
1.73 (no multishell) - Text: 1.95, Color: 2.05, Advanced: 3.6
1.74pr20 - Text: 9.55, Color: 30.95, Advanced: 15.2
1.74pr20 (no multishell) - Text: 1.95, Color: 2.1, Advanced: 3.65

Bearing in mind that the numbers deviate a little bit with each run (typically less than ~0.5), the most obvious change is that the "advanced" score is down four points (bearing in mind that "low" is supposed to mean "good").

Under general use (eg writing a whole line with unchanging text / background colours), term.write() and term.blit() operate at very nearly the same speed - running a few tests, I found the winner to be quite random. On the other hand, if you want to print a string while quickly switching between colours (eg a unique text / background colour for every character in your line), blit offers a dramatic speed boost. For example, it's about ten times faster with an eight character string... and the difference would increase as the string got longer.

Windows naturally make use of term.blit() now (for the purpose of redrawing lines), but you really won't see much of a speed difference there unless there are multiple colours in use on the same line. The aforementioned benchmark script never creates such a scenario, so that happens to be mostly useless for the purpose of demonstrating the change.

Thanks for this. I guess i still need to optimise window.write/window.blit!
Quote

Tag365's Photo Tag365 10 Apr 2015

Would you like to merge my version of the edit script with the official version of it? I have the source for my version. Below is my version with more features.
Spoiler

Edited by Lyqyd, 10 April 2015 - 03:05 PM.
Quote

ElvishJerricco's Photo ElvishJerricco 10 Apr 2015

View Postdan200, on 10 April 2015 - 01:56 PM, said:

again: you can create non-top-level-functions with custom environments using _ENV

That's not really the same. I mean, functionally, it has the same effect. But the reason you actually call setfenv on non-top-level-functions is because you for some reason don't have access to its local scope. For example, LuaLua creates instance methods with their environments set to a special table. The functions are provided by the programmer, not anything the runtime has access to. So the runtime can't change or control the _ENV upvalue for these functions, meaning it relies strongly on the 5.1 environment model.

All in all we're not arguing anything important. You could update to 5.2 and I'd happily find another way around the problems that the 5.1 environment model can solve. It's just that it's not exceedingly rare to abuse the 5.1 model.

View PostTag365, on 10 April 2015 - 02:06 PM, said:

- snip -

Dude use a spoiler tag. That's a lot of text =P
Edited by ElvishJerricco, 10 April 2015 - 02:08 PM.
Quote

Bomb Bloke's Photo Bomb Bloke 10 Apr 2015

View Postdan200, on 10 April 2015 - 01:59 PM, said:

Thanks for this. I guess i still need to optimise window.write/window.blit!

I'm not sure there's that much left to improve... For what it's worth, I gave it a go but didn't have much luck.

Spoiler

Yeah, it's faster, but not by all that much - 8.5/30.5/14.5 on average.

Edit: Actually that code was broken. Fixed it... for what it's worth.
Edited by Bomb Bloke, 14 April 2015 - 12:55 AM.
Quote

Lignum's Photo Lignum 10 Apr 2015

Perhaps instead of using two strings to store the terminal display, it should use an array instead? Blitting would be way less complex that way and as a consequence probably also faster.
Quote

SquidDev's Photo SquidDev 10 Apr 2015

View PostLignum, on 10 April 2015 - 04:46 PM, said:

Perhaps instead of using two strings to store the terminal display, it should use an array instead? Blitting would be way less complex that way and as a consequence probably also faster.

Also Strings are immutable and so have to be reallocated every time a draw occurs. I don't know how great the performance increase would be (if any) if it was changed though.
Quote

Bomb Bloke's Photo Bomb Bloke 11 Apr 2015

"Two strings"?

Dividing line contents across a table would make it more complex, and I reckon the extra function calls required to do the spreading (and the recombining of the results) would do more to hurt matters than to help.
Quote

Lignum's Photo Lignum 11 Apr 2015

View PostBomb Bloke, on 11 April 2015 - 12:47 AM, said:

"Two strings"?

Dividing line contents across a table would make it more complex, and I reckon the extra function calls required to do the spreading (and the recombining of the results) would do more to hurt matters than to help.

I'm not talking about term.blit, I'm talking about how ComputerCraft stores the display internally. Currently it's done with two strings, one stores the text along with its colour, the other stores the background colours. Because of this the blit function is just a huge mess of string manipulation, which lead me to think that perhaps using an array could simplify it and thus eventually increase performance. But maybe that's just because I often (wrongly) associate messy code with bad performance.
Quote

Bomb Bloke's Photo Bomb Bloke 11 Apr 2015

Ah.

We'd been talking about getting the window API to operate at a speed closer to term.native(), so unfortunately Java-side changes won't help there.

I suppose something like the ".no_disk_startup" file check could be implemented, only to toggle multishell instead? That'd make the point moot, for those who care.
Quote

dan200's Photo dan200 13 Apr 2015

If your program needs native performance (and you're ok with being incompatible with multishell and other windowing based OSes), you can just redirect to term.native()
Quote

Phoenix323's Photo Phoenix323 18 Apr 2015

When will ComputerCraft update to forge 1.8
Quote

Creator's Photo Creator 18 Apr 2015

That would be really great. Oh and dan200 I want to thank you for making such a great mod. I thought me a lot of skills: lua and iron logic (very strong logic). I really think it is the best mod available ;)
Quote

Bomb Bloke's Photo Bomb Bloke 19 Apr 2015

Source for which part of it?

The Java-side of things is closed source.

But much of the code you get to play with - the majority of the APIs, shell, and so on - are written in plain Lua, and can be found within the assets folder of the mod archive itself.
Quote

Lyqyd's Photo Lyqyd 19 Apr 2015

In case the above post isn't clear, ComputerCraft is closed-source, so the source is not available anywhere. You could decompile the mod, but you cannot distribute modified versions of it.
Quote

Phoenix323's Photo Phoenix323 20 Apr 2015

ok thanks
Quote

JoeNoIce's Photo JoeNoIce 23 Apr 2015

not to be a bother but when will 1.8 version of the mod be out?
Quote

Cranium's Photo Cranium 23 Apr 2015

View Post10xephos01, on 23 April 2015 - 09:26 PM, said:

not to be a bother but when will 1.8 version of the mod be out?
Whenever it's out.
Quote

JoeNoIce's Photo JoeNoIce 24 Apr 2015

View PostCranium, on 23 April 2015 - 11:07 PM, said:

View Post10xephos01, on 23 April 2015 - 09:26 PM, said:

not to be a bother but when will 1.8 version of the mod be out?
Whenever it's out.

1 lol
and 2 when did you get moderator rank on this forum?
Quote

Bomb Bloke's Photo Bomb Bloke 24 Apr 2015

View Post10xephos01, on 24 April 2015 - 06:15 AM, said:

when did you get moderator rank on this forum?

Believe it or not, that's actually documented.
Edited by Bomb Bloke, 24 April 2015 - 07:20 AM.
Quote
Locked