Code Monkey home page Code Monkey logo

Comments (3)

fsaad avatar fsaad commented on June 5, 2024

Thanks for the runtime measurements. These numbers are in line with expectation for preprocessing floats, since the floating-point algorithm (which itself is not very optimized) is significantly more expensive than the integer arithmetic algorithm.

The implementation in C is much faster. We should consider using e.g., Cython to create a Python API.

from fast-loaded-dice-roller.

cloudbopper avatar cloudbopper commented on June 5, 2024

Ok, thanks.
FYI the runtime measurements only include sampling, not preprocessing. I also noted that using the alternative floating-point preprocessing algorithm mentioned in #4 resulted in runtimes much more comparable to the integer algorithm.

python -m timeit -s "from fldr.fldrf import fldr_preprocess_float_c as fldrf_preprocess; from fldr import fldr_sample; l = range(10000); x = fldrf_preprocess([1/len(l) for _ in l])" "fldr_sample(x)"

50000 loops, best of 5: 7.16 usec per loop

Thanks again for the great work.

from fast-loaded-dice-roller.

fsaad avatar fsaad commented on June 5, 2024

Thanks again for confirming. I will change the default implementation to use the alternative preprocessing algorithm in light of #4 and #5.

FYI the runtime measurements only include sampling, not preprocessing.

Good point, I missed the fact that your timeit script uses -s for "setup".

from fast-loaded-dice-roller.

Related Issues (8)

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.