ip2region_test.go 382 B

123456789101112131415161718192021222324
  1. package ip2region
  2. import (
  3. "fmt"
  4. "github.com/lionsoul2014/ip2region/binding/golang/ip2region"
  5. "testing"
  6. )
  7. var r *ip2region.Ip2Region
  8. func init() {
  9. var err error
  10. r, err = ip2region.New("../../conf/ip2region.db")
  11. if err != nil {
  12. fmt.Printf("%s", err)
  13. }
  14. }
  15. func BenchmarkIp2Region(b *testing.B) {
  16. ip := "36.161.36.225"
  17. for i := 0; i < b.N; i++ {
  18. r.MemorySearch(ip)
  19. }
  20. }