59 lines
1.1 KiB
Go
Raw Normal View History

2016-10-23 04:15:47 +00:00
package main
import (
2016-10-28 16:11:25 +00:00
"bytes"
"fmt"
"strings"
2016-10-23 04:15:47 +00:00
"testing"
)
2016-10-28 16:11:25 +00:00
// func BenchmarkRender(b *testing.B) {
// b.ReportAllocs()
// layout := aero.NewTemplate("layout/layout.pug")
// template := aero.NewTemplate("pages/anime/anime.pug")
// cssBytes, _ := ioutil.ReadFile("layout.css")
// css := string(cssBytes)
// cssSearch := "</head><body"
// cssReplace := "<style>" + css + "</style></head><body"
2016-10-23 04:15:47 +00:00
2016-10-28 16:11:25 +00:00
// for i := 0; i < b.N; i++ {
// anime, _ := arn.GetAnime(1000001)
2016-10-23 04:15:47 +00:00
2016-10-28 16:11:25 +00:00
// content := template.Render(map[string]interface{}{
// "anime": anime,
// })
// final := layout.Render(map[string]interface{}{
// "content": content,
// })
// final = strings.Replace(final, cssSearch, cssReplace, 1)
// }
// }
2016-10-23 04:15:47 +00:00
2016-10-28 16:11:25 +00:00
func Benchmark1(b *testing.B) {
code := []byte(strings.Repeat("a", 10000))
b.ReportAllocs()
2016-10-23 04:15:47 +00:00
for i := 0; i < b.N; i++ {
2016-10-28 16:11:25 +00:00
var buf bytes.Buffer
buf.Write(code)
buf.Write(code)
buf.Write(code)
c := buf.String()
fmt.Println(len(c))
2016-10-23 04:15:47 +00:00
}
}
2016-10-28 16:11:25 +00:00
func Benchmark2(b *testing.B) {
code := strings.Repeat("a", 10000)
b.ReportAllocs()
2016-10-23 04:15:47 +00:00
for i := 0; i < b.N; i++ {
2016-10-28 16:11:25 +00:00
c := code
c += code
c += code
fmt.Println(len(c))
2016-10-23 04:15:47 +00:00
}
}