Skip to content
This repository has been archived by the owner on Dec 29, 2021. It is now read-only.

Takes ~300ms to run 1 invocation #100

Closed
rcoh opened this issue Apr 7, 2018 · 4 comments
Closed

Takes ~300ms to run 1 invocation #100

rcoh opened this issue Apr 7, 2018 · 4 comments
Labels

Comments

@rcoh
Copy link

rcoh commented Apr 7, 2018

  • assert_cli version: 0.5
  • Rust version: 1.25.0
  • OS and version: Ubuntu 16.04
    Unfortunately, cargo run takes at minimum about 300ms on my computer:
➜  angle-grinder git:(master) ✗ time cargo run --bin agrind -- '* | json | count' --file test_files/empty
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
     Running `target/debug/agrind '* | json | count' --file test_files/empty`
No data
cargo run --bin agrind -- '* | json | count' --file test_files/empty  0.22s user 0.06s system 92% cpu 0.307 total

It makes it impractical to run hundreds of integration tests with assert_cli.

I'm not positive what a better way would be -- I guess running the binary in dist directly if it exists?

@killercup
Copy link
Collaborator

Hm, indeed. cargo run adds ~300ms overhead on my machine as well (on macOS). That's quite unfortunate! Executing the binary directly takes less than 1ms, though, so making sure everything is compiled correctly and then executing with the then-known path should be a good workaround.

We should absolutely add this to the docs. And I'll ask the cargo team if there is a way to use cargo's "find binary" feature without having it check if it needs to compile things (which I guess is what's taking so long -- --locked --frozen doesn't speed things up).

@epage
Copy link
Collaborator

epage commented Apr 7, 2018

We should absolutely add this to the docs. And I'll ask the cargo team if there is a way to use cargo's "find binary" feature without having it check if it needs to compile things

Another use case for such a feature is packaging. Looking into this is coming up on my plate for packaging.

@killercup
Copy link
Collaborator

cargo issue: rust-lang/cargo#5315

@epage epage added the bug label Apr 7, 2018
epage added a commit to epage/assert_cli that referenced this issue May 25, 2018
This switches us from using `cargo run` to `cargo build`, reading where
the binary is placed, and callin that instead.

Fixes assert-rs#95 because the user changing the `CWD` doesn't impact `cargo
build`.

Fixes assert-rs#79 because there is no `cargo` output when capturing the user's
stdout/stderr.

Fixes assert-rs#51 because the user changing the environment doesn't impact
`cargo build`.

This is a step towards working around assert-rs#100 because we can allow a user
to cache the result of `cargo build`.
@epage
Copy link
Collaborator

epage commented May 29, 2018

The responsibility for this is moving to assert_cmd and tis will be addressed in assert-rs/assert_cmd#6

assert_cli is going to morph into a wider-focused tool, including things like assert_fs. See #41

@epage epage closed this as completed May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants