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

Improved performance of scan level #221

Closed
wants to merge 35 commits into from
Closed

Improved performance of scan level #221

wants to merge 35 commits into from

Conversation

blond
Copy link
Member

@blond blond commented May 15, 2016

After this change the scan time was the same as before #217.

Example with project-stub:

version time
v2.2.1 51ms
#master 63ms
#perf/levels 54ms

blond and others added 30 commits March 30, 2016 11:21
The `node.getLevelNamingScheme` and the `node.setLevelNamingScheme`
methods will be removed in `enb@2.0.0`.
Got rid of scheme builders
Remove deprecated techs
Remove deprecated options
The `mock-fs` does not support `require` for Node.js 4.

Because of this test failed with error:

```
Cannot find module 'path/to/file.js
```
**Example of new format:**

```
{
    button__text: [
        {
            entity: { block: ‘button’, elem: ‘text’ },
            tech: ‘css’,
            path: ‘path/to/file.ext’,
            level: ‘path/to/level’
        },
        /* ... */
    ],
    /* ... */
}
```

With this introspection format to easily get a list of files named
entity.

**What has been done?**

* Use `bem-walk` to scan levels.
* Use `bem-naming` to get id of BEM entity.
* Add `BundleIntrospection` class to work with introspection of levels
for one bundle.
* Rewrite `levels` tech with `build-flow`.
* Use promises with `node.buildState` to avoid scanning the same levels
multiple times.
* Don't read files for directories (example i18n), it should do `files` tech.
Now the `bem-walk` is used to scan.
Exactly the same benchmarks in `bem-walk` repository
blond and others added 5 commits May 7, 2016 16:15
API moved to bottom of list
Used writable stream instead of promises.
Used `fs.statSync` instead of `fs.stat`.
.pipe(new stream.Writable({
objectMode: true,
write: function (file, encoding, callback) {
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try catch не оптимизируется же, или врут?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Как иначе обработать fs.statSync?

Например, когда файл был удалён?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не, я ж не против, но сделай хелпер:

function tryCatch(tryFn, catchFn) { try { return tryFn(); } catch(e) { catchFn(e); } }

@blond
Copy link
Member Author

blond commented Dec 3, 2016

Closed in favor of #253

@blond blond closed this Dec 3, 2016
@blond blond removed the in progress label Dec 3, 2016
@blond blond deleted the perf/levels branch December 3, 2016 10:51
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.

None yet

3 participants