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

Commits on Mar 2, 2019

  1. Performance improvement 10: Avoid and simplify _check_array_parms()

    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>
    andy-maier committed Mar 2, 2019
    Configuration menu
    Copy the full SHA
    90df133 View commit details
    Browse the repository at this point in the history
  2. Performance improvement 11: Optimize NocaseDict.__init__()

    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 committed Mar 2, 2019
    Configuration menu
    Copy the full SHA
    80c816d View commit details
    Browse the repository at this point in the history

Commits on Mar 3, 2019

  1. Performance improvement 12: Optimize NocaseDict._real_key()

    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>
    andy-maier committed Mar 3, 2019
    Configuration menu
    Copy the full SHA
    f7024d5 View commit details
    Browse the repository at this point in the history