Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: docker/go-units
base: v0.4.0
Choose a base ref
...
head repository: docker/go-units
compare: v0.5.0
Choose a head ref
  • 6 commits
  • 2 files changed
  • 3 contributors

Commits on May 16, 2022

  1. size_test: add tests for 0.3 + suffix

    Such sizes are quite valid but were never tested.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed May 16, 2022
    Copy the full SHA
    af07f36 View commit details
    Browse the repository at this point in the history
  2. size_test: add parseSize benchmark

    Shows on my laptop (6 iterations processed by benchstat):
    
    name         time/op
    ParseSize-4  10.6µs ± 3%
    
    name         alloc/op
    ParseSize-4  3.26kB ± 0%
    
    name         allocs/op
    ParseSize-4    72.0 ± 0%
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed May 16, 2022
    Copy the full SHA
    1d23ffa View commit details
    Browse the repository at this point in the history
  3. size_test: add t.Helper annotations

    This way, error messages will show correct line information.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed May 16, 2022
    Copy the full SHA
    54c3e55 View commit details
    Browse the repository at this point in the history
  4. size_test: add more tests

    Co-authored-by: Kir Kolyshkin <kolyshkin@gmail.com>
    thaJeztah and kolyshkin committed May 16, 2022
    Copy the full SHA
    cec4960 View commit details
    Browse the repository at this point in the history
  5. size: stop using regexp

    Using a regular expression brings in the whole regexp and regexp/syntax
    packages, which increase the resulting binary size by about 130K
    (Go 1.18.1, Linux/amd64).
    
    Besides, regular expressions are generally slow and incur some
    initialization overhead (to compile all global regexp.MustComplile
    variables). This, unlike the size difference, is not the main motivation
    for this commit, but it feels like it should have also been mentioned.
    
    A quick benchmark comparison shows a huge improvement (again, this is
    not why this is done, nevertheless it pleases the eye):
    
    name         old time/op    new time/op    delta
    ParseSize-4    10.6µs ± 3%     2.6µs ±29%  -75.10%  (p=0.002 n=6+6)
    
    name         old alloc/op   new alloc/op   delta
    ParseSize-4    3.26kB ± 0%    0.20kB ± 0%  -93.75%  (p=0.000 n=7+6)
    
    name         old allocs/op  new allocs/op  delta
    ParseSize-4      72.0 ± 0%      26.0 ± 0%  -63.89%  (p=0.000 n=7+6)
    
    Compatibility note: As a result, we are now a but more relaxed to the
    input, allowing e.g. ".4 Gb", or "-0", or "234. B", following the rules
    of strconv.ParseFloat. It seems that those were previously rejected as
    a result of a regex being used, not deliberately.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed May 16, 2022
    Copy the full SHA
    7375726 View commit details
    Browse the repository at this point in the history

Commits on May 17, 2022

  1. Merge pull request #40 from kolyshkin/no-regex

    Remove regexp use
    thaJeztah committed May 17, 2022
    Copy the full SHA
    e682442 View commit details
    Browse the repository at this point in the history