Files
goquery/bench_property_test.go
2012-09-11 21:05:03 -04:00

48 lines
707 B
Go

package goquery
import (
"testing"
)
func BenchmarkAttr(b *testing.B) {
var s string
b.StopTimer()
sel := DocW().Root.Find("h1")
b.StartTimer()
for i := 0; i < b.N; i++ {
s, _ = sel.Attr("id")
}
b.Logf("Attr=%s", s)
}
func BenchmarkText(b *testing.B) {
b.StopTimer()
sel := DocW().Root.Find("h2")
b.StartTimer()
for i := 0; i < b.N; i++ {
sel.Text()
}
}
func BenchmarkLength(b *testing.B) {
var n int
b.StopTimer()
sel := DocW().Root.Find("h2")
b.StartTimer()
for i := 0; i < b.N; i++ {
n = sel.Length()
}
b.Logf("Length=%d", n)
}
func BenchmarkHtml(b *testing.B) {
b.StopTimer()
sel := DocW().Root.Find("h2")
b.StartTimer()
for i := 0; i < b.N; i++ {
sel.Html()
}
}