[2.2] [WIP] [Finder] Adding native finders implementations
merged branch jfsimon/issue-4031 (PR #4061)

This PR was squashed before being merged into the master branch (closes #4061).

Commits
-------

32bb754 [2.2] [WIP] [Finder] Adding native finders implementations

Discussion
----------

[2.2] [WIP] [Finder] Adding native finders implementations

Work in progress...

Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #4031

This PR intends to add native finders implementation based on shell command execution.
Planned support concerns:
- GNU `find` command -> done
- MS `FINDSTR` command

---------------------------------------------------------------------------

by fabpot at 2012-05-15T06:19:50Z

@jfsimon What's the status of this PR?

---------------------------------------------------------------------------

by jfsimon at 2012-05-15T06:43:34Z

@fabpot 2 features missing for the GNU find adapter: sorting result with `sort` command and excluding directories; 1 bug (even if tests pass, which let me thing it needs more tests): regex matching is done on full path, not basename. Then I'll need to work on MS `FINDSTR` command adapter (I talked to Pierre Couzy, and he's OK to help when he will have time to). I'll try to push the sort and directory excluding features this week.

---------------------------------------------------------------------------

by jalliot at 2012-05-15T09:51:20Z

BTW @jfsimon, in the (quite specific) case where you don't precise filenames or other options but only `contains` or `notContains`, you could call `grep` directly without the `find`. That would speed things up a bit more :)

---------------------------------------------------------------------------

by fabpot at 2012-06-28T15:20:55Z

@jfsimon Would be nice to be able to include this PR before 2.1.0 beta2. Would you have time to finish the work soon?

---------------------------------------------------------------------------

by jfsimon at 2012-06-29T11:07:19Z

@fabpot I'd say next week for GNU part with some help from @smaftoul.

---------------------------------------------------------------------------

by jfsimon at 2012-07-10T08:20:44Z

It seems that I need to perform some benchmarks as find may not be so fast :/

---------------------------------------------------------------------------

by jfsimon at 2012-07-10T16:51:19Z

@fabpot @stof do you think I can add benchmark scripts inside the component, or should I create a new repository for that?

---------------------------------------------------------------------------

by fabpot at 2012-07-10T16:57:05Z

Then benchmark scripts won't be part of the repository in the end, so you should create a new repo for that.

---------------------------------------------------------------------------

by jfsimon at 2012-07-13T17:57:03Z

@fabpot @smaftoul Benchmark is ready (more cases to come): https://github.com/jfsimon/symfony-finder-benchmark
I'm glad to see that `gnu_find` adapter is really faster than the `php` one!

---------------------------------------------------------------------------

by stof at 2012-07-13T19:17:20Z

@jfsimon could you make a gist with the result of the benchmark ? I think many people will be lazy to run it themselves when looking at this ticket, and people using windows will probably be unable to run it at all :)

---------------------------------------------------------------------------

by jfsimon at 2012-07-13T21:37:50Z

First results: https://gist.github.com/3107676

---------------------------------------------------------------------------

by jfsimon at 2012-08-01T07:26:21Z

Sorry, I forgot `[Finder]` tag in 3 commits message... is it fixable?

---------------------------------------------------------------------------

by stof at 2012-08-01T08:58:28Z

@jfsimon you can edit the commit message whne doing an interactive rebase.

and btw, you will need to do a rebase anyway: the PR conflicts with master

---------------------------------------------------------------------------

by jfsimon at 2012-08-01T13:11:20Z

@stof Okay, I rebased origin/master. As you can see, above comments are now floating in the air :/

Strangely, rebase broke my tests... I need to fix them :(

---------------------------------------------------------------------------

by stof at 2012-08-01T13:14:11Z

Weird. github still tells me that the PR cannot be merged. Did you fetch the latest master before rebasing ?

---------------------------------------------------------------------------

by jfsimon at 2012-08-01T13:19:25Z

Weird, git fetch only fetched my own repository, I had to `git fetch origin`. I'm rebasing... again.

---------------------------------------------------------------------------

by jfsimon at 2012-08-01T14:50:02Z

@stof Rebase done, tests fixed :)

---------------------------------------------------------------------------

by stof at 2012-08-01T15:18:19Z

hmm, Travis does not seems to agree with the second statement :)

---------------------------------------------------------------------------

by jfsimon at 2012-08-01T17:33:55Z

Ouch, I'm really sorry, I was in the wrong tmux window when started tests :/
Good news, I have to fix my last problem (the regex tested against full path instead of basename) to fix the tests.
I'm on it.

---------------------------------------------------------------------------

by jfsimon at 2012-08-01T18:16:10Z

Grrr...  I didnt start full test suite, shame on me.

---------------------------------------------------------------------------

by jfsimon at 2012-08-01T19:10:02Z

Same bench than before, but with non empty files: https://gist.github.com/3229865

---------------------------------------------------------------------------

by jfsimon at 2012-08-01T19:23:32Z

It seems that searching files by their name with regex is really fatser than by glob with find: https://gist.github.com/3229911
@fabpot should I convert glob to regex when using `contains` and `notContains`?

---------------------------------------------------------------------------

by jfsimon at 2012-08-01T19:55:02Z

It seems that I'm an idiot, I used `contains` instead of `name`.
Real bench is here: https://gist.github.com/3230139
@fabpot sorry for the mess, I should go to bed :/
Results are still convincing!

---------------------------------------------------------------------------

by stof at 2012-08-01T20:04:42Z

They are, but the regex are not faster than glob anymore in these results

---------------------------------------------------------------------------

by jfsimon at 2012-08-01T21:17:25Z

@travisbot you failed, not me!

---------------------------------------------------------------------------

by jfsimon at 2012-08-01T21:18:28Z

Anyone to launch benchmark with php 5.4?
https://github.com/jfsimon/symfony-finder-benchmark

---------------------------------------------------------------------------

by lyrixx at 2012-08-01T22:25:08Z

Bench with php 5.4.5
https://gist.github.com/3231244
[Finder] tweaked previous merge