These are chat archives for rust-lang/rust

30th
Mar 2019
Brian Knapp
@knappador
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
@invis87
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.

rayon::iter::repeat(0)
        .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
@vorner
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
@invis87
Mar 30 18:53
hmm, thanks, will take a look
Michal 'vorner' Vaner
@vorner
Mar 30 19:39
Put it inside Arc or as a global?
Denis Lisov
@tanriol
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
@knappador
Mar 30 21:19
@tanriol to create a true either-or switch out of --disable-defaults. This is what I ended up with: https://github.com/e-nguyen/shaderc-rs/pull/1/files
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
@mortimr
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
@knappador
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