Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer benchmark data to use from positional arguments #6

Open
eriknw opened this issue Jun 21, 2014 · 3 comments
Open

Infer benchmark data to use from positional arguments #6

eriknw opened this issue Jun 21, 2014 · 3 comments

Comments

@eriknw
Copy link
Member

eriknw commented Jun 21, 2014

It is very common to run the same benchmark code with different input. Currently, a separate benchmark is required for each input. I would like to be able to define a single benchmark function, and the prefix of the input data is given by the name of the positional argument:

data_empty = 0
data_small = 10
data_large = 10000

def bench_zeros(data):
    zeros(data)

The results need to be displayed cleanly in the output table. It should also be possible to provide multiple arguments, and all combinations of input should (probably) be benchmarked. I would be happy to begin with only supporting a single positional argument if it makes things easier.

@mrocklin
Copy link
Member

Maybe keyword arguments that are lists are assumed to be different cases?

def bench_zeros(data=[0, 10, 10000]):
    zeros(data)  # actually gets called with 0, then 10, then 10000

I think IPython's interact might be a relevant thing to copy here.

@eriknw
Copy link
Member Author

eriknw commented Jun 21, 2014

Which IPython interact are you referring to? A quick search reveals several interact occurrences in IPython's API and code.

@mrocklin
Copy link
Member

There is in interact function commonly used as a decorator. I guess it's
kinda described here
http://nbviewer.ipython.org/github/ipython/ipython/blob/2.x/examples/Interactive%20Widgets/Index.ipynb
but honestly you can't describe it well in a static link.

I recommend opening the IPython notebook and then running a single cell
with these contents

from IPython.html.widgets import interact

@interact
def foo(name=['Alice', 'Bob', 'Charlie']):
print "Hello, %s!" % name

On Sat, Jun 21, 2014 at 11:38 AM, Erik Welch notifications@github.com
wrote:

Which IPython interact are you referring to? A quick search reveals
several interact occurrences in IPython's API and code.


Reply to this email directly or view it on GitHub
#6 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants