Comments (4)
I had a go at this (as someone who doesn't really know Rust), and the problem I'm hitting is that the floaty From trait has some cleverness to list which types can be safely promoted to floats (and so don't need Options
around the result: http://japaric.github.io/float.rs/src/cast/lib.rs.html#253
That means that lots of the uses of Floaty::cast
in the stats crate return Floaty
.
As far as I can tell num-traits doesn't have this - the ::from
method always returns an Option
so I'm having to sprinkle lots of .unwrap()
s in to compile (which I'm sure is wrong). What's the right way to do this?
Hmm, also num_traits::float::Float
isn't Sync
, so the threads in univariate and bivariate can't share them. There's an issue to implement it though: rust-num/num-traits#8
Maybe num_traits isn't ready to replace Floaty yet?
from criterion.rs.
Hmm. That's unfortunate, I thought num-traits was going to be more or less a drop-in-replacement.
For the options, I think it should be mostly safe to just unwrap them, but it's a bit ugly. You could perhaps try to add a function (or potentially a trait) to keep all of the cast-and-unwrap code in one place until something equivalent is added to num-traits.
As for the Sync, I think it should be possible to add an explict Sync bound to the generics for that function. Again, it can be removed later, when num-traits catches up.
Honestly, num-traits probably isn't ready to replace Floaty yet, but it is actively maintained and doesn't require nightly like Floaty does. I think the best option for now is to make the switch anyway and try to make it so we can remove the workarounds easily later.
Thanks for your help.
from criterion.rs.
Having thought about it some more, I think a good way to do this would be to add a new trait (stats::float::Float
maybe) which extends num-traits' Float and adds the Sync bound and the necessary safe casts and change all of the stats code to use that instead. That way we can rely on num-traits for most of the code and it will be easy to replace our extension trait with num-traits' Float when they provide everything that Criterion needs.
from criterion.rs.
Yeah, that makes sense, I'll have a go at that sometime soon.
from criterion.rs.
Related Issues (20)
- --profile-time doesn't work HOT 1
- panic in drop
- Custom Iter with async setup and non-async benched value
- "cargo bench -- <filter>" does not actually filter the benchmarks
- Can't call a function for the benchmark from the crate inside a Rust workspace HOT 1
- Quickstart instructions still use criterion 0.4 HOT 1
- Benchmarking With One function result as Input
- Help needed? HOT 5
- Found argument '--bench' which wasn't expected
- Benchmarks not running when specifying benchmark name
- Skip setup for filtered out benchmarks
- Allow running benchmarks as tests under Miri
- Segfault in code that passes valgrind/asan HOT 1
- Save baseline does not work in 0.5 HOT 4
- Can clap be made optional? HOT 1
- Can I limit number of threads to use in benchmark? HOT 1
- Enable Github "Discussions"
- "How Should I Benchmark Small Functions?" section in book is nonsense HOT 1
- script / plugin to easily interpret benchmark with OpenAI / LLM
- Does criterion store the binary some for later investigations with valgrind or something else?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from criterion.rs.