MCPcopy Create free account
hub / github.com/efectn/go-orm-benchmarks / InsertMulti

Method InsertMulti

bench/ent.go:71–98  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

69}
70
71func (ent *Ent) InsertMulti(b *testing.B) {
72 ms := make([]Model, 0, 100)
73 for i := 0; i < 100; i++ {
74 ms = append(ms, NewModelAlt())
75 }
76
77 b.ReportAllocs()
78 b.ResetTimer()
79
80 bulk := make([]*entdb.ModelCreate, len(ms))
81 for i, m := range ms {
82 bulk[i] = ent.conn.Model.Create().
83 SetName(m.Name).
84 SetTitle(m.Title).
85 SetFax(m.Fax).
86 SetWeb(m.Web).
87 SetAge(m.Age).
88 SetRight(m.Right).
89 SetCounter(m.Counter)
90 }
91
92 for i := 0; i < b.N; i++ {
93 _, err := ent.conn.Model.CreateBulk(bulk...).Save(ctx)
94 if err != nil {
95 helper.SetError(b, ent.Name(), "InsertMulti", err.Error())
96 }
97 }
98}
99
100func (ent *Ent) Update(b *testing.B) {
101 m := NewModelAlt()

Callers

nothing calls this directly

Calls 14

NameMethod · 0.95
SetErrorFunction · 0.92
NewModelAltFunction · 0.85
CreateBulkMethod · 0.80
ErrorMethod · 0.65
SetCounterMethod · 0.45
SetRightMethod · 0.45
SetAgeMethod · 0.45
SetWebMethod · 0.45
SetFaxMethod · 0.45
SetTitleMethod · 0.45
SetNameMethod · 0.45

Tested by

no test coverage detected