Giter Club home page Giter Club logo

backend-benchmarking-activity's Introduction

What time is it?

For this activity, you will be measuring the performance characteristics of various sorting algorithms, defined in sort.py.

Timeit

Experiment with the timeit module by seeing how long the various sort implementations take. While you could modify sort.py directly, you can take advantage of the command line interface to test different algorithms:

$ python2 -m timeit "from sort import quick_sort as sort, random_seq; print sort(random_seq)"

The reason for the as keyword is so that you can change search algorithms in one place instead of two:

In fact, you can take advantage of command substitution by typing the following in a terminal and pressing enter:

$ ^quick^merge

Where the word after the first ^ signifies the word in the previous command to replace, and the word after the second ^ signifies the word to use as a replacement.

Doing so will result in the following command:

$ python2 -m timeit "from sort import merge_sort as sort, random_seq; print sort(random_seq)"

Special Note when running your timing profile on the bubble_sort algorithm: Don't give up! Your computer is not stalled in an infinite loop. Waaaaaiiiiiitttttt for it ....

cProfile

You can measure the performance of all algorithms by using the cProfile module and running the script:

$ python2 -m cProfile -o sort.profile sort.py

You can then pass the resulting sort.profile file to the pstats module:

$ python2 -m pstats sort.profile

Take a look at this article for help on how to analyze statistics.

Credits

We've adapted the algorithms from Popular Sorting Algorithms.

backend-benchmarking-activity's People

Contributors

aphonicchaos avatar madarp avatar

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.