Skip to content

Async Test Takes Much Longer Than Actual Runtime – Why? #139954

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

Closed
94Rahul opened this issue Apr 17, 2025 · 1 comment
Closed

Async Test Takes Much Longer Than Actual Runtime – Why? #139954

94Rahul opened this issue Apr 17, 2025 · 1 comment

Comments

@94Rahul
Copy link

94Rahul commented Apr 17, 2025

Hello Rustaceans! 👋

I’m currently writing a unit test for a simple async function that performs some string manipulation. When I run the function in my actual application using cargo run, it completes in about 1 second — as expected.

However, when I run the same function in a unit test (using #[tokio::test] or block_on), the test takes around 40 seconds to complete. I’m puzzled as to why there’s such a huge difference in runtime between the normal execution and the test environment.

Any advice, insight, or debugging tips would be greatly appreciated!

Thanks in advance! 🙏

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 17, 2025
@jieyouxu
Copy link
Member

For general Rust discussions (not specific to the Rust projects in this repo), consider asking on URLO or in the Community Discord or on zulip. The rust-lang/rust issue tracker is meant for specific issues pertaining to the language, compiler, rustdoc, and other projects living in this repo, but is not meant for general Rust discussions.

@jieyouxu jieyouxu closed this as not planned Won't fix, can't repro, duplicate, stale Apr 17, 2025
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants