{"action":"created","comment":{"url":"https://api.github.com/repos/javaslang/javaslang/pulls/comments/75094363","id":75094363,"diff_hunk":"@@ -0,0 +1,111 @@\n+package javaslang.idiom;\n+\n+import javaslang.JmhRunner;\n+import javaslang.collection.Array;\n+import javaslang.control.Try;\n+import org.junit.Test;\n+import org.openjdk.jmh.annotations.Benchmark;\n+import org.openjdk.jmh.annotations.Scope;\n+import org.openjdk.jmh.annotations.Setup;\n+import org.openjdk.jmh.annotations.State;\n+\n+import java.util.Random;\n+\n+import static javaslang.API.Case;\n+import static javaslang.API.Match;\n+import static javaslang.Predicates.instanceOf;\n+\n+/**\n+ * Benchmark for Try vs try/catch.\n+ */\n+public class TryBenchmark {\n+    static final Array<Class<?>> CLASSES = Array.of(\n+            TryThrowsCatchBenchmark.class,\n+            TryNoThrowsCatchBenchmark.class\n+    );\n+\n+    @Test\n+    public void testAsserts() {\n+        JmhRunner.runDebugWithAsserts(CLASSES);\n+    }\n+\n+    public static void main(String... args) {\n+        JmhRunner.runNormalNoAsserts(CLASSES);\n+    }\n+\n+\n+    @State(Scope.Benchmark)\n+    public static class Base {\n+\n+        int random;\n+\n+        Integer throwsException() {\n+            if ((random ^ random) == 0) throw new RuntimeException();\n+            return 1;\n+        }\n+\n+        Integer doesntThrow() {\n+            if ((random ^ random) != 0) throw new RuntimeException();\n+            return 0;\n+        }\n+\n+        @Setup\n+        public void setup() {\n+            random = new Random().nextInt();\n+        }\n+    }\n+\n+    public static class TryThrowsCatchBenchmark extends Base {\n+\n+        @Benchmark\n+        public Object javaslang_try_actual_exception() {\n+            Integer res = Try.of(this::throwsException)\n+                    .recover(x -> Match(x).of(Case(instanceOf(RuntimeException.class), () -> 1)))","path":"javaslang-benchmark/src/test/java/javaslang/idiom/TryBenchmark.java","position":63,"original_position":63,"commit_id":"3ad6d8c7adc6f978319b5e3fe19a28c3bbaeb716","original_commit_id":"3ad6d8c7adc6f978319b5e3fe19a28c3bbaeb716","user":{"login":"mping","id":88425,"avatar_url":"https://avatars.githubusercontent.com/u/88425?v=3","gravatar_id":"","url":"https://api.github.com/users/mping","html_url":"https://github.com/mping","followers_url":"https://api.github.com/users/mping/followers","following_url":"https://api.github.com/users/mping/following{/other_user}","gists_url":"https://api.github.com/users/mping/gists{/gist_id}","starred_url":"https://api.github.com/users/mping/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mping/subscriptions","organizations_url":"https://api.github.com/users/mping/orgs","repos_url":"https://api.github.com/users/mping/repos","events_url":"https://api.github.com/users/mping/events{/privacy}","received_events_url":"https://api.github.com/users/mping/received_events","type":"User","site_admin":false},"body":"Since it was merged, I can use it now.","created_at":"2016-08-17T09:57:31Z","updated_at":"2016-08-17T09:57:31Z","html_url":"https://github.com/javaslang/javaslang/pull/1456#discussion_r75094363","pull_request_url":"https://api.github.com/repos/javaslang/javaslang/pulls/1456","_links":{"self":{"href":"https://api.github.com/repos/javaslang/javaslang/pulls/comments/75094363"},"html":{"href":"https://github.com/javaslang/javaslang/pull/1456#discussion_r75094363"},"pull_request":{"href":"https://api.github.com/repos/javaslang/javaslang/pulls/1456"}}},"pull_request":{"url":"https://api.github.com/repos/javaslang/javaslang/pulls/1456","id":78365157,"html_url":"https://github.com/javaslang/javaslang/pull/1456","diff_url":"https://github.com/javaslang/javaslang/pull/1456.diff","patch_url":"https://github.com/javaslang/javaslang/pull/1456.patch","issue_url":"https://api.github.com/repos/javaslang/javaslang/issues/1456","number":1456,"state":"open","locked":false,"title":"Added benchmarks for common java idioms","user":{"login":"mping","id":88425,"avatar_url":"https://avatars.githubusercontent.com/u/88425?v=3","gravatar_id":"","url":"https://api.github.com/users/mping","html_url":"https://github.com/mping","followers_url":"https://api.github.com/users/mping/followers","following_url":"https://api.github.com/users/mping/following{/other_user}","gists_url":"https://api.github.com/users/mping/gists{/gist_id}","starred_url":"https://api.github.com/users/mping/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mping/subscriptions","organizations_url":"https://api.github.com/users/mping/orgs","repos_url":"https://api.github.com/users/mping/repos","events_url":"https://api.github.com/users/mping/events{/privacy}","received_events_url":"https://api.github.com/users/mping/received_events","type":"User","site_admin":false},"body":"Hopefully will have the following benchmarks:\r\n- For comprehension\r\n- Tuple vs Pair class?\r\n- Try\r\n- Pattern Matching","created_at":"2016-07-21T18:33:43Z","updated_at":"2016-08-17T09:57:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cfa7c2154133ae9fbe9b073d1f02836a1894c9ab","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/javaslang/javaslang/pulls/1456/commits","review_comments_url":"https://api.github.com/repos/javaslang/javaslang/pulls/1456/comments","review_comment_url":"https://api.github.com/repos/javaslang/javaslang/pulls/comments{/number}","comments_url":"https://api.github.com/repos/javaslang/javaslang/issues/1456/comments","statuses_url":"https://api.github.com/repos/javaslang/javaslang/statuses/3ad6d8c7adc6f978319b5e3fe19a28c3bbaeb716","head":{"label":"mping:idioms-benchmark","ref":"idioms-benchmark","sha":"3ad6d8c7adc6f978319b5e3fe19a28c3bbaeb716","user":{"login":"mping","id":88425,"avatar_url":"https://avatars.githubusercontent.com/u/88425?v=3","gravatar_id":"","url":"https://api.github.com/users/mping","html_url":"https://github.com/mping","followers_url":"https://api.github.com/users/mping/followers","following_url":"https://api.github.com/users/mping/following{/other_user}","gists_url":"https://api.github.com/users/mping/gists{/gist_id}","starred_url":"https://api.github.com/users/mping/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mping/subscriptions","organizations_url":"https://api.github.com/users/mping/orgs","repos_url":"https://api.github.com/users/mping/repos","events_url":"https://api.github.com/users/mping/events{/privacy}","received_events_url":"https://api.github.com/users/mping/received_events","type":"User","site_admin":false},"repo":{"id":52986097,"name":"javaslang","full_name":"mping/javaslang","owner":{"login":"mping","id":88425,"avatar_url":"https://avatars.githubusercontent.com/u/88425?v=3","gravatar_id":"","url":"https://api.github.com/users/mping","html_url":"https://github.com/mping","followers_url":"https://api.github.com/users/mping/followers","following_url":"https://api.github.com/users/mping/following{/other_user}","gists_url":"https://api.github.com/users/mping/gists{/gist_id}","starred_url":"https://api.github.com/users/mping/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mping/subscriptions","organizations_url":"https://api.github.com/users/mping/orgs","repos_url":"https://api.github.com/users/mping/repos","events_url":"https://api.github.com/users/mping/events{/privacy}","received_events_url":"https://api.github.com/users/mping/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mping/javaslang","description":"A functional library for Java 8+ that provides persistent data types and functional control structures.","fork":true,"url":"https://api.github.com/repos/mping/javaslang","forks_url":"https://api.github.com/repos/mping/javaslang/forks","keys_url":"https://api.github.com/repos/mping/javaslang/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mping/javaslang/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mping/javaslang/teams","hooks_url":"https://api.github.com/repos/mping/javaslang/hooks","issue_events_url":"https://api.github.com/repos/mping/javaslang/issues/events{/number}","events_url":"https://api.github.com/repos/mping/javaslang/events","assignees_url":"https://api.github.com/repos/mping/javaslang/assignees{/user}","branches_url":"https://api.github.com/repos/mping/javaslang/branches{/branch}","tags_url":"https://api.github.com/repos/mping/javaslang/tags","blobs_url":"https://api.github.com/repos/mping/javaslang/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mping/javaslang/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mping/javaslang/git/refs{/sha}","trees_url":"https://api.github.com/repos/mping/javaslang/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mping/javaslang/statuses/{sha}","languages_url":"https://api.github.com/repos/mping/javaslang/languages","stargazers_url":"https://api.github.com/repos/mping/javaslang/stargazers","contributors_url":"https://api.github.com/repos/mping/javaslang/contributors","subscribers_url":"https://api.github.com/repos/mping/javaslang/subscribers","subscription_url":"https://api.github.com/repos/mping/javaslang/subscription","commits_url":"https://api.github.com/repos/mping/javaslang/commits{/sha}","git_commits_url":"https://api.github.com/repos/mping/javaslang/git/commits{/sha}","comments_url":"https://api.github.com/repos/mping/javaslang/comments{/number}","issue_comment_url":"https://api.github.com/repos/mping/javaslang/issues/comments{/number}","contents_url":"https://api.github.com/repos/mping/javaslang/contents/{+path}","compare_url":"https://api.github.com/repos/mping/javaslang/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mping/javaslang/merges","archive_url":"https://api.github.com/repos/mping/javaslang/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mping/javaslang/downloads","issues_url":"https://api.github.com/repos/mping/javaslang/issues{/number}","pulls_url":"https://api.github.com/repos/mping/javaslang/pulls{/number}","milestones_url":"https://api.github.com/repos/mping/javaslang/milestones{/number}","notifications_url":"https://api.github.com/repos/mping/javaslang/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mping/javaslang/labels{/name}","releases_url":"https://api.github.com/repos/mping/javaslang/releases{/id}","deployments_url":"https://api.github.com/repos/mping/javaslang/deployments","created_at":"2016-03-02T18:26:39Z","updated_at":"2016-03-02T18:26:40Z","pushed_at":"2016-08-02T21:32:42Z","git_url":"git://github.com/mping/javaslang.git","ssh_url":"git@github.com:mping/javaslang.git","clone_url":"https://github.com/mping/javaslang.git","svn_url":"https://github.com/mping/javaslang","homepage":"http://javaslang.io","size":12271,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"javaslang:master","ref":"master","sha":"80cdd21e7610aa8bcd684c1d64e7a93e0cbc9cec","user":{"login":"javaslang","id":5786132,"avatar_url":"https://avatars.githubusercontent.com/u/5786132?v=3","gravatar_id":"","url":"https://api.github.com/users/javaslang","html_url":"https://github.com/javaslang","followers_url":"https://api.github.com/users/javaslang/followers","following_url":"https://api.github.com/users/javaslang/following{/other_user}","gists_url":"https://api.github.com/users/javaslang/gists{/gist_id}","starred_url":"https://api.github.com/users/javaslang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javaslang/subscriptions","organizations_url":"https://api.github.com/users/javaslang/orgs","repos_url":"https://api.github.com/users/javaslang/repos","events_url":"https://api.github.com/users/javaslang/events{/privacy}","received_events_url":"https://api.github.com/users/javaslang/received_events","type":"Organization","site_admin":false},"repo":{"id":16378879,"name":"javaslang","full_name":"javaslang/javaslang","owner":{"login":"javaslang","id":5786132,"avatar_url":"https://avatars.githubusercontent.com/u/5786132?v=3","gravatar_id":"","url":"https://api.github.com/users/javaslang","html_url":"https://github.com/javaslang","followers_url":"https://api.github.com/users/javaslang/followers","following_url":"https://api.github.com/users/javaslang/following{/other_user}","gists_url":"https://api.github.com/users/javaslang/gists{/gist_id}","starred_url":"https://api.github.com/users/javaslang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javaslang/subscriptions","organizations_url":"https://api.github.com/users/javaslang/orgs","repos_url":"https://api.github.com/users/javaslang/repos","events_url":"https://api.github.com/users/javaslang/events{/privacy}","received_events_url":"https://api.github.com/users/javaslang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/javaslang/javaslang","description":"A functional library for Java 8+ that provides persistent data types and functional control structures.","fork":false,"url":"https://api.github.com/repos/javaslang/javaslang","forks_url":"https://api.github.com/repos/javaslang/javaslang/forks","keys_url":"https://api.github.com/repos/javaslang/javaslang/keys{/key_id}","collaborators_url":"https://api.github.com/repos/javaslang/javaslang/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/javaslang/javaslang/teams","hooks_url":"https://api.github.com/repos/javaslang/javaslang/hooks","issue_events_url":"https://api.github.com/repos/javaslang/javaslang/issues/events{/number}","events_url":"https://api.github.com/repos/javaslang/javaslang/events","assignees_url":"https://api.github.com/repos/javaslang/javaslang/assignees{/user}","branches_url":"https://api.github.com/repos/javaslang/javaslang/branches{/branch}","tags_url":"https://api.github.com/repos/javaslang/javaslang/tags","blobs_url":"https://api.github.com/repos/javaslang/javaslang/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/javaslang/javaslang/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/javaslang/javaslang/git/refs{/sha}","trees_url":"https://api.github.com/repos/javaslang/javaslang/git/trees{/sha}","statuses_url":"https://api.github.com/repos/javaslang/javaslang/statuses/{sha}","languages_url":"https://api.github.com/repos/javaslang/javaslang/languages","stargazers_url":"https://api.github.com/repos/javaslang/javaslang/stargazers","contributors_url":"https://api.github.com/repos/javaslang/javaslang/contributors","subscribers_url":"https://api.github.com/repos/javaslang/javaslang/subscribers","subscription_url":"https://api.github.com/repos/javaslang/javaslang/subscription","commits_url":"https://api.github.com/repos/javaslang/javaslang/commits{/sha}","git_commits_url":"https://api.github.com/repos/javaslang/javaslang/git/commits{/sha}","comments_url":"https://api.github.com/repos/javaslang/javaslang/comments{/number}","issue_comment_url":"https://api.github.com/repos/javaslang/javaslang/issues/comments{/number}","contents_url":"https://api.github.com/repos/javaslang/javaslang/contents/{+path}","compare_url":"https://api.github.com/repos/javaslang/javaslang/compare/{base}...{head}","merges_url":"https://api.github.com/repos/javaslang/javaslang/merges","archive_url":"https://api.github.com/repos/javaslang/javaslang/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/javaslang/javaslang/downloads","issues_url":"https://api.github.com/repos/javaslang/javaslang/issues{/number}","pulls_url":"https://api.github.com/repos/javaslang/javaslang/pulls{/number}","milestones_url":"https://api.github.com/repos/javaslang/javaslang/milestones{/number}","notifications_url":"https://api.github.com/repos/javaslang/javaslang/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/javaslang/javaslang/labels{/name}","releases_url":"https://api.github.com/repos/javaslang/javaslang/releases{/id}","deployments_url":"https://api.github.com/repos/javaslang/javaslang/deployments","created_at":"2014-01-30T14:07:25Z","updated_at":"2016-08-17T06:05:01Z","pushed_at":"2016-08-17T09:55:37Z","git_url":"git://github.com/javaslang/javaslang.git","ssh_url":"git@github.com:javaslang/javaslang.git","clone_url":"https://github.com/javaslang/javaslang.git","svn_url":"https://github.com/javaslang/javaslang","homepage":"http://javaslang.io","size":14008,"stargazers_count":1092,"watchers_count":1092,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":125,"mirror_url":null,"open_issues_count":112,"forks":125,"open_issues":112,"watchers":1092,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/javaslang/javaslang/pulls/1456"},"html":{"href":"https://github.com/javaslang/javaslang/pull/1456"},"issue":{"href":"https://api.github.com/repos/javaslang/javaslang/issues/1456"},"comments":{"href":"https://api.github.com/repos/javaslang/javaslang/issues/1456/comments"},"review_comments":{"href":"https://api.github.com/repos/javaslang/javaslang/pulls/1456/comments"},"review_comment":{"href":"https://api.github.com/repos/javaslang/javaslang/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/javaslang/javaslang/pulls/1456/commits"},"statuses":{"href":"https://api.github.com/repos/javaslang/javaslang/statuses/3ad6d8c7adc6f978319b5e3fe19a28c3bbaeb716"}}}}
{"actor":{"display_login":"mping"}}