• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ezgliding / goigc / 84 / 1
86%
master: 68%

Build:
Build:
LAST BUILD BRANCH: binder
DEFAULT BRANCH: master
Ran 06 Dec 2019 02:18AM UTC
Files 587
Run time 41s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

12 Aug 2017 12:26AM UTC coverage: 68.927% (-17.1%) from 86.031%
BUILDFLAVOR=goveralls

Pull #2186

travis-ci

rochaporto
Add caching of distance values in brute force

Add a cache for point to point distances in brute force Optimize(). This
is the result of a previous pprof analysis where it is clear most of the
time is spent calculating distance (and cos, sin, atan):
go tool pprof -top -cum cpu.pprof
15.62s of 16.70s total (93.53%)
Dropped 140 nodes (cum <= 0.08s)
      flat  flat%   sum%        cum   cum%
         0     0%     0%     16.42s 98.32%  runtime.goexit
         0     0%     0%     15.16s 90.78%  testing.tRunner
         0     0%     0%     14.60s 87.43%
github.com/ezgliding/goigc.(*bruteForceOptimizer).Optimize
     0.42s  2.51%  2.51%     14.60s 87.43%
github.com/ezgliding/goigc.(*bruteForceOptimizer).optimize1
         0     0%  2.51%     14.60s 87.43%
github.com/ezgliding/goigc.TestBruteForceOptimize.func1
     0.53s  3.17%  5.69%     11.10s 66.47%
github.com/ezgliding/goigc.(*Task).Distance
     0.40s  2.40%  8.08%     10.33s 61.86%
github.com/ezgliding/goigc.(*Point).Distance
     1.98s 11.86% 19.94%      9.93s 59.46%
github.com/ezgliding/goigc/vendor/github.com/golang/geo/s2.LatLng.Distance
     0.70s  4.19% 24.13%      3.10s 18.56%  math.atan2
     0.23s  1.38% 25.51%      2.65s 15.87%  runtime.newobject
     2.48s 14.85% 40.36%      2.48s 14.85%  math.sin
     0.93s  5.57% 45.93%      2.43s 14.55%  runtime.mallocgc
     0.41s  2.46% 48.38%      2.40s 14.37%  math.atan
     1.99s 11.92% 60.30%      1.99s 11.92%  math.satan
     1.94s 11.62% 71.92%      1.94s 11.62%  math.cos

Compute the distances inside the loop so we can reuse the values in the
cache, instead of using a Task struct.

Results show a significant improvement (was ~15s):
go test -bench=BenchmarkBruteForceOptimize -run=x -cpuprofile=cpu.pprof
BenchmarkBruteForceOptimize/optimize-short-flight-1/1-4         	       1	5175162399 ns/op
PASS
ok  	github.com/ezgliding/goigc	5.181s
Pull Request #2186:

3371 of 5511 branches covered (61.17%)

Branch coverage included in aggregate %.

8377 of 11533 relevant lines covered (72.64%)

34.6 hits per line

Source Files on job 84.1 (BUILDFLAVOR=goveralls)
  • Tree
  • List 0
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 84
  • Travis Job 84.1
  • b9dcbb52 on github
  • Prev Job for BUILDFLAVOR=goveralls on pprofdist (#83.1)
  • Next Job for BUILDFLAVOR=goveralls on pprofdist (#86.1)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc