2
0

Performance improvements.

BenchmarkResponseWriter     1239          1304          +5.25%
BenchmarkFullSSE            1469          915           -37.71%
BenchmarkNoRetrySSE         1187          785           -33.87%
BenchmarkSimpleSSE          961           687           -28.51%

benchmark                   old allocs     new allocs     delta
BenchmarkResponseWriter     9              9              +0.00%
BenchmarkFullSSE            12             3              -75.00%
BenchmarkNoRetrySSE         11             2              -81.82%
BenchmarkSimpleSSE          8              2              -75.00%

benchmark                   old bytes     new bytes     delta
BenchmarkResponseWriter     442           442           +0.00%
BenchmarkFullSSE            462           320           -30.74%
BenchmarkNoRetrySSE         473           337           -28.75%
BenchmarkSimpleSSE          426           314           -26.29%
This commit is contained in:
Manu Mtz-Almeida
2015-05-30 11:23:56 +02:00
parent 092a804d3e
commit 404710eaa4
2 changed files with 51 additions and 20 deletions
+24
View File
@@ -0,0 +1,24 @@
package sse
import "io"
type stringWriter interface {
io.Writer
WriteString(string) (int, error)
}
type stringWrapper struct {
io.Writer
}
func (w stringWrapper) WriteString(str string) (int, error) {
return w.Writer.Write([]byte(str))
}
func checkWriter(writer io.Writer) stringWriter {
if w, ok := writer.(stringWriter); ok {
return w
} else {
return stringWrapper{writer}
}
}