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

Minor performance improvements #14

Merged
merged 6 commits into from
Apr 10, 2021
Merged

Minor performance improvements #14

merged 6 commits into from
Apr 10, 2021

Commits on Apr 9, 2021

  1. test: add simple benchmark

    This establishes baseline performance of the algorithm using some
    resonable default settings. On my local machine, this yeilds the
    following bechmark results:
    
    goos: linux
    goarch: amd64
    pkg: github.com/esimov/triangle
    cpu: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
    BenchmarkDraw-4               21        3074890062 ns/op
    PASS
    ok      github.com/esimov/triangle      67.892s
    
    Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
    whereswaldon committed Apr 9, 2021
    Configuration menu
    Copy the full SHA
    5b96d5e View commit details
    Browse the repository at this point in the history
  2. perf: avoid nested slice to reduce dynamic allocations

    Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
    whereswaldon committed Apr 9, 2021
    Configuration menu
    Copy the full SHA
    2c1311f View commit details
    Browse the repository at this point in the history
  3. perf: use smaller types to prepresent same data

    This commit switches several types from taking 4-bytes-per-pixel
    to a single byte per pixel. The behavior (so far as I can tell) is unchanged, but the speedup is noticable:
    
    goos: linux
    goarch: amd64
    pkg: github.com/esimov/triangle
    cpu: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
    BenchmarkDraw-4               25        2865398063 ns/op
    PASS
    ok      github.com/esimov/triangle      74.604s
    
    Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
    whereswaldon committed Apr 9, 2021
    Configuration menu
    Copy the full SHA
    b87e4d1 View commit details
    Browse the repository at this point in the history
  4. perf: avoid reallocating slices each iteration

    This brings another few percent of performance improvement:
    
    goos: linux
    goarch: amd64
    pkg: github.com/esimov/triangle
    cpu: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
    BenchmarkDraw-4               27        2498826294 ns/op
    PASS
    ok      github.com/esimov/triangle      70.112s
    
    Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
    whereswaldon committed Apr 9, 2021
    Configuration menu
    Copy the full SHA
    c50fc44 View commit details
    Browse the repository at this point in the history
  5. perf: remove a slice allocation

    This tweak appears to have a minor performance improvemnt
    associated, as no dynamic allocation has to occur for the slice embedded within the type.
    
    goos: linux
    goarch: amd64
    pkg: github.com/esimov/triangle
    cpu: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
    BenchmarkDraw-4               28        2474394774 ns/op
    PASS
    ok      github.com/esimov/triangle      71.881s
    
    Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
    whereswaldon committed Apr 9, 2021
    Configuration menu
    Copy the full SHA
    f24d402 View commit details
    Browse the repository at this point in the history
  6. fix: use backwards-compatible file read function

    This preserves support for older go versions.
    
    Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
    whereswaldon committed Apr 9, 2021
    Configuration menu
    Copy the full SHA
    83814fc View commit details
    Browse the repository at this point in the history