Coder Social home page Coder Social logo

Newbie question about benchmark.js HOT 5 CLOSED

chenglou avatar chenglou commented on September 13, 2024
Newbie question

from benchmark.js.

Comments (5)

tomByrer avatar tomByrer commented on September 13, 2024

http://benchmarkjs.com/docs#prototype_cycles maybe?

from benchmark.js.

jdalton avatar jdalton commented on September 13, 2024

You can specify the minSamples to collect, the default is 5, but you can't specify how many times an operation should run, benchmark.js handles that for you. It automatically repeats a test until it reaches the minimum time needed to take an accurate measurement (usually ~50ms).

from benchmark.js.

chenglou avatar chenglou commented on September 13, 2024

Thanks. Perhaps I'm not doing this correctly, but say I'm testing two linked list implementations and I need both to do remove() the exact same amount of time (beyond that they'd be removing nothing), how would I do that?

from benchmark.js.

jdalton avatar jdalton commented on September 13, 2024

The setup, teardown, and fn have access to the repeat count via this.count.

So in your setup you would add this.count number of items, then in your fn you would call lib.remove(item). That way when lib.remove(item) is called this.count times it will remove exactly how many are added in the setup. The setup is not counted against the time of the fn.

from benchmark.js.

chenglou avatar chenglou commented on September 13, 2024

That's what I was searching for, thanks.

from benchmark.js.

Related Issues (20)

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.