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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use template strings, unify testing, remove dottie #10055

Merged
merged 5 commits into from Oct 21, 2018

Conversation

@SimonSchick
Copy link
Member

@SimonSchick SimonSchick commented Oct 21, 2018

Pull Request check-list

Please make sure to review and check all of these items:

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

Last big PR for a while.

  1. Used eslint to convert all string concat to template strings, see https://stackoverflow.com/questions/29055518/are-es6-template-literals-faster-than-string-concatenation
  2. Moved all usage of suite and test within tests to use the describe and it functions.
  3. Replaced dottie with _.set/get (one less dependency 馃帀)
Copy link
Contributor

@sushantdhiman sushantdhiman left a comment

Please keep dottie dependency for now or atleast we will remove that in different PR. Dottie is used in some performance sensitive codebase. I want to measure the impace before we replace it with lodash get/set

@sushantdhiman
Copy link
Contributor

@sushantdhiman sushantdhiman commented Oct 21, 2018

Some tests for Postgres are failing

@codecov
Copy link

@codecov codecov bot commented Oct 21, 2018

Codecov Report

Merging #10055 into master will decrease coverage by <.01%.
The diff coverage is 89.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10055      +/-   ##
==========================================
- Coverage    96.3%    96.3%   -0.01%     
==========================================
  Files          63       63              
  Lines        9412     9410       -2     
==========================================
- Hits         9064     9062       -2     
  Misses        348      348
Impacted Files Coverage 螖
lib/associations/belongs-to-many.js 97.03% <酶> (酶) 猬嗭笍
lib/associations/belongs-to.js 100% <酶> (酶) 猬嗭笍
lib/associations/has-one.js 97.11% <酶> (酶) 猬嗭笍
lib/associations/has-many.js 97.67% <酶> (酶) 猬嗭笍
lib/dialects/abstract/connection-manager.js 87.6% <100%> (酶) 猬嗭笍
lib/dialects/sqlite/query-interface.js 100% <100%> (酶) 猬嗭笍
lib/dialects/mssql/data-types.js 98.13% <100%> (酶) 猬嗭笍
lib/dialects/sqlite/data-types.js 97.15% <100%> (酶) 猬嗭笍
lib/dialects/mssql/query.js 94.87% <100%> (酶) 猬嗭笍
lib/dialects/sqlite/connection-manager.js 97.77% <100%> (酶) 猬嗭笍
... and 24 more

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update be958ac...b17941c. Read the comment docs.

@SimonSchick
Copy link
Member Author

@SimonSchick SimonSchick commented Oct 21, 2018

Re dottie, I did a rudimentary benchmark with 10mil iterations.

get
lodash: 2487.456ms
dottie: 1422.263ms
set
lodash: 2952.551ms
dottie: 2644.326ms

Reason I removed it is that you use _.get _.set everywhere else, not sure if the performance impact is relevant at all.

@sushantdhiman
Copy link
Contributor

@sushantdhiman sushantdhiman commented Oct 21, 2018

We use lodash.get to merely get some deep config path, messages etc stuff, nothing critical. lodash.set is not used anywhere.

Dottie still got upper hand (as per your benchmark), I would like to measure impact at-least independently before deciding to remove it

@SimonSchick
Copy link
Member Author

@SimonSchick SimonSchick commented Oct 21, 2018

I don't think it will have any measureable impact in actual consumer use but I will revert the specific changes.

Here is my benchmark:

'use strict';

const { get: lget, set: lset } = require('lodash');
const { get: dget, set: dset } = require('dottie');

console.log('get');
{
  const lookup = 'a.b.c.d.e.f.g';
  const obj = {
    a: {
      b: {
        d: {
          e: {
            f: {
              g: 123,
            },
          },
        },
      },
    },
  };
  console.time('lodash');
  for (let i = 0;i<10000000;++i) {
    lget(obj, lookup);
  }
  console.timeEnd('lodash');
}

{
  const lookup = 'a.b.c.d.e.f.g';
  const obj = {
    a: {
      b: {
        d: {
          e: {
            f: {
              g: 123,
            },
          },
        },
      },
    },
  };
  console.time('dottie');
  for (let i = 0;i<10000000;++i) {
    dget(obj, lookup);
  }
  console.timeEnd('dottie');
}

console.log('set');
{
  const lookup = 'a.b.c.d.e.f.g';
  const obj = {};
  console.time('lodash');
  for (let i = 0;i<10000000;++i) {
    lset(obj, lookup, 123);
  }
  console.timeEnd('lodash');
}

{
  const lookup = 'a.b.c.d.e.f.g';
  const obj = {};
  console.time('dottie');
  for (let i = 0;i<10000000;++i) {
    dset(obj, lookup);
  }
  console.timeEnd('dottie');
}
@sushantdhiman sushantdhiman merged commit a0545bf into sequelize:master Oct 21, 2018
2 of 4 checks passed
2 of 4 checks passed
@codecov
codecov/patch 89.91% of diff hit (target 96.3%)
Details
@codecov
codecov/project 96.3% (-0.01%) compared to be958ac
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@sushantdhiman
Copy link
Contributor

@sushantdhiman sushantdhiman commented Oct 21, 2018

Thanks @SimonSchick

@SimonSchick SimonSchick deleted the SimonSchick:refactor/more-cleanup branch Oct 21, 2018
owenkim added a commit to convoyinc/sequelize that referenced this pull request Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants