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

TykTechnologies / tyk / 3187 / 2

Build:
DEFAULT BRANCH: master
Ran 06 Oct 2017 02:20PM UTC
Files 84
Run time 4s
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

06 Oct 2017 02:17PM UTC coverage: 46.157% (+0.006%) from 46.151%
LATEST_GO=true

push

travis-ci

buger
proxy: avoid copying bodies multiple times

When we copy a request or response's body, we replace both results'
bodies with a NopCloser around a bytes.Buffer. We do this to be able to
read it multiple times from different places at different times.
However, once we put it in a bytes.Buffer once, it's already in memory
and doing the same again is useless.

Instead, buffer only once, and simply re-use a shallow copy of
bytes.Buffer from there on. This is enough, since it will make a copy of
the read offset yet share the same underlying buffer.

There is no indication that this is a bottleneck, but it's an easy win
and we do call copyRequest and copyResponse multiple times in the
codebase.

Benchmark of copying a request and response 10 times each, before and
after:

name                   old time/op    new time/op    delta
CopyRequestResponse-4     168µs ± 0%      26µs ± 1%  -84.39%  (p=0.004 n=5+6)

name                   old alloc/op   new alloc/op   delta
CopyRequestResponse-4     296kB ± 0%      36kB ± 0%  -87.98%  (p=0.000 n=5+6)

name                   old allocs/op  new allocs/op  delta
CopyRequestResponse-4       184 ± 0%        76 ± 0%  -58.70%  (p=0.002 n=6+6)

6144 of 13311 relevant lines covered (46.16%)

0.5 hits per line

Source Files on job 3187.2 (LATEST_GO=true)
  • Tree
  • List 0
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 3187
  • Travis Job 3187.2
  • 51b05b9d on github
  • Prev Job for LATEST_GO=true on master (#3186.2)
  • Next Job for LATEST_GO=true on master (#3188.2)
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