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

Performance improvement 12: Optimize NocaseDict._real_key() #1673

Merged
merged 3 commits into from
Mar 4, 2019

Conversation

andy-maier
Copy link
Contributor

see last commit

Details:

- The initialization of CIMProperty and CIMParameter always performs
  a check on the array-related parameters via _check_array_parms().
  However, in case is_array was inferred, it is set consistently
  by _infer_is_array() and there is no point in checking it again.

  This change performs the _check_array_parms() only if is_array
  was not inferred.

  This change leaves the following combination of incorrect input
  parameter undetected: is-array=False and array_size=5. Because
  array_size is ignored and has no meaning when is_array=False,
  not detecting this check seems acceptable.

  The improvement is to avoid the call to _check_array_parms()
  when is_array is inferred.

- An additional improvement was possible due to the first
  change, namely to not perform the check for is-array=False and
  array_size=5 at all, and to eliminate an assertion because
  the way the check function is called already ensures that.

Improvement:

  Output files before: perf/tupleparse/perf_9-infer_*
  Output files after:  perf/tupleparse/perf_10-checkarray_*

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
Details:

- This change optimizes the NocaseDict.__init__() method for the case
  that is by far the most common: No arguments.

  For that case, it reduces the number of if's from 3 if's each with
  len(), to 2 if's for non-emptiness, plus it eliminates a dict update()
  with empty input.

- This change also improves some comments in NocaseDict.__init__().

Improvement:

  Output files before: perf/tupleparse/perf_10-checkarray_*
  Output files after:  perf/tupleparse/perf_11-nocasedict_*

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
@andy-maier andy-maier self-assigned this Mar 2, 2019
@andy-maier andy-maier added this to the 0.14.0 milestone Mar 2, 2019
Details:

- This change optimizes the implementaiton of NocaseDict._real_key()
  by replacing a check using isinstance() with a check for None,
  turning around the order of checks. Also, replaced if/elif/else
  with a sequence of if's.

  This eliminates a call to isinstance().

Improvement:

  Output files before: perf/tupleparse/perf_11-nocasedict_*
  Output files after:  perf/tupleparse/perf_12-nocasedict_*

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.005%) to 84.188% when pulling f7024d5 on andy/perf-12-nocasedict into 1fa4b4e on master.

@andy-maier andy-maier merged commit 066c5fd into master Mar 4, 2019
@andy-maier andy-maier deleted the andy/perf-12-nocasedict branch March 4, 2019 13:44
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