rust-lang / measureme

Support crate for rustc's self-profiling feature
Apache License 2.0
333 stars 48 forks source link

Summarize panics if piped into head #31

Open Darksonn opened 5 years ago

Darksonn commented 5 years ago

Summarize prints a very long table so I piped it into head to get the start of the output, however it panics:

$ ~/src/measureme/target/debug/summarize pid-8987 | head
+------------------------------------------+-----------+-----------------+------------+------------+--------------+-----------------------+
| Item                                     | Self time | % of total time | Item count | Cache hits | Blocked time | Incremental load time |
+------------------------------------------+-----------+-----------------+------------+------------+--------------+-----------------------+
| LLVM_emit_obj                            | 3.72s     | 44.144          | 152        | 0          | 0.00ns       | 0.00ns                |
+------------------------------------------+-----------+-----------------+------------+------------+--------------+-----------------------+
| LLVM_module_passes                       | 873.62ms  | 10.379          | 152        | 0          | 0.00ns       | 0.00ns                |
+------------------------------------------+-----------+-----------------+------------+------------+--------------+-----------------------+
| LLVM_make_bitcode                        | 608.96ms  | 7.235           | 152        | 0          | 0.00ns       | 0.00ns                |
+------------------------------------------+-----------+-----------------+------------+------------+--------------+-----------------------+
| typeck_tables_of                         | 484.63ms  | 5.758           | 953        | 0          | 0.00ns       | 0.00ns                |
thread 'main' panicked at 'Cannot print table to standard output : Broken pipe (os error 32)', /home/alice/.cargo/registry/src/github.com-1ecc6299db9ec823/prettytable-rs-0.8.0/src/lib.rs:194:23
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
marieell commented 3 years ago

Maybe the easiest and nicest would be to not use prettytable and not buffer output if stdout is not a tty?