github.com/zhongdalu/gf@v1.0.0/g/encoding/ghash/ghash_test.go (about)

     1  // Copyright 2017 gf Author(https://github.com/zhongdalu/gf). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/zhongdalu/gf.
     6  
     7  // go test *.go -bench=".*"
     8  
     9  package ghash_test
    10  
    11  import (
    12  	"github.com/zhongdalu/gf/g/encoding/ghash"
    13  	"testing"
    14  )
    15  
    16  var (
    17  	str = []byte("This is the test string for hash.")
    18  )
    19  
    20  func BenchmarkBKDRHash(b *testing.B) {
    21  	for i := 0; i < b.N; i++ {
    22  		ghash.BKDRHash(str)
    23  	}
    24  }
    25  
    26  func BenchmarkBKDRHash64(b *testing.B) {
    27  	for i := 0; i < b.N; i++ {
    28  		ghash.BKDRHash64(str)
    29  	}
    30  }
    31  
    32  func BenchmarkSDBMHash(b *testing.B) {
    33  	for i := 0; i < b.N; i++ {
    34  		ghash.SDBMHash(str)
    35  	}
    36  }
    37  
    38  func BenchmarkSDBMHash64(b *testing.B) {
    39  	for i := 0; i < b.N; i++ {
    40  		ghash.SDBMHash64(str)
    41  	}
    42  }
    43  
    44  func BenchmarkRSHash(b *testing.B) {
    45  	for i := 0; i < b.N; i++ {
    46  		ghash.RSHash(str)
    47  	}
    48  }
    49  
    50  func BenchmarkSRSHash64(b *testing.B) {
    51  	for i := 0; i < b.N; i++ {
    52  		ghash.RSHash64(str)
    53  	}
    54  }
    55  
    56  func BenchmarkJSHash(b *testing.B) {
    57  	for i := 0; i < b.N; i++ {
    58  		ghash.JSHash(str)
    59  	}
    60  }
    61  
    62  func BenchmarkJSHash64(b *testing.B) {
    63  	for i := 0; i < b.N; i++ {
    64  		ghash.JSHash64(str)
    65  	}
    66  }
    67  
    68  func BenchmarkPJWHash(b *testing.B) {
    69  	for i := 0; i < b.N; i++ {
    70  		ghash.PJWHash(str)
    71  	}
    72  }
    73  
    74  func BenchmarkPJWHash64(b *testing.B) {
    75  	for i := 0; i < b.N; i++ {
    76  		ghash.PJWHash64(str)
    77  	}
    78  }
    79  
    80  func BenchmarkELFHash(b *testing.B) {
    81  	for i := 0; i < b.N; i++ {
    82  		ghash.ELFHash(str)
    83  	}
    84  }
    85  
    86  func BenchmarkELFHash64(b *testing.B) {
    87  	for i := 0; i < b.N; i++ {
    88  		ghash.ELFHash64(str)
    89  	}
    90  }
    91  
    92  func BenchmarkDJBHash(b *testing.B) {
    93  	for i := 0; i < b.N; i++ {
    94  		ghash.DJBHash(str)
    95  	}
    96  }
    97  
    98  func BenchmarkDJBHash64(b *testing.B) {
    99  	for i := 0; i < b.N; i++ {
   100  		ghash.DJBHash64(str)
   101  	}
   102  }
   103  
   104  func BenchmarkAPHash(b *testing.B) {
   105  	for i := 0; i < b.N; i++ {
   106  		ghash.APHash(str)
   107  	}
   108  }
   109  
   110  func BenchmarkAPHash64(b *testing.B) {
   111  	for i := 0; i < b.N; i++ {
   112  		ghash.APHash64(str)
   113  	}
   114  }