~mna/siberian

f3c8ffd01ea08b5874a8f7755bbfa17a03e2e0e3 — Martin Angers 4 years ago c57701e
add some benchmark to compare with stdlib
M internal/jsonmatcher/jsonmatcher_test.go => internal/jsonmatcher/jsonmatcher_test.go +26 -0
@@ 1,6 1,8 @@
package jsonmatcher

import (
	"encoding/json"
	"io/ioutil"
	"testing"

	"git.sr.ht/~mna/siberian"


@@ 36,3 38,27 @@ func TestMatches(t *testing.T) {
		})
	}
}

func BenchmarkJSON(b *testing.B) {
	d, err := ioutil.ReadFile("testdata/github-octokit-repos.json")
	if err != nil {
		b.Fatal(err)
	}

	b.Run("Matches", func(b *testing.B) {
		for i := 0; i < b.N; i++ {
			if !siberian.Matches(Doc, d) {
				b.Fatal(err)
			}
		}
	})

	b.Run("Stdlib", func(b *testing.B) {
		for i := 0; i < b.N; i++ {
			var iface interface{}
			if err := json.Unmarshal(d, &iface); err != nil {
				b.Fatal(err)
			}
		}
	})
}

A internal/jsonmatcher/testdata/github-octokit-repos.json => internal/jsonmatcher/testdata/github-octokit-repos.json +370 -0
@@ 0,0 1,370 @@
[
  {
    "id": 417862,
    "name": "octokit.rb",
    "full_name": "octokit/octokit.rb",
    "owner": {
      "login": "octokit",
      "id": 3430433,
      "avatar_url": "https://avatars.githubusercontent.com/u/3430433?v=3",
      "gravatar_id": "",
      "url": "https://api.github.com/users/octokit",
      "html_url": "https://github.com/octokit",
      "followers_url": "https://api.github.com/users/octokit/followers",
      "following_url": "https://api.github.com/users/octokit/following{/other_user}",
      "gists_url": "https://api.github.com/users/octokit/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/octokit/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/octokit/subscriptions",
      "organizations_url": "https://api.github.com/users/octokit/orgs",
      "repos_url": "https://api.github.com/users/octokit/repos",
      "events_url": "https://api.github.com/users/octokit/events{/privacy}",
      "received_events_url": "https://api.github.com/users/octokit/received_events",
      "type": "Organization",
      "site_admin": false
    },
    "private": false,
    "html_url": "https://github.com/octokit/octokit.rb",
    "description": "Ruby toolkit for the GitHub API",
    "fork": false,
    "url": "https://api.github.com/repos/octokit/octokit.rb",
    "forks_url": "https://api.github.com/repos/octokit/octokit.rb/forks",
    "keys_url": "https://api.github.com/repos/octokit/octokit.rb/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/octokit/octokit.rb/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/octokit/octokit.rb/teams",
    "hooks_url": "https://api.github.com/repos/octokit/octokit.rb/hooks",
    "issue_events_url": "https://api.github.com/repos/octokit/octokit.rb/issues/events{/number}",
    "events_url": "https://api.github.com/repos/octokit/octokit.rb/events",
    "assignees_url": "https://api.github.com/repos/octokit/octokit.rb/assignees{/user}",
    "branches_url": "https://api.github.com/repos/octokit/octokit.rb/branches{/branch}",
    "tags_url": "https://api.github.com/repos/octokit/octokit.rb/tags",
    "blobs_url": "https://api.github.com/repos/octokit/octokit.rb/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/octokit/octokit.rb/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/octokit/octokit.rb/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/octokit/octokit.rb/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/octokit/octokit.rb/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/octokit/octokit.rb/languages",
    "stargazers_url": "https://api.github.com/repos/octokit/octokit.rb/stargazers",
    "contributors_url": "https://api.github.com/repos/octokit/octokit.rb/contributors",
    "subscribers_url": "https://api.github.com/repos/octokit/octokit.rb/subscribers",
    "subscription_url": "https://api.github.com/repos/octokit/octokit.rb/subscription",
    "commits_url": "https://api.github.com/repos/octokit/octokit.rb/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/octokit/octokit.rb/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/octokit/octokit.rb/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/octokit/octokit.rb/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/octokit/octokit.rb/contents/{+path}",
    "compare_url": "https://api.github.com/repos/octokit/octokit.rb/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/octokit/octokit.rb/merges",
    "archive_url": "https://api.github.com/repos/octokit/octokit.rb/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/octokit/octokit.rb/downloads",
    "issues_url": "https://api.github.com/repos/octokit/octokit.rb/issues{/number}",
    "pulls_url": "https://api.github.com/repos/octokit/octokit.rb/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/octokit/octokit.rb/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/octokit/octokit.rb/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/octokit/octokit.rb/labels{/name}",
    "releases_url": "https://api.github.com/repos/octokit/octokit.rb/releases{/id}",
    "created_at": "2009-12-10T21:41:49Z",
    "updated_at": "2015-04-02T15:26:33Z",
    "pushed_at": "2015-03-25T01:12:36Z",
    "git_url": "git://github.com/octokit/octokit.rb.git",
    "ssh_url": "git@github.com:octokit/octokit.rb.git",
    "clone_url": "https://github.com/octokit/octokit.rb.git",
    "svn_url": "https://github.com/octokit/octokit.rb",
    "homepage": "http://octokit.github.io/octokit.rb/",
    "size": 16088,
    "stargazers_count": 1845,
    "watchers_count": 1845,
    "language": "Ruby",
    "has_issues": true,
    "has_downloads": true,
    "has_wiki": false,
    "has_pages": true,
    "forks_count": 401,
    "mirror_url": null,
    "open_issues_count": 5,
    "forks": 401,
    "open_issues": 5,
    "watchers": 1845,
    "default_branch": "master",
    "permissions": {
      "admin": false,
      "push": false,
      "pull": true
    }
  },
  {
    "id": 7528679,
    "name": "octokit.net",
    "full_name": "octokit/octokit.net",
    "owner": {
      "login": "octokit",
      "id": 3430433,
      "avatar_url": "https://avatars.githubusercontent.com/u/3430433?v=3",
      "gravatar_id": "",
      "url": "https://api.github.com/users/octokit",
      "html_url": "https://github.com/octokit",
      "followers_url": "https://api.github.com/users/octokit/followers",
      "following_url": "https://api.github.com/users/octokit/following{/other_user}",
      "gists_url": "https://api.github.com/users/octokit/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/octokit/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/octokit/subscriptions",
      "organizations_url": "https://api.github.com/users/octokit/orgs",
      "repos_url": "https://api.github.com/users/octokit/repos",
      "events_url": "https://api.github.com/users/octokit/events{/privacy}",
      "received_events_url": "https://api.github.com/users/octokit/received_events",
      "type": "Organization",
      "site_admin": false
    },
    "private": false,
    "html_url": "https://github.com/octokit/octokit.net",
    "description": "A GitHub API client library for .NET ",
    "fork": false,
    "url": "https://api.github.com/repos/octokit/octokit.net",
    "forks_url": "https://api.github.com/repos/octokit/octokit.net/forks",
    "keys_url": "https://api.github.com/repos/octokit/octokit.net/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/octokit/octokit.net/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/octokit/octokit.net/teams",
    "hooks_url": "https://api.github.com/repos/octokit/octokit.net/hooks",
    "issue_events_url": "https://api.github.com/repos/octokit/octokit.net/issues/events{/number}",
    "events_url": "https://api.github.com/repos/octokit/octokit.net/events",
    "assignees_url": "https://api.github.com/repos/octokit/octokit.net/assignees{/user}",
    "branches_url": "https://api.github.com/repos/octokit/octokit.net/branches{/branch}",
    "tags_url": "https://api.github.com/repos/octokit/octokit.net/tags",
    "blobs_url": "https://api.github.com/repos/octokit/octokit.net/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/octokit/octokit.net/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/octokit/octokit.net/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/octokit/octokit.net/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/octokit/octokit.net/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/octokit/octokit.net/languages",
    "stargazers_url": "https://api.github.com/repos/octokit/octokit.net/stargazers",
    "contributors_url": "https://api.github.com/repos/octokit/octokit.net/contributors",
    "subscribers_url": "https://api.github.com/repos/octokit/octokit.net/subscribers",
    "subscription_url": "https://api.github.com/repos/octokit/octokit.net/subscription",
    "commits_url": "https://api.github.com/repos/octokit/octokit.net/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/octokit/octokit.net/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/octokit/octokit.net/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/octokit/octokit.net/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/octokit/octokit.net/contents/{+path}",
    "compare_url": "https://api.github.com/repos/octokit/octokit.net/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/octokit/octokit.net/merges",
    "archive_url": "https://api.github.com/repos/octokit/octokit.net/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/octokit/octokit.net/downloads",
    "issues_url": "https://api.github.com/repos/octokit/octokit.net/issues{/number}",
    "pulls_url": "https://api.github.com/repos/octokit/octokit.net/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/octokit/octokit.net/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/octokit/octokit.net/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/octokit/octokit.net/labels{/name}",
    "releases_url": "https://api.github.com/repos/octokit/octokit.net/releases{/id}",
    "created_at": "2013-01-09T20:48:45Z",
    "updated_at": "2015-04-02T18:10:11Z",
    "pushed_at": "2015-04-03T11:47:52Z",
    "git_url": "git://github.com/octokit/octokit.net.git",
    "ssh_url": "git@github.com:octokit/octokit.net.git",
    "clone_url": "https://github.com/octokit/octokit.net.git",
    "svn_url": "https://github.com/octokit/octokit.net",
    "homepage": null,
    "size": 70529,
    "stargazers_count": 637,
    "watchers_count": 637,
    "language": "C#",
    "has_issues": true,
    "has_downloads": true,
    "has_wiki": false,
    "has_pages": false,
    "forks_count": 270,
    "mirror_url": null,
    "open_issues_count": 63,
    "forks": 270,
    "open_issues": 63,
    "watchers": 637,
    "default_branch": "master",
    "permissions": {
      "admin": false,
      "push": false,
      "pull": true
    }
  },
  {
    "id": 7530454,
    "name": "octokit.objc",
    "full_name": "octokit/octokit.objc",
    "owner": {
      "login": "octokit",
      "id": 3430433,
      "avatar_url": "https://avatars.githubusercontent.com/u/3430433?v=3",
      "gravatar_id": "",
      "url": "https://api.github.com/users/octokit",
      "html_url": "https://github.com/octokit",
      "followers_url": "https://api.github.com/users/octokit/followers",
      "following_url": "https://api.github.com/users/octokit/following{/other_user}",
      "gists_url": "https://api.github.com/users/octokit/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/octokit/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/octokit/subscriptions",
      "organizations_url": "https://api.github.com/users/octokit/orgs",
      "repos_url": "https://api.github.com/users/octokit/repos",
      "events_url": "https://api.github.com/users/octokit/events{/privacy}",
      "received_events_url": "https://api.github.com/users/octokit/received_events",
      "type": "Organization",
      "site_admin": false
    },
    "private": false,
    "html_url": "https://github.com/octokit/octokit.objc",
    "description": "GitHub API client for Objective-C",
    "fork": false,
    "url": "https://api.github.com/repos/octokit/octokit.objc",
    "forks_url": "https://api.github.com/repos/octokit/octokit.objc/forks",
    "keys_url": "https://api.github.com/repos/octokit/octokit.objc/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/octokit/octokit.objc/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/octokit/octokit.objc/teams",
    "hooks_url": "https://api.github.com/repos/octokit/octokit.objc/hooks",
    "issue_events_url": "https://api.github.com/repos/octokit/octokit.objc/issues/events{/number}",
    "events_url": "https://api.github.com/repos/octokit/octokit.objc/events",
    "assignees_url": "https://api.github.com/repos/octokit/octokit.objc/assignees{/user}",
    "branches_url": "https://api.github.com/repos/octokit/octokit.objc/branches{/branch}",
    "tags_url": "https://api.github.com/repos/octokit/octokit.objc/tags",
    "blobs_url": "https://api.github.com/repos/octokit/octokit.objc/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/octokit/octokit.objc/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/octokit/octokit.objc/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/octokit/octokit.objc/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/octokit/octokit.objc/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/octokit/octokit.objc/languages",
    "stargazers_url": "https://api.github.com/repos/octokit/octokit.objc/stargazers",
    "contributors_url": "https://api.github.com/repos/octokit/octokit.objc/contributors",
    "subscribers_url": "https://api.github.com/repos/octokit/octokit.objc/subscribers",
    "subscription_url": "https://api.github.com/repos/octokit/octokit.objc/subscription",
    "commits_url": "https://api.github.com/repos/octokit/octokit.objc/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/octokit/octokit.objc/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/octokit/octokit.objc/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/octokit/octokit.objc/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/octokit/octokit.objc/contents/{+path}",
    "compare_url": "https://api.github.com/repos/octokit/octokit.objc/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/octokit/octokit.objc/merges",
    "archive_url": "https://api.github.com/repos/octokit/octokit.objc/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/octokit/octokit.objc/downloads",
    "issues_url": "https://api.github.com/repos/octokit/octokit.objc/issues{/number}",
    "pulls_url": "https://api.github.com/repos/octokit/octokit.objc/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/octokit/octokit.objc/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/octokit/octokit.objc/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/octokit/octokit.objc/labels{/name}",
    "releases_url": "https://api.github.com/repos/octokit/octokit.objc/releases{/id}",
    "created_at": "2013-01-09T22:42:53Z",
    "updated_at": "2015-04-03T06:16:41Z",
    "pushed_at": "2015-03-21T17:10:20Z",
    "git_url": "git://github.com/octokit/octokit.objc.git",
    "ssh_url": "git@github.com:octokit/octokit.objc.git",
    "clone_url": "https://github.com/octokit/octokit.objc.git",
    "svn_url": "https://github.com/octokit/octokit.objc",
    "homepage": "",
    "size": 3779,
    "stargazers_count": 1131,
    "watchers_count": 1131,
    "language": "Objective-C",
    "has_issues": true,
    "has_downloads": true,
    "has_wiki": true,
    "has_pages": false,
    "forks_count": 170,
    "mirror_url": null,
    "open_issues_count": 26,
    "forks": 170,
    "open_issues": 26,
    "watchers": 1131,
    "default_branch": "master",
    "permissions": {
      "admin": false,
      "push": false,
      "pull": true
    }
  },
  {
    "id": 10575811,
    "name": "go-octokit",
    "full_name": "octokit/go-octokit",
    "owner": {
      "login": "octokit",
      "id": 3430433,
      "avatar_url": "https://avatars.githubusercontent.com/u/3430433?v=3",
      "gravatar_id": "",
      "url": "https://api.github.com/users/octokit",
      "html_url": "https://github.com/octokit",
      "followers_url": "https://api.github.com/users/octokit/followers",
      "following_url": "https://api.github.com/users/octokit/following{/other_user}",
      "gists_url": "https://api.github.com/users/octokit/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/octokit/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/octokit/subscriptions",
      "organizations_url": "https://api.github.com/users/octokit/orgs",
      "repos_url": "https://api.github.com/users/octokit/repos",
      "events_url": "https://api.github.com/users/octokit/events{/privacy}",
      "received_events_url": "https://api.github.com/users/octokit/received_events",
      "type": "Organization",
      "site_admin": false
    },
    "private": false,
    "html_url": "https://github.com/octokit/go-octokit",
    "description": "Simple Go wrapper for the GitHub API",
    "fork": false,
    "url": "https://api.github.com/repos/octokit/go-octokit",
    "forks_url": "https://api.github.com/repos/octokit/go-octokit/forks",
    "keys_url": "https://api.github.com/repos/octokit/go-octokit/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/octokit/go-octokit/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/octokit/go-octokit/teams",
    "hooks_url": "https://api.github.com/repos/octokit/go-octokit/hooks",
    "issue_events_url": "https://api.github.com/repos/octokit/go-octokit/issues/events{/number}",
    "events_url": "https://api.github.com/repos/octokit/go-octokit/events",
    "assignees_url": "https://api.github.com/repos/octokit/go-octokit/assignees{/user}",
    "branches_url": "https://api.github.com/repos/octokit/go-octokit/branches{/branch}",
    "tags_url": "https://api.github.com/repos/octokit/go-octokit/tags",
    "blobs_url": "https://api.github.com/repos/octokit/go-octokit/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/octokit/go-octokit/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/octokit/go-octokit/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/octokit/go-octokit/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/octokit/go-octokit/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/octokit/go-octokit/languages",
    "stargazers_url": "https://api.github.com/repos/octokit/go-octokit/stargazers",
    "contributors_url": "https://api.github.com/repos/octokit/go-octokit/contributors",
    "subscribers_url": "https://api.github.com/repos/octokit/go-octokit/subscribers",
    "subscription_url": "https://api.github.com/repos/octokit/go-octokit/subscription",
    "commits_url": "https://api.github.com/repos/octokit/go-octokit/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/octokit/go-octokit/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/octokit/go-octokit/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/octokit/go-octokit/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/octokit/go-octokit/contents/{+path}",
    "compare_url": "https://api.github.com/repos/octokit/go-octokit/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/octokit/go-octokit/merges",
    "archive_url": "https://api.github.com/repos/octokit/go-octokit/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/octokit/go-octokit/downloads",
    "issues_url": "https://api.github.com/repos/octokit/go-octokit/issues{/number}",
    "pulls_url": "https://api.github.com/repos/octokit/go-octokit/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/octokit/go-octokit/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/octokit/go-octokit/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/octokit/go-octokit/labels{/name}",
    "releases_url": "https://api.github.com/repos/octokit/go-octokit/releases{/id}",
    "created_at": "2013-06-08T23:50:29Z",
    "updated_at": "2015-04-02T18:47:34Z",
    "pushed_at": "2015-04-02T18:48:16Z",
    "git_url": "git://github.com/octokit/go-octokit.git",
    "ssh_url": "git@github.com:octokit/go-octokit.git",
    "clone_url": "https://github.com/octokit/go-octokit.git",
    "svn_url": "https://github.com/octokit/go-octokit",
    "homepage": "https://github.com/octokit/go-octokit",
    "size": 3693,
    "stargazers_count": 106,
    "watchers_count": 106,
    "language": "Go",
    "has_issues": true,
    "has_downloads": true,
    "has_wiki": false,
    "has_pages": false,
    "forks_count": 29,
    "mirror_url": null,
    "open_issues_count": 16,
    "forks": 29,
    "open_issues": 16,
    "watchers": 106,
    "default_branch": "master",
    "permissions": {
      "admin": false,
      "push": false,
      "pull": true
    }
  }
]