LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package big | 5 package big |
6 | 6 |
7 import "testing" | 7 import "testing" |
8 | 8 |
9 type cmpTest struct { | 9 type cmpTest struct { |
10 x, y nat | 10 x, y nat |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 mulArg = make(nat, n) | 154 mulArg = make(nat, n) |
155 for i := 0; i < n; i++ { | 155 for i := 0; i < n; i++ { |
156 mulArg[i] = _M | 156 mulArg[i] = _M |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 | 160 |
161 func BenchmarkMul(b *testing.B) { | 161 func BenchmarkMul(b *testing.B) { |
162 for i := 0; i < b.N; i++ { | 162 for i := 0; i < b.N; i++ { |
163 var t nat | 163 var t nat |
164 » » t.mul(mulArg, mulArg) | 164 » » for j := 1; j <= 10; j++ { |
| 165 » » » x := mulArg[0 : j*100] |
| 166 » » » t.mul(x, x) |
| 167 » » } |
165 } | 168 } |
166 } | 169 } |
167 | 170 |
168 | 171 |
169 type strN struct { | 172 type strN struct { |
170 x nat | 173 x nat |
171 b int | 174 b int |
172 s string | 175 s string |
173 } | 176 } |
174 | 177 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 if len(test.m) > 0 { | 359 if len(test.m) > 0 { |
357 m, _, _ = nat(nil).scan(test.m, 0) | 360 m, _, _ = nat(nil).scan(test.m, 0) |
358 } | 361 } |
359 | 362 |
360 z := nat(nil).expNN(x, y, m) | 363 z := nat(nil).expNN(x, y, m) |
361 if z.cmp(out) != 0 { | 364 if z.cmp(out) != 0 { |
362 t.Errorf("#%d got %v want %v", i, z, out) | 365 t.Errorf("#%d got %v want %v", i, z, out) |
363 } | 366 } |
364 } | 367 } |
365 } | 368 } |
LEFT | RIGHT |