Comments (11)
The various string-generation strategies are now Send + Sync
as of 0.3.2.
I also did look into the performance of string generation, and I believe the main bottleneck is actually character generation due to the inefficient way it accomplishes biasing towards particular characters. Changing that will likely require breaking backwards compatibility, so I'll make another pass at that at a later time.
from proptest.
I've moved the regex performance concerns to a separate issue (#16) since the problem referenced by the title of this one has been fixed.
from proptest.
also, any advice on speeding up generation of random strings? I'm seeing significant (i.e. 10x) slowdowns compared to quickcheck + regex_generate.
from proptest.
one thing I did: reduce the number generated for tests that don't need a large number. Very hard to do with quickcheck!
from proptest.
Strategies don't implement Sync
I originally wanted to leave the possibility of using interior mutability within a strategy. But as I found out trying to implement prop_recursive
with it, you can't usefull track state in a strategy anyway, so I don't think there's any reason not to add Sync
at this point.
seeing significant (i.e. 10x) slowdowns compared to quickcheck + regex_generate
That's somewhat expected. Proptest needs to build and retain a more complicated structure for shrinking to work correctly. The generation could also benefit a lot from small string optimisation; currently, each individual element of the regex becomes its own Vec<u8>
, so you may be paying for an enormous amount of allocations depending on the regex. I'll look into improving this soon.
from proptest.
Thanks for the replies. It would be nice to add Sync.
As for the slowdown, I think it's mostly fine -- obviously faster is always better :)
It would probably be worth documenting eventually though, especially if a solution cannot be found.
from proptest.
It turns out that adding Strategy: Send + Sync
would actually be pretty painful as combinators like prop_map
would need to require the closures to be Send + Sync
. Instead, I'm just fixing the immediate problem which was specific to the regex strategy, which used Box<Strategy>
under the hood and so erased the OIBITS. I'm also adding a conventional way to make a Box<Strategy + Send + Sync>
so external users can get the same benefit.
The only other remaining internal use of BoxedStrategy
is in prop_recursive()
, but I'm not sure what could be done there since switching to the Send + Sync
version would restrict how people could use that combinator.
from proptest.
@vitiral Would you be able to provide the regex in question? I started looking into optimising the string generation, but the regex I tried ([0-9]{4}-[0-9]{2}-[0-9]{2} .*
) ended up being faster than I anticipated (~9μs per iteration), so it would help to have a slow-but-realistic test case.
from proptest.
Here is the regex I am using:
const GEN_NAME_RE: &str = r#"(?ix)
(REQ|SPC|TST)- # the type followed by `-`
([a-z0-9_]{1,20}-){0,8} # an optional number of `elem-` elements
[a-z0-9_]{1,20} # required final element
"#;
from proptest.
originally I was using *
instead of the ranges {1,20}
or {0,8}
. That was slow, so I adjusted the ranges to (I think) up to 50 and then down to 20/8.
Hope that helps!
from proptest.
Thanks! Wow, you are really responsive on these issues. Hope they were helpful for you as a lib designer!
from proptest.
Related Issues (20)
- First-class support for async functions
- The type 'EasyCashIdentity.EntityLayer.Concrete.AppUser' cannot be used as type parameter
- rust-analyzer doesn't like the derive(Arbitrary) generated code for enums HOT 1
- Zero Examples of `impl Arbitrary` ? HOT 3
- Finite state machines HOT 1
- proptest_derive triggers non-local impl nightly warning HOT 1
- Update "shrinks to" comment on the same seed failures HOT 1
- Panic on empty ranges during strategy creation HOT 3
- Don't require `Arbitrary::Parameters` to implement `Default` HOT 4
- Recursive `arbitrary` calls HOT 3
- Change verbosity of shrink disabled and persisted failure messages HOT 3
- Provide access to state for (debug) printing transitions HOT 5
- feat: add option to interrupt test runner HOT 2
- derive macro for Arbitrary is hard to find HOT 4
- Attribute macro #[property_test] available in docs, but undocumented and behind undocumented feature HOT 1
- Lift MSRV to 1.70 to relax dependency on trybuild
- RangeInclusive of floats containing one element panics
- Improve logging for state machine testing
- The ` state_machine_echo_server` example does not compile HOT 2
- Proptest logging
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 proptest.