{"action":"created","issue":{"url":"https://api.github.com/repos/ugorji/go/issues/107","labels_url":"https://api.github.com/repos/ugorji/go/issues/107/labels{/name}","comments_url":"https://api.github.com/repos/ugorji/go/issues/107/comments","events_url":"https://api.github.com/repos/ugorji/go/issues/107/events","html_url":"https://github.com/ugorji/go/issues/107","id":111066195,"number":107,"title":"Slower than encoding/json","user":{"login":"atombender","id":50314,"avatar_url":"https://avatars.githubusercontent.com/u/50314?v=3","gravatar_id":"","url":"https://api.github.com/users/atombender","html_url":"https://github.com/atombender","followers_url":"https://api.github.com/users/atombender/followers","following_url":"https://api.github.com/users/atombender/following{/other_user}","gists_url":"https://api.github.com/users/atombender/gists{/gist_id}","starred_url":"https://api.github.com/users/atombender/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atombender/subscriptions","organizations_url":"https://api.github.com/users/atombender/orgs","repos_url":"https://api.github.com/users/atombender/repos","events_url":"https://api.github.com/users/atombender/events{/privacy}","received_events_url":"https://api.github.com/users/atombender/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2015-10-12T22:18:59Z","updated_at":"2015-10-13T23:27:46Z","closed_at":"2015-10-13T19:31:32Z","body":"Here's my test:\r\n\r\n```go\r\nn := 5\r\n\r\nlog.Print(\"encoding/json\")\r\nfor i := 0; i < n; i++ {\r\n  t := time.Now()\r\n  var v interface{}\r\n  for j := 0; j < 20; j++ {\r\n    if err = json.Unmarshal(b, &v); err != nil {\r\n      panic(err)\r\n    }\r\n  }\r\n  log.Print(time.Now().Sub(t))\r\n}\r\n\r\nlog.Print(\"go-codec\")\r\nfor i := 0; i < n; i++ {\r\n  t := time.Now()\r\n  for j := 0; j < 20; j++ {\r\n    var dec *codec.Decoder = codec.NewDecoderBytes(b, new(codec.JsonHandle))\r\n    var v interface{}\r\n    if err := dec.Decode(&v); err != nil {\r\n      panic(err)\r\n    }\r\n  }\r\n  log.Print(time.Now().Sub(t))\r\n}\r\n```\r\n\r\nFor a large, minified file with long keys (4.7MB), `go-codec` is ~ 31% _slower_ than `encoding/json`:\r\n\r\n```\r\nencoding/json\r\n1.617601942s\r\n1.576523967s\r\n1.610622356s\r\n1.608594081s\r\n1.647141938s\r\ngo-codec\r\n2.129585437s\r\n2.166288614s\r\n2.1520013s\r\n2.061147463s\r\n2.102718168s\r\n```\r\n\r\nFor a file containing the same values, but with every key shortened to just 2 characters (970KB), it's 80% slower:\r\n\r\n```\r\nencoding/json\r\n474.933239ms\r\n451.410297ms\r\n452.822768ms\r\n462.508272ms\r\n456.032676ms\r\ngo-codec\r\n852.508337ms\r\n849.04073ms\r\n830.897711ms\r\n852.40816ms\r\n826.848954ms\r\n```\r\n\r\nThis is from byte arrays into `interface{}` values. Is there anything I can tweak to make `go-codec` be faster? Is this by design, somehow?\r\n\r\nGo 1.5.1 on OS X.\r\n"},"comment":{"url":"https://api.github.com/repos/ugorji/go/issues/comments/147882305","html_url":"https://github.com/ugorji/go/issues/107#issuecomment-147882305","issue_url":"https://api.github.com/repos/ugorji/go/issues/107","id":147882305,"user":{"login":"atombender","id":50314,"avatar_url":"https://avatars.githubusercontent.com/u/50314?v=3","gravatar_id":"","url":"https://api.github.com/users/atombender","html_url":"https://github.com/atombender","followers_url":"https://api.github.com/users/atombender/followers","following_url":"https://api.github.com/users/atombender/following{/other_user}","gists_url":"https://api.github.com/users/atombender/gists{/gist_id}","starred_url":"https://api.github.com/users/atombender/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atombender/subscriptions","organizations_url":"https://api.github.com/users/atombender/orgs","repos_url":"https://api.github.com/users/atombender/repos","events_url":"https://api.github.com/users/atombender/events{/privacy}","received_events_url":"https://api.github.com/users/atombender/received_events","type":"User","site_admin":false},"created_at":"2015-10-13T23:27:46Z","updated_at":"2015-10-13T23:27:46Z","body":"Superb!"}}