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

Method Update

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

Source from the content-addressed store, hash-verified

98}
99
100func (ent *Ent) Update(b *testing.B) {
101 m := NewModelAlt()
102
103 created, err := ent.conn.Model.Create().
104 SetName(m.Name).
105 SetTitle(m.Title).
106 SetFax(m.Fax).
107 SetWeb(m.Web).
108 SetAge(m.Age).
109 SetRight(m.Right).
110 SetCounter(m.Counter).
111 Save(ctx)
112 if err != nil {
113 helper.SetError(b, ent.Name(), "Update", err.Error())
114 }
115 m.Id = created.ID
116
117 b.ReportAllocs()
118 b.ResetTimer()
119
120 for i := 0; i < b.N; i++ {
121 _, err := ent.conn.Model.Update().
122 Where(model.IDEQ(m.Id)).
123 SetName(m.Name).
124 SetTitle(m.Title).
125 SetFax(m.Fax).
126 SetWeb(m.Web).
127 SetAge(m.Age).
128 SetRight(m.Right).
129 SetCounter(m.Counter).
130 Save(ctx)
131 if err != nil {
132 helper.SetError(b, ent.Name(), "Update", err.Error())
133 }
134 }
135}
136
137func (ent *Ent) Read(b *testing.B) {
138 m := NewModelAlt()

Callers

nothing calls this directly

Calls 15

NameMethod · 0.95
SetErrorFunction · 0.92
IDEQFunction · 0.92
NewModelAltFunction · 0.85
ErrorMethod · 0.65
UpdateMethod · 0.65
SaveMethod · 0.45
SetCounterMethod · 0.45
SetRightMethod · 0.45
SetAgeMethod · 0.45
SetWebMethod · 0.45
SetFaxMethod · 0.45

Tested by

no test coverage detected