{"action":"created","comment":{"url":"https://api.github.com/repos/erikvanoosten/metrics-scala/pulls/comments/235934142","pull_request_review_id":177918056,"id":235934142,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNTkzNDE0Mg==","diff_hunk":"@@ -82,7 +82,8 @@ class MetricName private (val name: String) {\n \n     val sb = new StringBuilder(name)\n     names.view\n-      .filterNot(StringUtils.isEmpty)\n+      .filter(_ != null)\n+      .filter(_.nonEmpty)","path":"metrics-scala/src/main/scala/nl/grons/metrics4/scala/MetricName.scala","position":68,"original_position":6,"commit_id":"f94b152d97522bc636dd8fa54208bc53c8e9280d","original_commit_id":"f94b152d97522bc636dd8fa54208bc53c8e9280d","user":{"login":"erikvanoosten","id":630600,"node_id":"MDQ6VXNlcjYzMDYwMA==","avatar_url":"https://avatars3.githubusercontent.com/u/630600?v=4","gravatar_id":"","url":"https://api.github.com/users/erikvanoosten","html_url":"https://github.com/erikvanoosten","followers_url":"https://api.github.com/users/erikvanoosten/followers","following_url":"https://api.github.com/users/erikvanoosten/following{/other_user}","gists_url":"https://api.github.com/users/erikvanoosten/gists{/gist_id}","starred_url":"https://api.github.com/users/erikvanoosten/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erikvanoosten/subscriptions","organizations_url":"https://api.github.com/users/erikvanoosten/orgs","repos_url":"https://api.github.com/users/erikvanoosten/repos","events_url":"https://api.github.com/users/erikvanoosten/events{/privacy}","received_events_url":"https://api.github.com/users/erikvanoosten/received_events","type":"User","site_admin":false},"body":"Its probably faster if we combine these.\r\n\r\n```scala\r\n .filter(n => n != null && n.nonEmpty)\r\n```","created_at":"2018-11-23T13:01:08Z","updated_at":"2018-11-23T13:01:08Z","html_url":"https://github.com/erikvanoosten/metrics-scala/pull/117#discussion_r235934142","pull_request_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/pulls/117","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/erikvanoosten/metrics-scala/pulls/comments/235934142"},"html":{"href":"https://github.com/erikvanoosten/metrics-scala/pull/117#discussion_r235934142"},"pull_request":{"href":"https://api.github.com/repos/erikvanoosten/metrics-scala/pulls/117"}}},"pull_request":{"url":"https://api.github.com/repos/erikvanoosten/metrics-scala/pulls/117","id":232997056,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMyOTk3MDU2","html_url":"https://github.com/erikvanoosten/metrics-scala/pull/117","diff_url":"https://github.com/erikvanoosten/metrics-scala/pull/117.diff","patch_url":"https://github.com/erikvanoosten/metrics-scala/pull/117.patch","issue_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/issues/117","number":117,"state":"open","locked":false,"title":"Optimize MetricName","user":{"login":"filipochnik","id":4447011,"node_id":"MDQ6VXNlcjQ0NDcwMTE=","avatar_url":"https://avatars3.githubusercontent.com/u/4447011?v=4","gravatar_id":"","url":"https://api.github.com/users/filipochnik","html_url":"https://github.com/filipochnik","followers_url":"https://api.github.com/users/filipochnik/followers","following_url":"https://api.github.com/users/filipochnik/following{/other_user}","gists_url":"https://api.github.com/users/filipochnik/gists{/gist_id}","starred_url":"https://api.github.com/users/filipochnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/filipochnik/subscriptions","organizations_url":"https://api.github.com/users/filipochnik/orgs","repos_url":"https://api.github.com/users/filipochnik/repos","events_url":"https://api.github.com/users/filipochnik/events{/privacy}","received_events_url":"https://api.github.com/users/filipochnik/received_events","type":"User","site_admin":false},"body":"Hey! During some internal benchmarking I discovered that MetricName class can become a bottle neck if a lot of metric names a generated dynamically on the hot path. \r\nLooking at the code, there were a few things slowing it down:\r\n- `String.replaceAllLiterally` is very slow prior to Java 9\r\n- `String.replaceAll` compiles regex on each method call\r\n- `MetricName.append` was doing some unnecessary work\r\n\r\nSome basic benchmarks, ran on Mid 2015 MacBook Pro with 2.5GHz Core i7\r\n```\r\n$ java -version\r\njava version \"1.8.0_172\"\r\nJava(TM) SE Runtime Environment (build 1.8.0_172-b11)\r\nJava HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)\r\n```\r\n\r\n```\r\nBenchmark                                                                       (className)  Mode  Cnt     Score     Error  Units\r\nBenchMetricName.appendOld                                                 java.util.HashMap  avgt    5  1249.212 ±  35.993  ns/op\r\nBenchMetricName.appendOld           com.sumologic.benchmark.bench.metrics_scala.TestClassA$  avgt    5  1765.970 ± 337.021  ns/op\r\nBenchMetricName.appendOptimized                                           java.util.HashMap  avgt    5   218.687 ±  41.918  ns/op\r\nBenchMetricName.appendOptimized     com.sumologic.benchmark.bench.metrics_scala.TestClassA$  avgt    5   221.283 ±   6.072  ns/op\r\nBenchMetricName.fromClassOld                                              java.util.HashMap  avgt    5  2704.233 ± 146.685  ns/op\r\nBenchMetricName.fromClassOld        com.sumologic.benchmark.bench.metrics_scala.TestClassA$  avgt    5  3520.235 ± 624.656  ns/op\r\nBenchMetricName.fromClassOptimized                                        java.util.HashMap  avgt    5   223.203 ±  37.580  ns/op\r\nBenchMetricName.fromClassOptimized  com.sumologic.benchmark.bench.metrics_scala.TestClassA$  avgt    5   609.280 ±  22.542  ns/op\r\nBenchMetricName.fromNameOld                                               java.util.HashMap  avgt    5   437.847 ±   3.476  ns/op\r\nBenchMetricName.fromNameOld         com.sumologic.benchmark.bench.metrics_scala.TestClassA$  avgt    5   630.851 ±   6.655  ns/op\r\nBenchMetricName.fromNameOptimized                                         java.util.HashMap  avgt    5     3.750 ±   0.021  ns/op\r\nBenchMetricName.fromNameOptimized   com.sumologic.benchmark.bench.metrics_scala.TestClassA$  avgt    5     3.755 ±   0.014  ns/op\r\n```\r\n","created_at":"2018-11-22T14:26:39Z","updated_at":"2018-11-23T13:01:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8e0b20777ac28cbf090047f978a33f0166908403","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/pulls/117/commits","review_comments_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/pulls/117/comments","review_comment_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/pulls/comments{/number}","comments_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/issues/117/comments","statuses_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/statuses/f94b152d97522bc636dd8fa54208bc53c8e9280d","head":{"label":"filipochnik:optimize-metric-name","ref":"optimize-metric-name","sha":"f94b152d97522bc636dd8fa54208bc53c8e9280d","user":{"login":"filipochnik","id":4447011,"node_id":"MDQ6VXNlcjQ0NDcwMTE=","avatar_url":"https://avatars3.githubusercontent.com/u/4447011?v=4","gravatar_id":"","url":"https://api.github.com/users/filipochnik","html_url":"https://github.com/filipochnik","followers_url":"https://api.github.com/users/filipochnik/followers","following_url":"https://api.github.com/users/filipochnik/following{/other_user}","gists_url":"https://api.github.com/users/filipochnik/gists{/gist_id}","starred_url":"https://api.github.com/users/filipochnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/filipochnik/subscriptions","organizations_url":"https://api.github.com/users/filipochnik/orgs","repos_url":"https://api.github.com/users/filipochnik/repos","events_url":"https://api.github.com/users/filipochnik/events{/privacy}","received_events_url":"https://api.github.com/users/filipochnik/received_events","type":"User","site_admin":false},"repo":{"id":158704682,"node_id":"MDEwOlJlcG9zaXRvcnkxNTg3MDQ2ODI=","name":"metrics-scala","full_name":"filipochnik/metrics-scala","private":false,"owner":{"login":"filipochnik","id":4447011,"node_id":"MDQ6VXNlcjQ0NDcwMTE=","avatar_url":"https://avatars3.githubusercontent.com/u/4447011?v=4","gravatar_id":"","url":"https://api.github.com/users/filipochnik","html_url":"https://github.com/filipochnik","followers_url":"https://api.github.com/users/filipochnik/followers","following_url":"https://api.github.com/users/filipochnik/following{/other_user}","gists_url":"https://api.github.com/users/filipochnik/gists{/gist_id}","starred_url":"https://api.github.com/users/filipochnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/filipochnik/subscriptions","organizations_url":"https://api.github.com/users/filipochnik/orgs","repos_url":"https://api.github.com/users/filipochnik/repos","events_url":"https://api.github.com/users/filipochnik/events{/privacy}","received_events_url":"https://api.github.com/users/filipochnik/received_events","type":"User","site_admin":false},"html_url":"https://github.com/filipochnik/metrics-scala","description":"The scala API for Dropwizard's Metrics.","fork":true,"url":"https://api.github.com/repos/filipochnik/metrics-scala","forks_url":"https://api.github.com/repos/filipochnik/metrics-scala/forks","keys_url":"https://api.github.com/repos/filipochnik/metrics-scala/keys{/key_id}","collaborators_url":"https://api.github.com/repos/filipochnik/metrics-scala/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/filipochnik/metrics-scala/teams","hooks_url":"https://api.github.com/repos/filipochnik/metrics-scala/hooks","issue_events_url":"https://api.github.com/repos/filipochnik/metrics-scala/issues/events{/number}","events_url":"https://api.github.com/repos/filipochnik/metrics-scala/events","assignees_url":"https://api.github.com/repos/filipochnik/metrics-scala/assignees{/user}","branches_url":"https://api.github.com/repos/filipochnik/metrics-scala/branches{/branch}","tags_url":"https://api.github.com/repos/filipochnik/metrics-scala/tags","blobs_url":"https://api.github.com/repos/filipochnik/metrics-scala/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/filipochnik/metrics-scala/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/filipochnik/metrics-scala/git/refs{/sha}","trees_url":"https://api.github.com/repos/filipochnik/metrics-scala/git/trees{/sha}","statuses_url":"https://api.github.com/repos/filipochnik/metrics-scala/statuses/{sha}","languages_url":"https://api.github.com/repos/filipochnik/metrics-scala/languages","stargazers_url":"https://api.github.com/repos/filipochnik/metrics-scala/stargazers","contributors_url":"https://api.github.com/repos/filipochnik/metrics-scala/contributors","subscribers_url":"https://api.github.com/repos/filipochnik/metrics-scala/subscribers","subscription_url":"https://api.github.com/repos/filipochnik/metrics-scala/subscription","commits_url":"https://api.github.com/repos/filipochnik/metrics-scala/commits{/sha}","git_commits_url":"https://api.github.com/repos/filipochnik/metrics-scala/git/commits{/sha}","comments_url":"https://api.github.com/repos/filipochnik/metrics-scala/comments{/number}","issue_comment_url":"https://api.github.com/repos/filipochnik/metrics-scala/issues/comments{/number}","contents_url":"https://api.github.com/repos/filipochnik/metrics-scala/contents/{+path}","compare_url":"https://api.github.com/repos/filipochnik/metrics-scala/compare/{base}...{head}","merges_url":"https://api.github.com/repos/filipochnik/metrics-scala/merges","archive_url":"https://api.github.com/repos/filipochnik/metrics-scala/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/filipochnik/metrics-scala/downloads","issues_url":"https://api.github.com/repos/filipochnik/metrics-scala/issues{/number}","pulls_url":"https://api.github.com/repos/filipochnik/metrics-scala/pulls{/number}","milestones_url":"https://api.github.com/repos/filipochnik/metrics-scala/milestones{/number}","notifications_url":"https://api.github.com/repos/filipochnik/metrics-scala/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/filipochnik/metrics-scala/labels{/name}","releases_url":"https://api.github.com/repos/filipochnik/metrics-scala/releases{/id}","deployments_url":"https://api.github.com/repos/filipochnik/metrics-scala/deployments","created_at":"2018-11-22T13:38:42Z","updated_at":"2018-11-22T13:38:44Z","pushed_at":"2018-11-23T12:52:35Z","git_url":"git://github.com/filipochnik/metrics-scala.git","ssh_url":"git@github.com:filipochnik/metrics-scala.git","clone_url":"https://github.com/filipochnik/metrics-scala.git","svn_url":"https://github.com/filipochnik/metrics-scala","homepage":"","size":4823,"stargazers_count":0,"watchers_count":0,"language":"Scala","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":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"erikvanoosten:master","ref":"master","sha":"c15af413ac1b47cf0eec6b95ffb26b967fc9baea","user":{"login":"erikvanoosten","id":630600,"node_id":"MDQ6VXNlcjYzMDYwMA==","avatar_url":"https://avatars3.githubusercontent.com/u/630600?v=4","gravatar_id":"","url":"https://api.github.com/users/erikvanoosten","html_url":"https://github.com/erikvanoosten","followers_url":"https://api.github.com/users/erikvanoosten/followers","following_url":"https://api.github.com/users/erikvanoosten/following{/other_user}","gists_url":"https://api.github.com/users/erikvanoosten/gists{/gist_id}","starred_url":"https://api.github.com/users/erikvanoosten/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erikvanoosten/subscriptions","organizations_url":"https://api.github.com/users/erikvanoosten/orgs","repos_url":"https://api.github.com/users/erikvanoosten/repos","events_url":"https://api.github.com/users/erikvanoosten/events{/privacy}","received_events_url":"https://api.github.com/users/erikvanoosten/received_events","type":"User","site_admin":false},"repo":{"id":5753347,"node_id":"MDEwOlJlcG9zaXRvcnk1NzUzMzQ3","name":"metrics-scala","full_name":"erikvanoosten/metrics-scala","private":false,"owner":{"login":"erikvanoosten","id":630600,"node_id":"MDQ6VXNlcjYzMDYwMA==","avatar_url":"https://avatars3.githubusercontent.com/u/630600?v=4","gravatar_id":"","url":"https://api.github.com/users/erikvanoosten","html_url":"https://github.com/erikvanoosten","followers_url":"https://api.github.com/users/erikvanoosten/followers","following_url":"https://api.github.com/users/erikvanoosten/following{/other_user}","gists_url":"https://api.github.com/users/erikvanoosten/gists{/gist_id}","starred_url":"https://api.github.com/users/erikvanoosten/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erikvanoosten/subscriptions","organizations_url":"https://api.github.com/users/erikvanoosten/orgs","repos_url":"https://api.github.com/users/erikvanoosten/repos","events_url":"https://api.github.com/users/erikvanoosten/events{/privacy}","received_events_url":"https://api.github.com/users/erikvanoosten/received_events","type":"User","site_admin":false},"html_url":"https://github.com/erikvanoosten/metrics-scala","description":"The scala API for Dropwizard's Metrics.","fork":false,"url":"https://api.github.com/repos/erikvanoosten/metrics-scala","forks_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/forks","keys_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/keys{/key_id}","collaborators_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/teams","hooks_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/hooks","issue_events_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/issues/events{/number}","events_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/events","assignees_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/assignees{/user}","branches_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/branches{/branch}","tags_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/tags","blobs_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/git/refs{/sha}","trees_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/git/trees{/sha}","statuses_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/statuses/{sha}","languages_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/languages","stargazers_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/stargazers","contributors_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/contributors","subscribers_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/subscribers","subscription_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/subscription","commits_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/commits{/sha}","git_commits_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/git/commits{/sha}","comments_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/comments{/number}","issue_comment_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/issues/comments{/number}","contents_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/contents/{+path}","compare_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/compare/{base}...{head}","merges_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/merges","archive_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/downloads","issues_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/issues{/number}","pulls_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/pulls{/number}","milestones_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/milestones{/number}","notifications_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/labels{/name}","releases_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/releases{/id}","deployments_url":"https://api.github.com/repos/erikvanoosten/metrics-scala/deployments","created_at":"2012-09-10T17:53:21Z","updated_at":"2018-11-21T10:28:08Z","pushed_at":"2018-11-23T12:52:37Z","git_url":"git://github.com/erikvanoosten/metrics-scala.git","ssh_url":"git@github.com:erikvanoosten/metrics-scala.git","clone_url":"https://github.com/erikvanoosten/metrics-scala.git","svn_url":"https://github.com/erikvanoosten/metrics-scala","homepage":"","size":4813,"stargazers_count":370,"watchers_count":370,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":56,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":56,"open_issues":2,"watchers":370,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/erikvanoosten/metrics-scala/pulls/117"},"html":{"href":"https://github.com/erikvanoosten/metrics-scala/pull/117"},"issue":{"href":"https://api.github.com/repos/erikvanoosten/metrics-scala/issues/117"},"comments":{"href":"https://api.github.com/repos/erikvanoosten/metrics-scala/issues/117/comments"},"review_comments":{"href":"https://api.github.com/repos/erikvanoosten/metrics-scala/pulls/117/comments"},"review_comment":{"href":"https://api.github.com/repos/erikvanoosten/metrics-scala/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/erikvanoosten/metrics-scala/pulls/117/commits"},"statuses":{"href":"https://api.github.com/repos/erikvanoosten/metrics-scala/statuses/f94b152d97522bc636dd8fa54208bc53c8e9280d"}},"author_association":"NONE"}}
{"actor":{"display_login":"erikvanoosten"}}