Why is print() so expensive?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

Why is print() so expensive?

Post by Bindie »

Printing to the console, why so expensive? Curious.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Why is print() so expensive?

Post by s-ol »

Bindie wrote:Printing to the console, why so expensive? Curious.
Because, when you disable IO buffering, it has to push every single character through all the OS' rusty pipes.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: Why is print() so expensive?

Post by undef »

Expensive compared to what?
twitter | steam | indieDB

Check out quadrant on Steam!
Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

Re: Why is print() so expensive?

Post by Bindie »

S0ll0s: Right, since no memory is available.

Undef: Functions in general, math.random() kinda
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Why is print() so expensive?

Post by s-ol »

Bindie wrote:S0ll0s: Right, since no memory is available.
is that supposed to be sarcasm? Unbuffered IO is generally expensive.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

Re: Why is print() so expensive?

Post by Bindie »

Naw, no no. I didn't understand buffering had to do with memory. No memory = printing every single character then next and so on...
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

Re: Why is print() so expensive?

Post by I~=Spam »

Out of curiosity... why is unbuffered io used? Is it so that if love crashes the console will still have all output? Or is it something else?
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: Why is print() so expensive?

Post by undef »

Printing is mainly used for debugging purposes, so you usually wouldn't print out hundreds of lines of code per frame.
Therefore it isn't regarded as an efficiency impairment for game development.
twitter | steam | indieDB

Check out quadrant on Steam!
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

Re: Why is print() so expensive?

Post by I~=Spam »

undef wrote:Printing is mainly used for debugging purposes, so you usually wouldn't print out hundreds of lines of code per frame.
Therefore it isn't regarded as an efficiency impairment for game development.
Ahh that makes sense.
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Why is print() so expensive?

Post by s-ol »

I~=Spam wrote:Out of curiosity... why is unbuffered io used? Is it so that if love crashes the console will still have all output? Or is it something else?
Plus not having console debug output during tests running sucks a lot.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], pgimeno and 4 guests