bat-test icon indicating copy to clipboard operation
bat-test copied to clipboard

Is it possible to turn off enter watching?

Open slifin opened this issue 3 years ago • 2 comments

This could very well be my usage of bat-test being incorrect but I have some code where (bat-test) is called and then that's invoked from a boot-test, when I run VisualVM on that boot process this section appears to take a fair amount of CPU:

https://github.com/metosin/bat-test/blob/master/src/metosin/bat_test/impl.clj#L18

Since we point bat-test at all our tests anyway I don't think this section of code is doing much for us? Is it possible to optionally disable or avoid it?

slifin avatar Feb 01 '22 15:02 slifin

FWIW the CLI interface I proposed has an :enter-key-listener arg, might be worth duplicating this feature for Leiningen.

https://github.com/metosin/bat-test/pull/44/files#diff-332c74e4e4ec874dff7255a66cae0cebaab586ed1d0bc46029090d65cc0f1493R225

frenchy64 avatar Feb 02 '22 23:02 frenchy64

If VIsualVM is writes to app standard input it would explain why it takes lost of CPU time. If not, it is just overhead from the debugger, but that seems unlikely, as the read call in the loop should be just blocking until there is more input to read.

I tried to check java.util.Scanner implementation and looks like it isn't doing anything else that just reading System.in. Though difference is that it is reading input into CharBuffer and then handling all read bytes, instead of calling read for one byte at a time. That might be more efficient in a case where lots of stuff is written to std in.

But makes sense to just have option to disable this.

Deraen avatar Mar 02 '22 08:03 Deraen