@@ -54,6 +54,20 @@ func StdIntSet(b *testing.B) {
5454 }
5555}
5656
57+ func StdIntPre (b * testing.B ) {
58+ a := b .Allocator ()
59+ for b .Loop () {
60+ m := maps .New [int , int ](a , nKeys )
61+ for i := range nKeys {
62+ m .Set (i , i )
63+ }
64+ m .Free ()
65+ if arena != nil {
66+ arena .Reset ()
67+ }
68+ }
69+ }
70+
5771func StdIntGet (b * testing.B ) {
5872 m := maps .New [int , int ](nil , nKeys )
5973 for i := range nKeys {
@@ -98,6 +112,20 @@ func StdStrSet(b *testing.B) {
98112 }
99113}
100114
115+ func StdStrPre (b * testing.B ) {
116+ a := b .Allocator ()
117+ for b .Loop () {
118+ m := maps .New [string , int ](a , nKeys )
119+ for i := range nKeys {
120+ m .Set (strKeys [i ], i )
121+ }
122+ m .Free ()
123+ if arena != nil {
124+ arena .Reset ()
125+ }
126+ }
127+ }
128+
101129func StdStrGet (b * testing.B ) {
102130 m := maps .New [string , int ](nil , nKeys )
103131 for i := range nKeys {
@@ -186,9 +214,11 @@ func main() {
186214
187215 benchs := []testing.Benchmark {
188216 {Name : "IntSet" , F : StdIntSet },
217+ {Name : "IntPre" , F : StdIntPre },
189218 {Name : "IntGet" , F : StdIntGet },
190219 {Name : "IntDel" , F : StdIntDel },
191220 {Name : "StrSet" , F : StdStrSet },
221+ {Name : "StrPre" , F : StdStrPre },
192222 {Name : "StrGet" , F : StdStrGet },
193223 {Name : "StrDel" , F : StdStrDel },
194224 }
0 commit comments