How to turn off auto flush for println?

524 views
Skip to first unread message

peking2

unread,
Feb 12, 2013, 9:39:22 AM2/12/13
to scala...@googlegroups.com
Hi 

Auto flush is turned off in Java, but turned on in Scala. So Scala is very slow if there are lots of IO. Anyone knows how to turn off it in Scala? and any reason why it's set on by default?

Thanks
Gary

Simon Schäfer

unread,
Feb 12, 2013, 2:10:01 PM2/12/13
to scala...@googlegroups.com
How did it come to your mind that println is flushed? When I look to the sources I can't see any difference from println to System.out.println.

A call to println[1] is directly redirected to System.out.println[2].

[1]: https://github.com/scala/scala/blob/v2.10.0/src/library/scala/Console.scala#L234
[2]: https://github.com/scala/scala/blob/v2.10.0/src/library/scala/Console.scala#L75

Gary Zhao

unread,
Feb 12, 2013, 3:14:21 PM2/12/13
to Simon Schäfer, scala...@googlegroups.com
I saw this behavior on codeforces.com. Scala was very slow to print out iteratively. Someone told me it's because Scala was configured as "auto flush" and suggested to use mkString before print. I just did some test locally, but didn't see the slowness. Is it because of versioning? They are using 2.9.2 and I'm using 2.10.0? It was fixed somewhere between?

Codeforces: Scala compiler version 2.9.2
Local box: Scala code runner version 2.10.0

Thanks


--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Simon Schäfer

unread,
Feb 12, 2013, 3:22:19 PM2/12/13
to scala-user

On 02/12/2013 09:14 PM, Gary Zhao wrote:
I saw this behavior on codeforces.com. Scala was very slow to print out iteratively. Someone told me it's because Scala was configured as "auto flush" and suggested to use mkString before print. I just did some test locally, but didn't see the slowness. Is it because of versioning? They are using 2.9.2 and I'm using 2.10.0? It was fixed somewhere between?
I can't find any changes on this one in the commit history.

Gary Zhao

unread,
Feb 12, 2013, 4:46:35 PM2/12/13
to Simon Schäfer, scala-user
Thanks Simon. Will keep an eye on it to see if I can get some info more.


Reply all
Reply to author
Forward
0 new messages