MCPcopy
hub / github.com/signintech/gopdf / BenchmarkAddTTFFontData

Function BenchmarkAddTTFFontData

gopdf_test.go:288–309  ·  view source on GitHub ↗

* func TestBuffer(t *testing.T) { b := bytes.NewReader([]byte("ssssssss")) b1, err := ioutil.ReadAll(b) if err != nil { t.Error(err) return } fmt.Printf("->%s\n", string(b1)) b.Seek(0, 0) b2, err := ioutil.ReadAll(b) if err != nil { t.Error(err) return } fmt.Printf("+>%s\n", stri

(b *testing.B)

Source from the content-addressed store, hash-verified

286}*/
287
288func BenchmarkAddTTFFontData(b *testing.B) {
289 ttf, err := os.Open("test/res/LiberationSerif-Regular.ttf")
290 if err != nil {
291 b.Error(err)
292 return
293 }
294 defer ttf.Close()
295
296 fontData, err := io.ReadAll(ttf)
297 if err != nil {
298 b.Error(err)
299 return
300 }
301
302 for n := 0; n < b.N; n++ {
303 pdf := &GoPdf{}
304 pdf.Start(Config{PageSize: *PageSizeA4})
305 if err := pdf.AddTTFFontData("LiberationSerif-Regular", fontData); err != nil {
306 return
307 }
308 }
309}
310
311func TestReuseFontData(t *testing.T) {
312 ttf, err := os.Open("test/res/LiberationSerif-Regular.ttf")

Callers

nothing calls this directly

Calls 3

StartMethod · 0.95
AddTTFFontDataMethod · 0.95
CloseMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…