Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a colored output on Windows? #267

Closed
alekseysidorov opened this issue Feb 16, 2019 · 12 comments
Closed

Add a colored output on Windows? #267

alekseysidorov opened this issue Feb 16, 2019 · 12 comments
Labels
Beginner Suitable for people new to Criterion.rs Enhancement

Comments

@alekseysidorov
Copy link

At the moment criterion output on windows doesn't support colors, thus it is harder to understand benchmark results that on *nix.

@bheisler bheisler added Enhancement Beginner Suitable for people new to Criterion.rs labels Feb 16, 2019
@bheisler
Copy link
Owner

Hey, thanks for the suggestion! That seems like a reasonable feature to add, but I don't typically develop on Windows. Pull requests would be welcome, though!

@vpetrigo
Copy link
Contributor

vpetrigo commented Feb 26, 2019

Hey @alekseysidorov,

Would you please specify which Windows version you mean? I'm on Windows 10 (build 1809 - 10.0.17763) and color output works fine for me.

So that's is the short snippet I added into the report.rs:

    #[test]
    fn test_windows_colors() {
        let cli = CliReport::new(false, true, false);
        let hello = "Hello";

        println!("{}", cli.green(hello.to_string()));
        println!("{}", cli.red(hello.to_string()));
    }

And how it looks in the plain cmd:

Hello Test

That's how the benchmarks output of criterion.rs itself looks like in my cmd:

Criterion Bench

I may elaborate on that, but need more info about the system you experienced such an issue. 😄

@vpetrigo
Copy link
Contributor

Small update on that: seems like that issue with lack of colors in Windows terminals has been fixed in rust-lang/cargo#4722. So I was able to reproduce OP's issue with Rust 1.26.0, but it went away after I switched back to the stable-msvc toolchain.

@alekseysidorov
Copy link
Author

I am using rustc version 1.32.0 and powershell as shell. Sometimes I run tests in git-bash but I never tried to run criterion benchmarks in cmd.exe.

@vpetrigo
Copy link
Contributor

vpetrigo commented Mar 1, 2019

@alekseysidorov try to run you benchmarks with the following command: cargo bench -- --color=always. I guess there are some issues with traking PowerShell color output features.

@alekseysidorov
Copy link
Author

With additional argument works fine in powershell
2019-03-01_12-14-14
But without them colors do not work:
cmd.exe
2019-03-01_09-58-03
powershell
2019-03-01_09-58-22

@vpetrigo
Copy link
Contributor

vpetrigo commented Mar 1, 2019

Would you specify which OS version you use and Criterion.rc?

@vpetrigo
Copy link
Contributor

vpetrigo commented Mar 1, 2019

@alekseysidorov @bheisler I found potential fix, so will work on a PR.

@alekseysidorov
Copy link
Author

Sorry for delay ^_^, my OS is Windows 10 release 1809 (17763.316)

@alekseysidorov
Copy link
Author

And I used a master branch of criterion-rs.

@bheisler
Copy link
Owner

bheisler commented Mar 5, 2019

Hey, thanks for the patience - I've been on vacation for a week and a half or so.

This fix looks good to me. @alekseysidorov Does this solve the issue for you?

@bheisler
Copy link
Owner

Closing this; it seems to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Beginner Suitable for people new to Criterion.rs Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants