Git Product home page Git Product logo

Comments (6)

piotrmurach avatar piotrmurach commented on May 23, 2024

Hi,

Thanks for using this gem!

This gem should have no impact on how your records are saved. It has no dependency on external environment such as Rails, databases etc... It simply calls a block, the expectation, a number of times and each time it executes the block it measures the time. Therefore, the implication is that if you setup your DB once before the expectation is executed, and your foo.bar code has side effects including modifications to DB, then it is no surprise that it fails to execute correctly on the second block evaluation.

The rspec matchers perform no mutation of your database as they have no understanding of any of your code. This gem can be used in any context to execute a function. If the function is pure then you don't need to worry, however in your case you have clear DB mutations and hence keeping all the setup in the block is the only way to ensure that each block evaluation starts in the same state.

Hope this makes sense!

from rspec-benchmark.

tjwallace avatar tjwallace commented on May 23, 2024

I'm having a similar problem. Could it be because the benchmark-perf gem runs the block to be timed in a sub process?

from rspec-benchmark.

piotrmurach avatar piotrmurach commented on May 23, 2024

@tjwallace It could be or it could not be, I don't know. Would you have time to code up a minimal example using active record and sqlite that replicates the problem you're having and open a new issue? I would like to have something to poke around and I'm sure we can get to the bottom of it.

from rspec-benchmark.

tjwallace avatar tjwallace commented on May 23, 2024

@piotrmurach done, see issue #10

from rspec-benchmark.

piotrmurach avatar piotrmurach commented on May 23, 2024

@tjwallace Magic! Thank you.

from rspec-benchmark.

5minpause avatar 5minpause commented on May 23, 2024

Thank you @tjwallace

from rspec-benchmark.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.