Skip to content

Instantly share code, notes, and snippets.

@mantyr
Last active August 29, 2015 14:23
Show Gist options
  • Save mantyr/6603c56d0e46df77d291 to your computer and use it in GitHub Desktop.
Save mantyr/6603c56d0e46df77d291 to your computer and use it in GitHub Desktop.
How to understand the delay on time?
$ go get github.com/fiam/gounidecode/unidecode
$ go get github.com/rainycape/unidecode
$ time go test github.com/fiam/gounidecode/unidecode
ok github.com/fiam/gounidecode/unidecode 0.039s
real 0m9.629s
user 0m1.621s
sys 0m1.647s
$ time go test github.com/rainycape/unidecode
ok github.com/rainycape/unidecode 0.197s
real 0m1.000s
user 0m0.328s
sys 0m0.154s
$ time go install ./test.go
real 0m0.534s
user 0m0.223s
sys 0m0.043s
$ time ./test
ABCDEF
Knosos
Bei Jing
real 0m0.034s
user 0m0.017s
sys 0m0.000s
package main
import (
uni "github.com/fiam/gounidecode/unidecode"
"fmt"
)
func testTransliteration(original string, decoded string) {
if r := uni.Unidecode(original); r != decoded {
fmt.Println("Error", decoded)
}
fmt.Println(decoded)
}
func TestASCII() {
s := "ABCDEF"
testTransliteration(s, s)
}
func TestKnosos() {
o := "Κνωσός"
d := "Knosos"
testTransliteration(o, d)
}
func TestBeiJing() {
o := "\u5317\u4EB0"
d := "Bei Jing "
testTransliteration(o, d)
}
func main() {
TestASCII()
TestKnosos()
TestBeiJing()
}
@mantyr
Copy link
Author

mantyr commented Jun 17, 2015

# time go test github.com/fiam/gounidecode/unidecode
ok      github.com/fiam/gounidecode/unidecode   0.038s

real    0m26.925s
user    0m2.329s
sys 0m1.926s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment