{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/comments/36871688","id":36871688,"diff_hunk":"@@ -0,0 +1,198 @@\n+﻿using System;\n+using System.Diagnostics;\n+using Xunit;\n+using Xunit.Abstractions;\n+\n+namespace System.Numerics.Tests\n+{\n+    public class PerformanceTests\n+    {\n+        private readonly Random _random;\n+        private readonly ITestOutputHelper _output;\n+\n+        public PerformanceTests(ITestOutputHelper output)\n+        {\n+            _random = new Random(1138);\n+            _output = output;\n+        }\n+\n+        [Theory]\n+        [ActiveIssue(\"PerformanceTest\")]\n+        [InlineData(1000000, 16, 16)]\n+        [InlineData(1000000, 64, 64)]\n+        [InlineData(1000000, 256, 256)]\n+        [InlineData(1000000, 1024, 1024)]\n+        [InlineData(100000, 4096, 4096)]\n+        [InlineData(100000, 16384, 16384)]\n+        [InlineData(100000, 65536, 65536)]\n+        public void Add(int count, int leftBits, int rightBits)\n+        {\n+            RunBenchmark(count, leftBits, rightBits, (l, r) => BigInteger.Add(l, r));\n+        }\n+\n+        [Theory]\n+        [ActiveIssue(\"PerformanceTest\")]\n+        [InlineData(1000000, 16, 16)]\n+        [InlineData(1000000, 64, 64)]\n+        [InlineData(1000000, 256, 256)]\n+        [InlineData(1000000, 1024, 1024)]\n+        [InlineData(100000, 4096, 4096)]\n+        [InlineData(100000, 16384, 16384)]\n+        [InlineData(100000, 65536, 65536)]\n+        public void Subtract(int count, int leftBits, int rightBits)\n+        {\n+            RunBenchmark(count, leftBits, rightBits, (l, r) => BigInteger.Subtract(l, r));\n+        }\n+\n+        [Theory]\n+        [ActiveIssue(\"PerformanceTest\")]\n+        [InlineData(1000000, 16, 16)]\n+        [InlineData(1000000, 64, 64)]\n+        [InlineData(1000000, 256, 256)]\n+        [InlineData(100000, 1024, 1024)]\n+        [InlineData(10000, 4096, 4096)]\n+        [InlineData(1000, 16384, 16384)]\n+        [InlineData(100, 65536, 65536)]\n+        public void Multiply(int count, int leftBits, int rightBits)\n+        {\n+            RunBenchmark(count, leftBits, rightBits, (l, r) => BigInteger.Multiply(l, r));\n+        }\n+\n+        [Theory]\n+        [ActiveIssue(\"PerformanceTest\")]\n+        [InlineData(1000000, 16)]\n+        [InlineData(1000000, 64)]\n+        [InlineData(1000000, 256)]\n+        [InlineData(100000, 1024)]\n+        [InlineData(10000, 4096)]\n+        [InlineData(1000, 16384)]\n+        [InlineData(100, 65536)]\n+        public void Square(int count, int bits)\n+        {\n+            RunBenchmark(count, bits, v => BigInteger.Multiply(v, v));\n+        }\n+\n+        [Theory]\n+        [ActiveIssue(\"PerformanceTest\")]\n+        [InlineData(1000000, 16, 16)]\n+        [InlineData(1000000, 64, 16)]\n+        [InlineData(1000000, 256, 128)]\n+        [InlineData(100000, 1024, 512)]\n+        [InlineData(10000, 4096, 2048)]\n+        [InlineData(1000, 16384, 8192)]\n+        [InlineData(100, 65536, 32768)]\n+        public void Divide(int count, int leftBits, int rightBits)\n+        {\n+            RunBenchmark(count, leftBits, rightBits, (l, r) => BigInteger.Divide(l, r));\n+        }\n+\n+        [Theory]\n+        [ActiveIssue(\"PerformanceTest\")]\n+        [InlineData(1000000, 16, 16)]\n+        [InlineData(1000000, 64, 16)]\n+        [InlineData(1000000, 256, 128)]\n+        [InlineData(100000, 1024, 512)]\n+        [InlineData(10000, 4096, 2048)]\n+        [InlineData(1000, 16384, 8192)]\n+        [InlineData(100, 65536, 32768)]\n+        public void Remainder(int count, int leftBits, int rightBits)\n+        {\n+            RunBenchmark(count, leftBits, rightBits, (l, r) => BigInteger.Remainder(l, r));\n+        }\n+\n+        [Theory]\n+        [ActiveIssue(\"PerformanceTest\")]\n+        [InlineData(100000, 16, 16, 16)]\n+        [InlineData(10000, 64, 64, 64)]\n+        [InlineData(1000, 256, 256, 256)]\n+        [InlineData(100, 1024, 1024, 1024)]\n+        [InlineData(10, 4096, 4096, 4096)]\n+        [InlineData(1, 16384, 16384, 16384)]\n+        public void ModPow(int count, int leftBits, int rightBits, int otherBits)\n+        {\n+            RunBenchmark(count, leftBits, rightBits, otherBits, (l, r, o) => BigInteger.ModPow(l, r, o));\n+        }\n+\n+        private void RunBenchmark(int count, int bits, Action<BigInteger> operation)\n+        {\n+            BigInteger[] value = CreateIntegerSeed(count, bits);\n+\n+            long result = RunBenchmark(count, i => operation(value[i]));\n+\n+            _output.WriteLine(\"({1:N0}) : {2:N0} ms / {0:N0} ops\", count, bits, result);\n+        }\n+\n+        private void RunBenchmark(int count, int leftBits, int rightBits, Action<BigInteger, BigInteger> operation)\n+        {\n+            BigInteger[] left = CreateIntegerSeed(count, leftBits);\n+            BigInteger[] right = CreateIntegerSeed(count, rightBits);\n+\n+            long result = RunBenchmark(count, i => operation(left[i], right[i]));\n+\n+            _output.WriteLine(\"({1:N0}, {2:N0}) : {3:N0} ms / {0:N0} ops\", count, leftBits, rightBits, result);\n+        }\n+\n+        private void RunBenchmark(int count, int leftBits, int rightBits, int otherBits, Action<BigInteger, BigInteger, BigInteger> operation)\n+        {\n+            BigInteger[] left = CreateIntegerSeed(count, leftBits);\n+            BigInteger[] right = CreateIntegerSeed(count, rightBits);\n+            BigInteger[] other = CreateIntegerSeed(count, otherBits);\n+\n+            long result = RunBenchmark(count, i => operation(left[i], right[i], other[i]));\n+\n+            _output.WriteLine(\"({1:N0}, {2:N0}, {3:N0}) : {4:N0} ms / {0:N0} ops\", count, leftBits, rightBits, otherBits, result);\n+        }\n+\n+        private const int MAX_SEED = 10;\n+        private const int RUN_COUNT = 3;\n+\n+        private long RunBenchmark(int count, Action<int> operation)\n+        {\n+            operation(0);\n+\n+            long result = long.MaxValue;\n+            for (int j = 0; j < RUN_COUNT; j++)\n+            {\n+                Stopwatch watch = new Stopwatch();","path":"src/System.Runtime.Numerics/tests/BigInteger/PerformanceTests.cs","position":156,"original_position":156,"commit_id":"024f38b89629912edf2a711758d1f450392bf1e4","original_commit_id":"024f38b89629912edf2a711758d1f450392bf1e4","user":{"login":"axelheer","id":3988385,"avatar_url":"https://avatars.githubusercontent.com/u/3988385?v=3","gravatar_id":"","url":"https://api.github.com/users/axelheer","html_url":"https://github.com/axelheer","followers_url":"https://api.github.com/users/axelheer/followers","following_url":"https://api.github.com/users/axelheer/following{/other_user}","gists_url":"https://api.github.com/users/axelheer/gists{/gist_id}","starred_url":"https://api.github.com/users/axelheer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axelheer/subscriptions","organizations_url":"https://api.github.com/users/axelheer/orgs","repos_url":"https://api.github.com/users/axelheer/repos","events_url":"https://api.github.com/users/axelheer/events{/privacy}","received_events_url":"https://api.github.com/users/axelheer/received_events","type":"User","site_admin":false},"body":"Ah, I'll amend that.","created_at":"2015-08-12T15:13:58Z","updated_at":"2015-08-12T15:13:58Z","html_url":"https://github.com/dotnet/corefx/pull/2749#discussion_r36871688","pull_request_url":"https://api.github.com/repos/dotnet/corefx/pulls/2749","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments/36871688"},"html":{"href":"https://github.com/dotnet/corefx/pull/2749#discussion_r36871688"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/2749"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/2749","id":42207828,"html_url":"https://github.com/dotnet/corefx/pull/2749","diff_url":"https://github.com/dotnet/corefx/pull/2749.diff","patch_url":"https://github.com/dotnet/corefx/pull/2749.patch","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/2749","number":2749,"state":"open","locked":false,"title":"Add performance tests for BigInteger","user":{"login":"axelheer","id":3988385,"avatar_url":"https://avatars.githubusercontent.com/u/3988385?v=3","gravatar_id":"","url":"https://api.github.com/users/axelheer","html_url":"https://github.com/axelheer","followers_url":"https://api.github.com/users/axelheer/followers","following_url":"https://api.github.com/users/axelheer/following{/other_user}","gists_url":"https://api.github.com/users/axelheer/gists{/gist_id}","starred_url":"https://api.github.com/users/axelheer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axelheer/subscriptions","organizations_url":"https://api.github.com/users/axelheer/orgs","repos_url":"https://api.github.com/users/axelheer/repos","events_url":"https://api.github.com/users/axelheer/events{/privacy}","received_events_url":"https://api.github.com/users/axelheer/received_events","type":"User","site_admin":false},"body":"These unit tests should help measuring performance, until we have some kind of real performance-measurement system in place.\r\n\r\n#1307\r\n","created_at":"2015-08-12T06:23:04Z","updated_at":"2015-08-12T15:13:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6e6445acde298c3c33cf46aa856c13d4b482748e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/corefx/pulls/2749/commits","review_comments_url":"https://api.github.com/repos/dotnet/corefx/pulls/2749/comments","review_comment_url":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/2749/comments","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/024f38b89629912edf2a711758d1f450392bf1e4","head":{"label":"axelheer:biginteger-benchmark","ref":"biginteger-benchmark","sha":"024f38b89629912edf2a711758d1f450392bf1e4","user":{"login":"axelheer","id":3988385,"avatar_url":"https://avatars.githubusercontent.com/u/3988385?v=3","gravatar_id":"","url":"https://api.github.com/users/axelheer","html_url":"https://github.com/axelheer","followers_url":"https://api.github.com/users/axelheer/followers","following_url":"https://api.github.com/users/axelheer/following{/other_user}","gists_url":"https://api.github.com/users/axelheer/gists{/gist_id}","starred_url":"https://api.github.com/users/axelheer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axelheer/subscriptions","organizations_url":"https://api.github.com/users/axelheer/orgs","repos_url":"https://api.github.com/users/axelheer/repos","events_url":"https://api.github.com/users/axelheer/events{/privacy}","received_events_url":"https://api.github.com/users/axelheer/received_events","type":"User","site_admin":false},"repo":{"id":34116891,"name":"corefx","full_name":"axelheer/corefx","owner":{"login":"axelheer","id":3988385,"avatar_url":"https://avatars.githubusercontent.com/u/3988385?v=3","gravatar_id":"","url":"https://api.github.com/users/axelheer","html_url":"https://github.com/axelheer","followers_url":"https://api.github.com/users/axelheer/followers","following_url":"https://api.github.com/users/axelheer/following{/other_user}","gists_url":"https://api.github.com/users/axelheer/gists{/gist_id}","starred_url":"https://api.github.com/users/axelheer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axelheer/subscriptions","organizations_url":"https://api.github.com/users/axelheer/orgs","repos_url":"https://api.github.com/users/axelheer/repos","events_url":"https://api.github.com/users/axelheer/events{/privacy}","received_events_url":"https://api.github.com/users/axelheer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/axelheer/corefx","description":"This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others.","fork":true,"url":"https://api.github.com/repos/axelheer/corefx","forks_url":"https://api.github.com/repos/axelheer/corefx/forks","keys_url":"https://api.github.com/repos/axelheer/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/axelheer/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/axelheer/corefx/teams","hooks_url":"https://api.github.com/repos/axelheer/corefx/hooks","issue_events_url":"https://api.github.com/repos/axelheer/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/axelheer/corefx/events","assignees_url":"https://api.github.com/repos/axelheer/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/axelheer/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/axelheer/corefx/tags","blobs_url":"https://api.github.com/repos/axelheer/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/axelheer/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/axelheer/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/axelheer/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/axelheer/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/axelheer/corefx/languages","stargazers_url":"https://api.github.com/repos/axelheer/corefx/stargazers","contributors_url":"https://api.github.com/repos/axelheer/corefx/contributors","subscribers_url":"https://api.github.com/repos/axelheer/corefx/subscribers","subscription_url":"https://api.github.com/repos/axelheer/corefx/subscription","commits_url":"https://api.github.com/repos/axelheer/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/axelheer/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/axelheer/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/axelheer/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/axelheer/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/axelheer/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/axelheer/corefx/merges","archive_url":"https://api.github.com/repos/axelheer/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/axelheer/corefx/downloads","issues_url":"https://api.github.com/repos/axelheer/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/axelheer/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/axelheer/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/axelheer/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/axelheer/corefx/labels{/name}","releases_url":"https://api.github.com/repos/axelheer/corefx/releases{/id}","created_at":"2015-04-17T13:03:03Z","updated_at":"2015-04-30T09:05:49Z","pushed_at":"2015-08-12T06:20:16Z","git_url":"git://github.com/axelheer/corefx.git","ssh_url":"git@github.com:axelheer/corefx.git","clone_url":"https://github.com/axelheer/corefx.git","svn_url":"https://github.com/axelheer/corefx","homepage":"","size":26372,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"0c677d5b22514f41119ec7de4ac403a42f04e914","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","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":26295345,"name":"corefx","full_name":"dotnet/corefx","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","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},"private":false,"html_url":"https://github.com/dotnet/corefx","description":"This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others.","fork":false,"url":"https://api.github.com/repos/dotnet/corefx","forks_url":"https://api.github.com/repos/dotnet/corefx/forks","keys_url":"https://api.github.com/repos/dotnet/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/corefx/teams","hooks_url":"https://api.github.com/repos/dotnet/corefx/hooks","issue_events_url":"https://api.github.com/repos/dotnet/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/corefx/events","assignees_url":"https://api.github.com/repos/dotnet/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/corefx/tags","blobs_url":"https://api.github.com/repos/dotnet/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/corefx/languages","stargazers_url":"https://api.github.com/repos/dotnet/corefx/stargazers","contributors_url":"https://api.github.com/repos/dotnet/corefx/contributors","subscribers_url":"https://api.github.com/repos/dotnet/corefx/subscribers","subscription_url":"https://api.github.com/repos/dotnet/corefx/subscription","commits_url":"https://api.github.com/repos/dotnet/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/corefx/merges","archive_url":"https://api.github.com/repos/dotnet/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/corefx/downloads","issues_url":"https://api.github.com/repos/dotnet/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/corefx/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/corefx/releases{/id}","created_at":"2014-11-06T23:42:48Z","updated_at":"2015-08-12T13:00:46Z","pushed_at":"2015-08-12T14:58:25Z","git_url":"git://github.com/dotnet/corefx.git","ssh_url":"git@github.com:dotnet/corefx.git","clone_url":"https://github.com/dotnet/corefx.git","svn_url":"https://github.com/dotnet/corefx","homepage":"http://dotnet.github.io/core/","size":57974,"stargazers_count":8198,"watchers_count":8198,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1727,"mirror_url":null,"open_issues_count":533,"forks":1727,"open_issues":533,"watchers":8198,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/2749"},"html":{"href":"https://github.com/dotnet/corefx/pull/2749"},"issue":{"href":"https://api.github.com/repos/dotnet/corefx/issues/2749"},"comments":{"href":"https://api.github.com/repos/dotnet/corefx/issues/2749/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/2749/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/2749/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corefx/statuses/024f38b89629912edf2a711758d1f450392bf1e4"}}}}