@@ -361,12 +361,12 @@ func testFileWindow(i, window int, t *testing.T) {
361361}
362362
363363func testBigGzip (i int , t * testing.T ) {
364+ rng := rand .New (rand .NewSource (1337 ))
364365 if len (testbuf ) != i {
365366 // Make results predictable
366- rand .Seed (1337 )
367367 testbuf = make ([]byte , i )
368368 for idx := range testbuf {
369- testbuf [idx ] = byte (65 + rand .Intn (20 ))
369+ testbuf [idx ] = byte (65 + rng .Intn (20 ))
370370 }
371371 }
372372 c := BestCompression
@@ -441,10 +441,10 @@ func testDeterm(level int, t *testing.T) {
441441 if testing .Short () {
442442 length = 100000
443443 }
444- rand .Seed ( 1337 )
444+ rng := rand .New ( rand . NewSource ( 1337 ) )
445445 t1 := make ([]byte , length )
446446 for idx := range t1 {
447- t1 [idx ] = byte (65 + rand .Intn (8 ))
447+ t1 [idx ] = byte (65 + rng .Intn (8 ))
448448 }
449449
450450 br := bytes .NewBuffer (t1 )
@@ -462,10 +462,10 @@ func testDeterm(level int, t *testing.T) {
462462
463463 // We recreate the buffer, so we have a goos chance of getting a
464464 // different memory address.
465- rand .Seed ( 1337 )
465+ rng = rand .New ( rand . NewSource ( 1337 ) )
466466 t2 := make ([]byte , length )
467467 for idx := range t2 {
468- t2 [idx ] = byte (65 + rand .Intn (8 ))
468+ t2 [idx ] = byte (65 + rng .Intn (8 ))
469469 }
470470
471471 br2 := bytes .NewBuffer (t2 )
@@ -538,46 +538,6 @@ func benchmarkGzipN(b *testing.B, level int) {
538538 }
539539}
540540
541- /*
542- func BenchmarkOldGzipL1(b *testing.B) { benchmarkOldGzipN(b, 1) }
543- func BenchmarkOldGzipL2(b *testing.B) { benchmarkOldGzipN(b, 2) }
544- func BenchmarkOldGzipL3(b *testing.B) { benchmarkOldGzipN(b, 3) }
545- func BenchmarkOldGzipL4(b *testing.B) { benchmarkOldGzipN(b, 4) }
546- func BenchmarkOldGzipL5(b *testing.B) { benchmarkOldGzipN(b, 5) }
547- func BenchmarkOldGzipL6(b *testing.B) { benchmarkOldGzipN(b, 6) }
548- func BenchmarkOldGzipL7(b *testing.B) { benchmarkOldGzipN(b, 7) }
549- func BenchmarkOldGzipL8(b *testing.B) { benchmarkOldGzipN(b, 8) }
550- func BenchmarkOldGzipL9(b *testing.B) { benchmarkOldGzipN(b, 9) }
551-
552- func benchmarkOldGzipN(b *testing.B, level int) {
553- dat, _ := os.ReadFile("testdata/test.json")
554- dat = append(dat, dat...)
555- dat = append(dat, dat...)
556- dat = append(dat, dat...)
557- dat = append(dat, dat...)
558- dat = append(dat, dat...)
559-
560- b.SetBytes(int64(len(dat)))
561- w, _ := oldgz.NewWriterLevel(io.Discard, level)
562- b.ResetTimer()
563- for n := 0; n < b.N; n++ {
564- w.Reset(io.Discard)
565- n, err := w.Write(dat)
566- if n != len(dat) {
567- panic("short write")
568- }
569- if err != nil {
570- panic(err)
571- }
572- err = w.Close()
573- if err != nil {
574- panic(err)
575- }
576- }
577- }
578-
579- */
580-
581541func BenchmarkCompressAllocations (b * testing.B ) {
582542 payload := []byte (strings .Repeat ("Tiny payload" , 20 ))
583543 for j := - 2 ; j <= 9 ; j ++ {
0 commit comments