From b7c99f00cb9cd9264f810d72aeae8a0b509ab2a1 Mon Sep 17 00:00:00 2001 From: "Edwin Liu (RD-TW)" Date: Mon, 9 Sep 2019 00:19:07 +0800 Subject: [PATCH] Use go modules --- .gitignore | 184 ++++++++++++++++++++++++++++++++++++++++++++++++++++- Gopkg.lock | 39 ------------ Gopkg.toml | 30 --------- Makefile | 7 +- README.md | 20 +++--- go.mod | 9 +++ go.sum | 14 ++++ 7 files changed, 216 insertions(+), 87 deletions(-) delete mode 100644 Gopkg.lock delete mode 100644 Gopkg.toml create mode 100644 go.mod create mode 100644 go.sum diff --git a/.gitignore b/.gitignore index 8f94280..3d38ba8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,184 @@ -# Custom .coverprofile .coverprofile.html +# Created by https://www.gitignore.io/api/macos,windows,linux,vim,jetbrains +# Edit at https://www.gitignore.io/?templates=macos,windows,linux,vim,jetbrains + +### JetBrains ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +.idea + +# User-specific stuff +#.idea/**/workspace.xml +#.idea/**/tasks.xml +#.idea/**/usage.statistics.xml +#.idea/**/dictionaries +#.idea/**/shelf + +# Generated files +#.idea/**/contentModel.xml + +# Sensitive or high-churn files +#.idea/**/dataSources/ +#.idea/**/dataSources.ids +#.idea/**/dataSources.local.xml +#.idea/**/sqlDataSources.xml +#.idea/**/dynamic.xml +#.idea/**/uiDesigner.xml +#.idea/**/dbnavigator.xml + +# Gradle +#.idea/**/gradle.xml +#.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +#.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +#.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +#.idea/httpRequests + +# Android studio 3.1+ serialized cache file +#.idea/caches/build_file_checksums.ser + +### JetBrains Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +#.idea/sonarlint + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.gitignore.io/api/macos,windows,linux,vim,jetbrains + # Created by https://www.gitignore.io/api/go +# Edit at https://www.gitignore.io/?templates=go ### Go ### # Binaries for programs and plugins @@ -12,15 +188,17 @@ *.so *.dylib -# Test binary, build with `go test -c` +# Test binary, built with `go test -c` *.test # Output of the go coverage tool, specifically when used with LiteIDE *.out +# Dependency directories (remove the comment below to include it) +# vendor/ + ### Go Patch ### /vendor/ /Godeps/ - # End of https://www.gitignore.io/api/go diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index 01d4415..0000000 --- a/Gopkg.lock +++ /dev/null @@ -1,39 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - name = "github.com/davecgh/go-spew" - packages = ["spew"] - revision = "346938d642f2ec3594ed81d874461961cd0faa76" - version = "v1.1.0" - -[[projects]] - branch = "master" - name = "github.com/loganjspears/joker" - packages = ["hand"] - revision = "3f2f69a75914c1af9b9949c1718b63da40ca1b19" - -[[projects]] - branch = "master" - name = "github.com/notnil/joker" - packages = ["util"] - revision = "3f2f69a75914c1af9b9949c1718b63da40ca1b19" - -[[projects]] - name = "github.com/pmezard/go-difflib" - packages = ["difflib"] - revision = "792786c7400a136282c1664665ae0a8db921c6c2" - version = "v1.0.0" - -[[projects]] - name = "github.com/stretchr/testify" - packages = ["assert"] - revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686" - version = "v1.2.2" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - inputs-digest = "14d100d331065746c26b8b49d803d570cf37f058b48f9ced61f3e0ac69ea56f4" - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index 24f0f17..0000000 --- a/Gopkg.toml +++ /dev/null @@ -1,30 +0,0 @@ -# Gopkg.toml example -# -# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" -# -# [prune] -# non-go = false -# go-tests = true -# unused-packages = true - - -[prune] - go-tests = true - unused-packages = true diff --git a/Makefile b/Makefile index 7ebf574..222e304 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,8 @@ -TEST_FLAGS = -short -EXTRA_FLAGS = - .PHONY: test test: - go test -coverprofile .coverprofile -timeout 10m $(TEST_FLAGS) $(EXTRA_FLAGS) ./... + go test -coverprofile .coverprofile -timeout 10m ./... go tool cover -html .coverprofile -o .coverprofile.html .PHONY: benchmark benchmark: - go test -bench=. \ No newline at end of file + go test -bench=. -benchtime 5s diff --git a/README.md b/README.md index 29e854e..765e7db 100644 --- a/README.md +++ b/README.md @@ -55,19 +55,19 @@ Three of a Kind ## Performance -Compared with [notnil/joker](https://github.com/notnil/joker), Poker is 180x faster on 5-card evaluation, and drops to 50x faster on 7-card evaluation. +Compared with [notnil/joker](https://github.com/notnil/joker), Poker is 160x faster on 5-card evaluation, and drops to 40x faster on 7-card evaluation. ```sh -$ go test -bench=. -benchtime 5s +go test -bench=. -benchtime 5s goos: darwin goarch: amd64 pkg: github.com/chehsunliu/poker -BenchmarkFivePoker-4 20000000 280 ns/op -BenchmarkFiveJoker-4 100000 50769 ns/op -BenchmarkSixPoker-4 3000000 2428 ns/op -BenchmarkSixJoker-4 30000 272321 ns/op -BenchmarkSevenPoker-4 300000 20317 ns/op -BenchmarkSevenJoker-4 5000 1062044 ns/op +BenchmarkFivePoker-4 23396181 253 ns/op +BenchmarkFiveJoker-4 141036 41662 ns/op +BenchmarkSixPoker-4 3037298 1949 ns/op +BenchmarkSixJoker-4 28158 211533 ns/op +BenchmarkSevenPoker-4 356448 16357 ns/op +BenchmarkSevenJoker-4 7143 759394 ns/op PASS -ok github.com/chehsunliu/poker 43.996s -``` \ No newline at end of file +ok github.com/chehsunliu/poker 40.111s +``` diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..466ce92 --- /dev/null +++ b/go.mod @@ -0,0 +1,9 @@ +module github.com/chehsunliu/poker + +go 1.13 + +require ( + github.com/loganjspears/joker v0.0.0-20180219043703-3f2f69a75914 + github.com/notnil/joker v0.0.0-20180219043703-3f2f69a75914 // indirect + github.com/stretchr/testify v1.4.0 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..6a352a8 --- /dev/null +++ b/go.sum @@ -0,0 +1,14 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/loganjspears/joker v0.0.0-20180219043703-3f2f69a75914 h1:yAIlIiOkdoJvqd5xtWzM9tNDpLZrFfJdpnNSKha78G8= +github.com/loganjspears/joker v0.0.0-20180219043703-3f2f69a75914/go.mod h1:76SAnflG7ZFhgtnaVCpP6A5Z1S/VMFzRBN7KGm5j4oc= +github.com/notnil/joker v0.0.0-20180219043703-3f2f69a75914 h1:xXPuFr3PVM4p6Vw3j0CP29oWYRVKO3cPZjR6D7BxggQ= +github.com/notnil/joker v0.0.0-20180219043703-3f2f69a75914/go.mod h1:L0Sdr2nYdktjerdXpIn9wOCn+GebPs/nCL2qH6RTGa0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=