package xproto import ( "bnema.dev/xturbo" "testing" ) func BenchmarkConfigureWindow(b *testing.B) { buf := xturbo.NewBuf(0) var v ConfigureWindowValues v.SetX(-1).SetY(-2).SetWidth(800).SetHeight(600).SetBorderWidth(1).SetSibling(2).SetStackMode(StackModeAbove) batch := 0 b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { if batch == 60000 { b.StopTimer() buf = xturbo.NewBuf(0) batch = 0 b.StartTimer() } buf.Reset() ConfigureWindow(buf, 1, &v) batch++ } if buf.Err() != nil { b.Fatal(buf.Err()) } } func BenchmarkMapWindow(b *testing.B) { buf := xturbo.NewBuf(0) batch := 0 b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { if batch == 60000 { b.StopTimer() buf = xturbo.NewBuf(0) batch = 0 b.StartTimer() } buf.Reset() MapWindow(buf, 1) batch++ } } func BenchmarkInternAtom(b *testing.B) { buf := xturbo.NewBuf(0) batch := 0 b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { if batch == 60000 { b.StopTimer() buf = xturbo.NewBuf(0) batch = 0 b.StartTimer() } buf.Reset() InternAtom(buf, false, "WM_CLASS") batch++ } } func BenchmarkChangeProperty4KiB(b *testing.B) { buf := xturbo.NewBuf(0) data := make([]byte, 4096) batch := 0 b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { if batch == 60000 { b.StopTimer() buf = xturbo.NewBuf(0) batch = 0 b.StartTimer() } buf.Reset() ChangeProperty(buf, 0, 1, 1, 1, 8, 4096, data) batch++ } }