These are chat archives for rust-lang/rust

Mar 2019
Brian Knapp
Mar 30 17:57
Can a Cargo feature be set to happen when a feature is disabled? I realize this is something that would normally done with two features, but I'm supporting an existing use case and tryting to preserve API
Aleksandrov Vladimir
Mar 30 18:50

is there a way to calculate number of times one particular function calls? I want to check performance of my program in concrete machine. The problem that I use rayon crate to consume all CPU.

        .map(|_| generate_some_data())
        .map(|data| do_work(data))

How can I calculate how many times function do_work was called?

(and do not harm performance significantly)
Michal 'vorner' Vaner
Mar 30 18:52
invis87: Put an AtomicUsize somewhere reachable from it and increment it with fetch_add(1, Ordering::Relaxed).
Or use a library for metrics, if you want to instrument more of your code (I'm quite fond of dipstick)
Aleksandrov Vladimir
Mar 30 18:53
hmm, thanks, will take a look
Michal 'vorner' Vaner
Mar 30 19:39
Put it inside Arc or as a global?
Denis Lisov
Mar 30 19:50
@knappador Do you need to enable a feature if another one is disabled, or just to compile some code?
Brian Knapp
Mar 30 21:19
@tanriol to create a true either-or switch out of --disable-defaults. This is what I ended up with:
While the sys crate theoretically should be independent, I needed it to implement a behavior that is being deprecated from the newly spun off shaderc-rs crate
Iulian Rotaru
Mar 30 22:17
How weird does it sound to also have a package.json in my rust project to access dev tools (mainly for the commit linter and changelog generator from conventional commits) that do not exist in rust ?
Brian Knapp
Mar 30 22:57
@mortimr usually stuff like that lives in gists, blog posts, somewhere in .gitignore
It's too personal for being generally distributed in the repo