【发布时间】:2012-11-18 01:09:52
【问题描述】:
最近我正在编写一些微基准代码,所以我必须打印出 JVM 行为以及我的基准信息。我用
-XX:+PrintCompilation
-XX:+PrintGCDetails
和其他获取 JVM 状态的选项。对于基准信息,我只是使用System.out.print() 方法。因为我需要知道我打印的消息的顺序和JVM的输出。
我只是在控制台打印出来就可以得到很好的结果,虽然JVM输出有时会撕掉我的消息,但是由于它们在不同的线程中,这是可以理解和接受的。
当我需要做一些批处理基准测试时,我想redirect the output into a file 和pipe (> in Linux system),并使用 python 从文件中获取结果并分析一下。
问题来了:
The JVM output always overlapped with the messages I printed in the Java application.它破坏了消息的完成。
知道如何处理这种情况吗?我需要both the JVM output and application output in the same place in order to preserve the sequence because it is important. And they do not overlap on each other so I don't lose anything.
【问题讨论】: