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

Optimization #166

Closed
simlu opened this issue Feb 26, 2019 · 6 comments
Closed

Optimization #166

simlu opened this issue Feb 26, 2019 · 6 comments

Comments

@simlu
Copy link
Collaborator

simlu commented Feb 26, 2019

Now that meta computation gotten more expensive it should only be computed once. However computation should still only happen on demand.

@simlu
Copy link
Collaborator Author

simlu commented Feb 26, 2019

Consider using Object.freeze?

@simlu simlu changed the title Cache meta computation Optimization Mar 1, 2019
@simlu
Copy link
Collaborator Author

simlu commented Mar 1, 2019

Also consider caching formatPath

@simlu
Copy link
Collaborator Author

simlu commented May 1, 2019

More things to consider:

  • the generification between isArray and the parseInt make this slow: consider separating this out into its own function and handle array and object cases separately again this is actually not true. Nodejs is very smart here somehow
  • Object.entries() on searches is redundant and should be pre-computed done
  • concat should be replaced by push and pop. Consider rewriting find as iterative function to make state handing more obvious done

@simlu
Copy link
Collaborator Author

simlu commented May 1, 2019

Performance test:

import fs from 'smart-fs';
import objectScan from './src/index.js';

const data = fs.smartRead('./test/integration/entities.json');

const scanner = objectScan(['**'], { joined: false });

const repeats = 1;
for (let i = 0; i < repeats; i += 1) {
  console.time('scan');
  const count = 1000;
  for (let idx = 0; idx < count; idx += 1) {
    scanner(data);
  }
  console.timeEnd('scan');
}

@simlu
Copy link
Collaborator Author

simlu commented May 4, 2019

Need to further investigate GC overhead as it seems excessive. Asked for further instructions here

@simlu
Copy link
Collaborator Author

simlu commented Jan 26, 2020

This library is highly optimized now. However meta computation can still be a significant overhead. Creating a separate ticket for that

@simlu simlu closed this as completed Jan 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant