Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Only async is used from the options passed into Benchmark.prototype.run(options). #65

Open
Myaushka opened this issue Feb 11, 2014 · 5 comments

Comments

@Myaushka
Copy link

I see this line inside of run(options) that obviously overrides options that are passed in:
options = { 'async': ((options = options && options.async) == null ? me.async : options) && support.timeout };

The documentation does not say that only the async option will be used.

What is the reason for this? It looks intentional; however, I spent a couple of hours debugging before I gradually concluded that my options were not being used, so I'm very frustrated.

@bnjmnt4n
Copy link
Member

Basically what this line does is check if you have enabled the async option. Otherwise it will use the default, which is false. It also checks to make sure timeouts are supported.

@jdalton
Copy link
Member

jdalton commented Feb 11, 2014

The documentation does not say that only the async option will be used.

It is the only option shown and the only option supported. We should make this more clear using JSDoc. So I'll mark this as a doc bug.

@Myaushka
Copy link
Author

Thanks; it's true that it was the only thing shown, and yes, it looks deliberate and "by design" in the code, but examples are not usually exhaustive.

For what it's worth, I was trying to capture the benchmark itself in one of the options' callbacks. This would not be relevant except that I'm using Benchmark.js via Script#, so I was trying to work around the C# scoping rules.

@ghost
Copy link

ghost commented Jul 8, 2015

Is it really the idea to set all other options like this?

Benchmark.options.maxTime = 1;

Edit: If you use a benchmark suite, then the correct way is to pass the options to add():

new Benchmark.Suite()
            .add('...', function () {
                // ...
            }, {
                maxTime: 1
            })

@jdalton
Copy link
Member

jdalton commented Jul 8, 2015

@joelrich

Is it really the idea to set all other options like this?

Benchmark.options.maxTime = 1;

Default options yep.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants