This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Sewbacca's profile picture

Term.blit

Started by Sewbacca, 02 December 2016 - 08:07 PM
Sewbacca #1
Posted 02 December 2016 - 09:07 PM
Hey guys,
imagine two clocks in the same line.
Is it faster to rewrite the full line?
Or just the clocks?
And imagine three clocks in one line.
When is it faster to rewrite the full line, and when just a part of the line.
How could i code an algorithm?

Thanks in advance
Sewbacca
Lupus590 #2
Posted 02 December 2016 - 09:33 PM
you could make some measurements:
  1. get a big monitor and put a clock on each line
  2. copy the time into a variable, update all of the clocks with one method
  3. get the difference in time from when you started, divide by the number of lines to get the time per line
  4. repeat 2-3 for a different method, compare values of time per line
  5. repeat 1-4 with a additional clock per line
KingofGamesYami #3
Posted 02 December 2016 - 09:35 PM
There is no performance difference between blitting a partial line as opposed to a full line.
Sewbacca #4
Posted 03 December 2016 - 12:33 AM
There is no performance difference between blitting a partial line as opposed to a full line.

But there is one, if i blit two partials in one line?
So this:

term.blit(time1, tCol, bCol)
term.setCursorPos(nWidth - #sText, 1)
term.blit(time2, tCol, bCol)
is slower than this:

term.blit(time1 .. (' '):rep(nSpaces) .. time2, tCol, bCol)
?
KingofGamesYami #5
Posted 03 December 2016 - 01:34 AM
Yes. Blitting twice will, of course, take more time than blitting once.
Sewbacca #6
Posted 03 December 2016 - 08:26 PM
There is no performance difference between blitting a partial line as opposed to a full line.

Why is the duration of blitting one little piece equal to the duration of blitting a full line?
Edited on 03 December 2016 - 07:27 PM
KingofGamesYami #7
Posted 03 December 2016 - 08:52 PM
ComputerCraft updates the entire line either way.
Sewbacca #8
Posted 03 December 2016 - 10:46 PM
ComputerCraft updates the entire line either way.
Thanks