go-openapi / spec

openapi specification object model
Apache License 2.0
394 stars 100 forks source link

improve performance of schema deserialize #61

Closed mikedanese closed 6 years ago

mikedanese commented 6 years ago

and add some benchmarks. This is a bottleneck for the kubernetes unit tests. The fix works by caching the deserialization of the full schema into a map. We were doing this three times. Now we only do it once.

Before:

    BenchmarkSchemaUnmarshal-12
            50000            321498 ns/op           86325 B/op       1400 allocs/op

After:

    BenchmarkSchemaUnmarshal-12
           100000            131877 ns/op           46183 B/op        535 allocs/op

@mbohlool

codecov[bot] commented 6 years ago

Codecov Report

Merging #61 into master will increase coverage by 0.35%. The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #61      +/-   ##
==========================================
+ Coverage   36.97%   37.32%   +0.35%     
==========================================
  Files          18       18              
  Lines        1888     1894       +6     
==========================================
+ Hits          698      707       +9     
- Misses       1027     1028       +1     
+ Partials      163      159       -4
Impacted Files Coverage Δ
ref.go 42.25% <100%> (+1.67%) :arrow_up:
schema.go 26.03% <83.33%> (+2.28%) :arrow_up:

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 a7c6967...bc104a1. Read the comment docs.