Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1279)

Delta Between Two Patch Sets: src/pkg/big/nat_test.go

Issue 1004042: code review 1004042: big: implemented Karatsuba multiplication (Closed)
Left Patch Set: code review 1004042: big: implemented Karatsuba multiplication Created 13 years, 11 months ago
Right Patch Set: code review 1004042: big: implemented Karatsuba multiplication Created 13 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« src/pkg/big/nat.go ('K') | « src/pkg/big/nat.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 func TestMulRange(t *testing.T) { 140 func TestMulRange(t *testing.T) {
141 for i, r := range mulRanges { 141 for i, r := range mulRanges {
142 prod := nat(nil).mulRange(r.a, r.b).string(10) 142 prod := nat(nil).mulRange(r.a, r.b).string(10)
143 if prod != r.prod { 143 if prod != r.prod {
144 t.Errorf("%d: got %s; want %s", i, prod, r.prod) 144 t.Errorf("%d: got %s; want %s", i, prod, r.prod)
145 } 145 }
146 } 146 }
147 } 147 }
148 148
149 149
150 func BenchmarkFact(b *testing.B) { 150 var mulArg nat
151 » var t nat 151
152 func init() {
153 » const n = 1000
154 » mulArg = make(nat, n)
155 » for i := 0; i < n; i++ {
156 » » mulArg[i] = _M
157 » }
158 }
159
160
161 func BenchmarkMul(b *testing.B) {
152 for i := 0; i < b.N; i++ { 162 for i := 0; i < b.N; i++ {
153 » » t.mulRange(1, 1e5) 163 » » var t nat
164 » » for j := 1; j <= 10; j++ {
165 » » » x := mulArg[0 : j*100]
166 » » » t.mul(x, x)
167 » » }
154 } 168 }
155 } 169 }
156 170
157 171
158 type strN struct { 172 type strN struct {
159 x nat 173 x nat
160 b int 174 b int
161 s string 175 s string
162 } 176 }
163 177
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 if len(test.m) > 0 { 359 if len(test.m) > 0 {
346 m, _, _ = nat(nil).scan(test.m, 0) 360 m, _, _ = nat(nil).scan(test.m, 0)
347 } 361 }
348 362
349 z := nat(nil).expNN(x, y, m) 363 z := nat(nil).expNN(x, y, m)
350 if z.cmp(out) != 0 { 364 if z.cmp(out) != 0 {
351 t.Errorf("#%d got %v want %v", i, z, out) 365 t.Errorf("#%d got %v want %v", i, z, out)
352 } 366 }
353 } 367 }
354 } 368 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b