{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/performance/pulls/comments/240827989","pull_request_review_id":183949638,"id":240827989,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MDgyNzk4OQ==","diff_hunk":"@@ -0,0 +1,156 @@\n+// Licensed to the .NET Foundation under one or more agreements.\n+// The .NET Foundation licenses this file to you under the MIT license.\n+// See the LICENSE file in the project root for more information.\n+\n+\n+using System.Collections.Generic;\n+using BenchmarkDotNet.Attributes;\n+using MicroBenchmarks;\n+\n+namespace System.Text.Json.Tests\n+{\n+    [BenchmarkCategory(Categories.CoreFX)]\n+    public class Perf_Utf8JsonReader\n+    {\n+        [ParamsSource(nameof(DataGenerator))]\n+        public JsonNumberSet NumberSet { get; set; }\n+\n+        public IEnumerable<JsonNumberSet> DataGenerator()\n+        {\n+            yield return new JsonNumberSet(\"positive numbers\", \"1234\", \"12345678901\", \"1234.5678\", \"1234.5678\", \"1234.5678\");\n+            \n+            yield return new JsonNumberSet(\"positive numbers e2\", \"1234e2\", \"12345678901e2\", \"1234.5678e2\", \"1234.5678e2\", \"1234.5678e2\");\n+            yield return new JsonNumberSet(\"positive numbers e+2\", \"1234e+2\", \"12345678901e+2\", \"1234.5678e+2\", \"1234.5678e+2\", \"1234.5678e+2\");\n+            yield return new JsonNumberSet(\"positive numbers e-2\", \"1234e-2\", \"12345678901e-2\", \"1234.5678e-2\", \"1234.5678e-2\", \"1234.5678e-2\");\n+            \n+            yield return new JsonNumberSet(\"positive numbers E2\", \"1234E2\", \"12345678901E2\", \"1234.5678E2\", \"1234.5678E2\", \"1234.5678E2\");\n+            yield return new JsonNumberSet(\"positive numbers E+2\", \"1234E+2\", \"12345678901E+2\", \"1234.5678E+2\", \"1234.5678E+2\", \"1234.5678E+2\");\n+            yield return new JsonNumberSet(\"positive numbers E-2\", \"1234E-2\", \"12345678901E-2\", \"1234.5678E-2\", \"1234.5678E-2\", \"1234.5678E-2\");\n+            \n+            yield return new JsonNumberSet(\"negative numbers\", \"-1234\", \"-12345678901\", \"-1234.5678\", \"-1234.5678\", \"-1234.5678\");\n+            \n+            yield return new JsonNumberSet(\"negative numbers e2\", \"-1234e2\", \"-12345678901e2\", \"-1234.5678e2\", \"-1234.5678e2\", \"-1234.5678e2\");\n+            yield return new JsonNumberSet(\"negative numbers e+2\", \"-1234e+2\", \"-12345678901e+2\", \"-1234.5678e+2\", \"-1234.5678e+2\", \"-1234.5678e+2\");\n+            yield return new JsonNumberSet(\"negative numbers e-2\", \"-1234e-2\", \"-12345678901e-2\", \"-1234.5678e-2\", \"-1234.5678e-2\", \"-1234.5678e-2\");\n+            \n+            yield return new JsonNumberSet(\"negative numbers E2\", \"-1234E2\", \"-12345678901E2\", \"-1234.5678E2\", \"-1234.5678E2\", \"-1234.5678E2\");\n+            yield return new JsonNumberSet(\"negative numbers E+2\", \"-1234E+2\", \"-12345678901E+2\", \"-1234.5678E+2\", \"-1234.5678E+2\", \"-1234.5678E+2\");\n+            yield return new JsonNumberSet(\"negative numbers E-2\", \"-1234E-2\", \"-12345678901E-2\", \"-1234.5678E-2\", \"-1234.5678E-2\", \"-1234.5678E-2\");\n+        }\n+\n+        [Benchmark]\n+        public int GetInt32Value() => GetInt32(NumberSet.int32Json);\n+\n+        [Benchmark]\n+        public long GetInt64Value() => GetInt64(NumberSet.int64Json);\n+\n+        [Benchmark]\n+        public float GetSingleValue() => GetSingleValue(NumberSet.floatJson);\n+\n+        [Benchmark]\n+        public double GetDoubleValue() => GetDoubleValue(NumberSet.doubleJson);\n+\n+        [Benchmark]\n+        public decimal GetDecimalValue() => GetDecimalValue(NumberSet.decimalJson);\n+\n+        private int GetInt32(ReadOnlySpan<byte> value)\n+        {\n+            var json = new Utf8JsonReader(value, isFinalBlock: true, state: default);","path":"src/benchmarks/micro/corefx/System.Text.Json/Perf.Utf8JsonReader.cs","position":58,"original_position":58,"commit_id":"1305aab64c14a54deace1c82e995a5a5e1598229","original_commit_id":"1305aab64c14a54deace1c82e995a5a5e1598229","user":{"login":"ahsonkhan","id":6527137,"node_id":"MDQ6VXNlcjY1MjcxMzc=","avatar_url":"https://avatars1.githubusercontent.com/u/6527137?v=4","gravatar_id":"","url":"https://api.github.com/users/ahsonkhan","html_url":"https://github.com/ahsonkhan","followers_url":"https://api.github.com/users/ahsonkhan/followers","following_url":"https://api.github.com/users/ahsonkhan/following{/other_user}","gists_url":"https://api.github.com/users/ahsonkhan/gists{/gist_id}","starred_url":"https://api.github.com/users/ahsonkhan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahsonkhan/subscriptions","organizations_url":"https://api.github.com/users/ahsonkhan/orgs","repos_url":"https://api.github.com/users/ahsonkhan/repos","events_url":"https://api.github.com/users/ahsonkhan/events{/privacy}","received_events_url":"https://api.github.com/users/ahsonkhan/received_events","type":"User","site_admin":false},"body":"If we are explicitly trying to measure how fast does the JsonReader reads and returns numbers specifically, I would try to minimize the overhead of creating a JsonReader and potentially even the loop checks. We can achieve this by having the reader read through a large array of (potentially random) numbers (so that the extra overhead is amortized).\r\n\r\nSomething like:\r\n```C#\r\ndata = [number0, number1, number2, ..., numberN];\r\nvar json = new Utf8JsonReader(data, isFinalBlock: true, state: default);\r\nwhile (json.Read());\r\n```\r\n\r\nOR\r\n\r\n```C#\r\ndata = [number0, number1, number2, ..., numberN];\r\nint result = 0;\r\nvar json = new Utf8JsonReader(data, isFinalBlock: true, state: default);\r\nwhile (json.Read())\r\n{\r\n   // DO token type checks.\r\n   json.TryGetInt32Value(out var currentInt);\r\n   result |= currentInt;\r\n}\r\nreturn result;\r\n```","created_at":"2018-12-11T23:14:36Z","updated_at":"2018-12-11T23:14:36Z","html_url":"https://github.com/dotnet/performance/pull/185#discussion_r240827989","pull_request_url":"https://api.github.com/repos/dotnet/performance/pulls/185","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/dotnet/performance/pulls/comments/240827989"},"html":{"href":"https://github.com/dotnet/performance/pull/185#discussion_r240827989"},"pull_request":{"href":"https://api.github.com/repos/dotnet/performance/pulls/185"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/performance/pulls/185","id":237481676,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM3NDgxNjc2","html_url":"https://github.com/dotnet/performance/pull/185","diff_url":"https://github.com/dotnet/performance/pull/185.diff","patch_url":"https://github.com/dotnet/performance/pull/185.patch","issue_url":"https://api.github.com/repos/dotnet/performance/issues/185","number":185,"state":"open","locked":false,"title":"Add benchmarks for Utf8JsonReader","user":{"login":"tkp1n","id":9985284,"node_id":"MDQ6VXNlcjk5ODUyODQ=","avatar_url":"https://avatars0.githubusercontent.com/u/9985284?v=4","gravatar_id":"","url":"https://api.github.com/users/tkp1n","html_url":"https://github.com/tkp1n","followers_url":"https://api.github.com/users/tkp1n/followers","following_url":"https://api.github.com/users/tkp1n/following{/other_user}","gists_url":"https://api.github.com/users/tkp1n/gists{/gist_id}","starred_url":"https://api.github.com/users/tkp1n/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkp1n/subscriptions","organizations_url":"https://api.github.com/users/tkp1n/orgs","repos_url":"https://api.github.com/users/tkp1n/repos","events_url":"https://api.github.com/users/tkp1n/events{/privacy}","received_events_url":"https://api.github.com/users/tkp1n/received_events","type":"User","site_admin":false},"body":"Some benchmarks for `Utf8JsonParser` to help investigate https://github.com/dotnet/corefx/issues/33294. Hope this is helpful.\r\n\r\n/cc @ahsonkhan\r\n","created_at":"2018-12-10T22:03:07Z","updated_at":"2018-12-11T23:14:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c6a574727c08c54ed673fff4adf6f885aac1cbdc","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/performance/pulls/185/commits","review_comments_url":"https://api.github.com/repos/dotnet/performance/pulls/185/comments","review_comment_url":"https://api.github.com/repos/dotnet/performance/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/performance/issues/185/comments","statuses_url":"https://api.github.com/repos/dotnet/performance/statuses/1305aab64c14a54deace1c82e995a5a5e1598229","head":{"label":"tkp1n:jsonNumbers","ref":"jsonNumbers","sha":"1305aab64c14a54deace1c82e995a5a5e1598229","user":{"login":"tkp1n","id":9985284,"node_id":"MDQ6VXNlcjk5ODUyODQ=","avatar_url":"https://avatars0.githubusercontent.com/u/9985284?v=4","gravatar_id":"","url":"https://api.github.com/users/tkp1n","html_url":"https://github.com/tkp1n","followers_url":"https://api.github.com/users/tkp1n/followers","following_url":"https://api.github.com/users/tkp1n/following{/other_user}","gists_url":"https://api.github.com/users/tkp1n/gists{/gist_id}","starred_url":"https://api.github.com/users/tkp1n/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkp1n/subscriptions","organizations_url":"https://api.github.com/users/tkp1n/orgs","repos_url":"https://api.github.com/users/tkp1n/repos","events_url":"https://api.github.com/users/tkp1n/events{/privacy}","received_events_url":"https://api.github.com/users/tkp1n/received_events","type":"User","site_admin":false},"repo":{"id":161240231,"node_id":"MDEwOlJlcG9zaXRvcnkxNjEyNDAyMzE=","name":"performance","full_name":"tkp1n/performance","private":false,"owner":{"login":"tkp1n","id":9985284,"node_id":"MDQ6VXNlcjk5ODUyODQ=","avatar_url":"https://avatars0.githubusercontent.com/u/9985284?v=4","gravatar_id":"","url":"https://api.github.com/users/tkp1n","html_url":"https://github.com/tkp1n","followers_url":"https://api.github.com/users/tkp1n/followers","following_url":"https://api.github.com/users/tkp1n/following{/other_user}","gists_url":"https://api.github.com/users/tkp1n/gists{/gist_id}","starred_url":"https://api.github.com/users/tkp1n/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkp1n/subscriptions","organizations_url":"https://api.github.com/users/tkp1n/orgs","repos_url":"https://api.github.com/users/tkp1n/repos","events_url":"https://api.github.com/users/tkp1n/events{/privacy}","received_events_url":"https://api.github.com/users/tkp1n/received_events","type":"User","site_admin":false},"html_url":"https://github.com/tkp1n/performance","description":"This repo contains benchmarks used for testing the performance of .NET Frameworks.","fork":true,"url":"https://api.github.com/repos/tkp1n/performance","forks_url":"https://api.github.com/repos/tkp1n/performance/forks","keys_url":"https://api.github.com/repos/tkp1n/performance/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tkp1n/performance/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tkp1n/performance/teams","hooks_url":"https://api.github.com/repos/tkp1n/performance/hooks","issue_events_url":"https://api.github.com/repos/tkp1n/performance/issues/events{/number}","events_url":"https://api.github.com/repos/tkp1n/performance/events","assignees_url":"https://api.github.com/repos/tkp1n/performance/assignees{/user}","branches_url":"https://api.github.com/repos/tkp1n/performance/branches{/branch}","tags_url":"https://api.github.com/repos/tkp1n/performance/tags","blobs_url":"https://api.github.com/repos/tkp1n/performance/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tkp1n/performance/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tkp1n/performance/git/refs{/sha}","trees_url":"https://api.github.com/repos/tkp1n/performance/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tkp1n/performance/statuses/{sha}","languages_url":"https://api.github.com/repos/tkp1n/performance/languages","stargazers_url":"https://api.github.com/repos/tkp1n/performance/stargazers","contributors_url":"https://api.github.com/repos/tkp1n/performance/contributors","subscribers_url":"https://api.github.com/repos/tkp1n/performance/subscribers","subscription_url":"https://api.github.com/repos/tkp1n/performance/subscription","commits_url":"https://api.github.com/repos/tkp1n/performance/commits{/sha}","git_commits_url":"https://api.github.com/repos/tkp1n/performance/git/commits{/sha}","comments_url":"https://api.github.com/repos/tkp1n/performance/comments{/number}","issue_comment_url":"https://api.github.com/repos/tkp1n/performance/issues/comments{/number}","contents_url":"https://api.github.com/repos/tkp1n/performance/contents/{+path}","compare_url":"https://api.github.com/repos/tkp1n/performance/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tkp1n/performance/merges","archive_url":"https://api.github.com/repos/tkp1n/performance/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tkp1n/performance/downloads","issues_url":"https://api.github.com/repos/tkp1n/performance/issues{/number}","pulls_url":"https://api.github.com/repos/tkp1n/performance/pulls{/number}","milestones_url":"https://api.github.com/repos/tkp1n/performance/milestones{/number}","notifications_url":"https://api.github.com/repos/tkp1n/performance/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tkp1n/performance/labels{/name}","releases_url":"https://api.github.com/repos/tkp1n/performance/releases{/id}","deployments_url":"https://api.github.com/repos/tkp1n/performance/deployments","created_at":"2018-12-10T21:43:43Z","updated_at":"2018-12-10T21:43:47Z","pushed_at":"2018-12-10T22:53:16Z","git_url":"git://github.com/tkp1n/performance.git","ssh_url":"git@github.com:tkp1n/performance.git","clone_url":"https://github.com/tkp1n/performance.git","svn_url":"https://github.com/tkp1n/performance","homepage":"","size":1893,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"fe3079f6bd79cbc2df0e72fda6baa6096f0b2fb2","user":{"login":"dotnet","id":9141961,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkxNDE5NjE=","avatar_url":"https://avatars0.githubusercontent.com/u/9141961?v=4","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":124948838,"node_id":"MDEwOlJlcG9zaXRvcnkxMjQ5NDg4Mzg=","name":"performance","full_name":"dotnet/performance","private":false,"owner":{"login":"dotnet","id":9141961,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkxNDE5NjE=","avatar_url":"https://avatars0.githubusercontent.com/u/9141961?v=4","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/dotnet/performance","description":"This repo contains benchmarks used for testing the performance of .NET Frameworks.","fork":false,"url":"https://api.github.com/repos/dotnet/performance","forks_url":"https://api.github.com/repos/dotnet/performance/forks","keys_url":"https://api.github.com/repos/dotnet/performance/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/performance/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/performance/teams","hooks_url":"https://api.github.com/repos/dotnet/performance/hooks","issue_events_url":"https://api.github.com/repos/dotnet/performance/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/performance/events","assignees_url":"https://api.github.com/repos/dotnet/performance/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/performance/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/performance/tags","blobs_url":"https://api.github.com/repos/dotnet/performance/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/performance/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/performance/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/performance/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/performance/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/performance/languages","stargazers_url":"https://api.github.com/repos/dotnet/performance/stargazers","contributors_url":"https://api.github.com/repos/dotnet/performance/contributors","subscribers_url":"https://api.github.com/repos/dotnet/performance/subscribers","subscription_url":"https://api.github.com/repos/dotnet/performance/subscription","commits_url":"https://api.github.com/repos/dotnet/performance/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/performance/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/performance/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/performance/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/performance/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/performance/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/performance/merges","archive_url":"https://api.github.com/repos/dotnet/performance/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/performance/downloads","issues_url":"https://api.github.com/repos/dotnet/performance/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/performance/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/performance/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/performance/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/performance/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/performance/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/performance/deployments","created_at":"2018-03-12T20:41:10Z","updated_at":"2018-12-11T10:06:29Z","pushed_at":"2018-12-11T22:45:18Z","git_url":"git://github.com/dotnet/performance.git","ssh_url":"git@github.com:dotnet/performance.git","clone_url":"https://github.com/dotnet/performance.git","svn_url":"https://github.com/dotnet/performance","homepage":"","size":1906,"stargazers_count":56,"watchers_count":56,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"archived":false,"open_issues_count":17,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":16,"open_issues":17,"watchers":56,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/performance/pulls/185"},"html":{"href":"https://github.com/dotnet/performance/pull/185"},"issue":{"href":"https://api.github.com/repos/dotnet/performance/issues/185"},"comments":{"href":"https://api.github.com/repos/dotnet/performance/issues/185/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/performance/pulls/185/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/performance/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/performance/pulls/185/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/performance/statuses/1305aab64c14a54deace1c82e995a5a5e1598229"}},"author_association":"NONE"}}
{"actor":{"display_login":"ahsonkhan"}}