Giter Club home page Giter Club logo

perfprof.py's Introduction

This is a Python script for printing performance profiles as defined by E. D. Dolan and J. J. Moré.

It is based on perfprof.m from the MATLAB Guide by D. J. Higham and N. J. Higham.

Performance profiles

Performance profiles are a mechanism to visualise the performance of multiple algorithms on multiple test problems. Given m problems and n algorithms, we're interested in the relative performance of all algorithms across the entire problem set.

Let t = t(i, j) > 0 be a measure of the performance of solver j on problem i, where lower means "better". Common choices for t are:

  • execution/CPU time;
  • number of iterations (assuming the algorithms are iterative);
  • the number of evaluations of some reference function (e.g., the ordering predicate in a sorting algorithm, or the objective function in an optimisation algorithm).

Given this data, a typical performance profile may look like this:

Example

Each algorithm has one line plot, where a point (x, y) means that, for x of the problem set, the algorithm in question was within a factor of y of the respective best algorithm. For example:

  • the point ≈(1, 0.6) means that Alg2 was the fastest algorithm on around 60% of the problem set;
  • the point ≈(1.5, 0.4) means that Alg3 was within a factor of 1.5 of the respective best algorithm for 40% of problems;
    • note that the "best" algorithm may be different for each problem;
  • the point ≈(1.5, 0.95) means that Alg1 was within a factor of 1.5 of the respective best algorithm for 95% of problems;
  • etc.

Generally speaking, an algorithm is considered efficient (relative to the others) when its performance profile comes close to the top left corner (1, 1).

It is possible for algorithms to fail on certain problems. This can be achieved by simply setting the performance measure t(i, j) to +inf or NaN.

Usage examples

import matplotlib.pyplot as plt
import perfprof

palette = ['-r', ':b', '--c', '-.g', '-y']

perfprof.perfprof(data, palette)
plt.show()

Marking y-intercepts

Markers can be inserted using the standard matplotlib pattern.

import matplotlib.pyplot as plt
import perfprof

palette = ['o-r', 'o:b', 'o--c', 'o-.g', 'o-y']

perfprof.perfprof(data, palette, markersize=4, markevery=[0])
plt.show()

Displaying legends

Legends can be displayed using matplotlib.pyplot.legend.

import matplotlib.pyplot as plt
import perfprof

palette = ['o-r', 'o:b', 'o--c', 'o-.g', 'o-y']
legend = ['Algorithm 1', 'Algorithm 2']

perfprof.perfprof(data, palette, markersize=4, markevery=[0])
plt.legend(legend)
plt.show()

Why another implementation?

Multiple implementations of performance profiles already exist in the public domain.

The design of perfprof was driven by a few key desires:

  • Simplicity: provide a clearly scoped, easy to use implementation that integrates with matplotlib;
  • Flexibility: unlock the full power of matplotlib for plot styling, legends, subplots etc.;
  • Robustness: the implementation must work in all edge cases including inf, NaN, etc.;
  • Usability: full Python3 compatibility and sensible defaults where possible.

perfprof.py's People

Contributors

dmsteck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 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.