Jump to content




Is term.blit faster?


3 replies to this topic

#1 Jummit

  • Members
  • 306 posts
  • LocationJulfander Squad Studio

Posted 19 October 2017 - 02:38 PM

I just thought about which function I would use to draw some textures; term.blit or something like
paintutils.setBackgroundColor()
paintutils.setTextureColor()
term.write()
the wiki says
Although it is no faster than term.write() in its own right, in some circumstances it can reduce code length and speed execution by removing the need to make multiple term.setTextColor() / term.setBackgroundColor() calls.
but what are the 'circumstances'?

I loop through 100 draws.

Edited by Jummit, 19 October 2017 - 02:43 PM.


#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 19 October 2017 - 03:14 PM

blit is (IIRC) slightly slower than term.write. The ratio of setBackgroundColor / setTextColor calls to term.write calls will determine at what point it is faster to use setBackgroundColor / setTextColor vs term.blit.

For example, blit would be a terrible way to clear the screen whereas the other method would be a terrible way to draw a buffer with unknown content.

#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 20 October 2017 - 12:43 AM

I couldn't spot any measurable speed difference between write / blit. It wouldn't greatly surprise me if using blit to clear the screen is faster than using write, simply because it'd make a single setBackgroundColour call redundant.

(clear is obviously the "best" choice for that particular goal, but hey.)

#4 Dave-ee Jones

  • Members
  • 456 posts
  • LocationVan Diemen's Land

Posted 20 October 2017 - 04:52 AM

The worst thing when it comes to 100 draws in an indefinite loop is having the frame constantly flash with screen updates, so it makes sense to look for the fastest way. I'm trying my hardest to make my web browser only updates certain parts of the screen by either clearing a whole line at one time or clearing just a bit with 'print()' or something like that. Looks way nicer, especially if you have multiple windows (I have one for the web browser itself and another for the page, because the page is obviously a 'separate' bit of code that's a UI).





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users