Is there a way to consistently measure cargo check times, apart from my gut feeling?

⚓ Rust    📅 2025-10-09    👤 surdeus    👁️ 5      

surdeus

I had troubles with compile times before. Running cargo check --timings made me notice one executable was particularly slow. I moved it into another crate, and timings dropped like by a factor of 4. From being unable to save & check (the editor would timeout waiting the language server), I got to acceptable latency in the editor.

I started a new project, and tested Zerocopy. Then tried switching to Serde. Doing this, I replaced custom serializations with derive macros (Serialize, Deserialize). Saving latency grew times more again. Like several seconds between Ctrl+S and seeing colored underlines appear or go away.

I understand that cargo llvm-lines is irrelevant here (it does not include how many times derive macros run), just how much code they produce. (And in my tests, lines count grew by 14%, not n times, as I see in the editor.)

cargo check --timings also seems to not reflect anything, because both versions, with Zerocopy & my own serializers, and Serde's derive macros, saved roughly the same time, like 27s from scratch, and 2.7s incrementally.

Is there a way to measure this incremental save-check latency in Rust projects at all?

1 post - 1 participant

Read full topic

🏷️ Rust_feed