Skip to content

Conversation

@dantleech
Copy link

This is a quick and dirty PR that:

  • implements data providers
  • allows multiple iteration speciications
  • forces to prefix the method with perform.

If it is interesting I could break it up into separate PRs and write it properly...

For example:

    public function provideFullTreeTraversal()
    {
        return array(
            array(10, 100),
            array(20, 200),
        );
    }

    /**
     * @dataProvider provideFullTreeTraversal
     * @iterations 1
     * @iterations 10
     */
    public function performFullTreeTraversal($from, $to)
    {
        $rootNode = $this->getSession()->getRootNode();
        $this->iterateNode($rootNode);
    }

Produces:

PHPCR\Benchmark\Suites\Reading\TraversalEvent
    Method Name                        Iterations   Average Time     Ops/second
    ---------------------------------  ------------ ---------------- -------------
    FullTreeTraversal(from=10,to=100): [1         ] [0.0515341758728] [19.40460]
    FullTreeTraversal(from=10,to=100): [10        ] [0.0038705348969] [258.36222]
    FullTreeTraversal(from=20,to=200): [1         ] [0.0037219524384] [268.67619]
    FullTreeTraversal(from=20,to=200): [10        ] [0.0038553476334] [259.37998]

@coveralls
Copy link

Coverage Status

Coverage decreased (-14.43%) when pulling a0483a6 on dantleech:iterations_and_data_provider into 443f052 on polyfractal:master.

@staabm
Copy link
Contributor

staabm commented Oct 19, 2014

Like the idea.

How will the result look when the dataprovider provides more complex parameters (or a bigger number of parameters). I dont know how to do it "better" but It feels like as is it will only work with a small number of scalar args (the formatting)

@dantleech
Copy link
Author

Well, we could do a var_export($arg, true) to show arrays, but I think it would be better to just show the type of non-scalar values - or limit it to scalar values, in which case it would become more of a "parameter" provider.

@malkusch
Copy link

malkusch commented May 9, 2015

+1 for dataproviders. I was just looking for that feature in upstream's code.

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

Successfully merging this pull request may close these issues.

4 participants