{"action":"created","comment":{"url":"https://api.github.com/repos/JabRef/jabref/pulls/comments/58584720","id":58584720,"diff_hunk":"@@ -0,0 +1,91 @@\n+package net.sf.jabref.benchmarks;\n+\n+import java.io.IOException;\n+import java.io.StringReader;\n+import java.io.StringWriter;\n+import java.util.ArrayList;\n+import java.util.List;\n+import java.util.Random;\n+import java.util.stream.Collectors;\n+\n+import net.sf.jabref.*;\n+import net.sf.jabref.exporter.BibDatabaseWriter;\n+import net.sf.jabref.exporter.SaveException;\n+import net.sf.jabref.exporter.SavePreferences;\n+import net.sf.jabref.importer.ParserResult;\n+import net.sf.jabref.importer.fileformat.BibtexParser;\n+import net.sf.jabref.logic.search.SearchQuery;\n+import net.sf.jabref.model.database.BibDatabase;\n+import net.sf.jabref.model.database.BibDatabaseMode;\n+import net.sf.jabref.model.database.BibDatabaseModeDetection;\n+import net.sf.jabref.model.entry.BibEntry;\n+import org.openjdk.jmh.Main;\n+import org.openjdk.jmh.annotations.*;\n+import org.openjdk.jmh.runner.RunnerException;\n+\n+@State(Scope.Thread)\n+public class Benchmarks {\n+    StringReader bibtexStringReader;\n+    BibDatabase database = new BibDatabase();\n+\n+    @Setup\n+    public void init() throws IOException, SaveException {\n+        Globals.prefs = JabRefPreferences.getInstance();\n+\n+        Random randomizer = new Random();\n+        for(int i = 0; i < 1000; i++)\n+        {","path":"src/jmh/java/net/sf/jabref/benchmarks/Benchmarks.java","position":37,"original_position":37,"commit_id":"774127e93509cd2eb3a1a3363f75afc3af972a52","original_commit_id":"774127e93509cd2eb3a1a3363f75afc3af972a52","user":{"login":"simonharrer","id":375693,"avatar_url":"https://avatars.githubusercontent.com/u/375693?v=3","gravatar_id":"","url":"https://api.github.com/users/simonharrer","html_url":"https://github.com/simonharrer","followers_url":"https://api.github.com/users/simonharrer/followers","following_url":"https://api.github.com/users/simonharrer/following{/other_user}","gists_url":"https://api.github.com/users/simonharrer/gists{/gist_id}","starred_url":"https://api.github.com/users/simonharrer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonharrer/subscriptions","organizations_url":"https://api.github.com/users/simonharrer/orgs","repos_url":"https://api.github.com/users/simonharrer/repos","events_url":"https://api.github.com/users/simonharrer/events{/privacy}","received_events_url":"https://api.github.com/users/simonharrer/received_events","type":"User","site_admin":false},"body":"formatting\r\n\r\nI would use more elements, e.g., 10k as this should be more helpful for finding the issues.","created_at":"2016-04-05T17:54:33Z","updated_at":"2016-04-05T17:54:33Z","html_url":"https://github.com/JabRef/jabref/pull/1103#discussion_r58584720","pull_request_url":"https://api.github.com/repos/JabRef/jabref/pulls/1103","_links":{"self":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/comments/58584720"},"html":{"href":"https://github.com/JabRef/jabref/pull/1103#discussion_r58584720"},"pull_request":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/1103"}}},"pull_request":{"url":"https://api.github.com/repos/JabRef/jabref/pulls/1103","id":65286109,"html_url":"https://github.com/JabRef/jabref/pull/1103","diff_url":"https://github.com/JabRef/jabref/pull/1103.diff","patch_url":"https://github.com/JabRef/jabref/pull/1103.patch","issue_url":"https://api.github.com/repos/JabRef/jabref/issues/1103","number":1103,"state":"open","locked":false,"title":"Add benchmarks","user":{"login":"tobiasdiez","id":5037600,"avatar_url":"https://avatars.githubusercontent.com/u/5037600?v=3","gravatar_id":"","url":"https://api.github.com/users/tobiasdiez","html_url":"https://github.com/tobiasdiez","followers_url":"https://api.github.com/users/tobiasdiez/followers","following_url":"https://api.github.com/users/tobiasdiez/following{/other_user}","gists_url":"https://api.github.com/users/tobiasdiez/gists{/gist_id}","starred_url":"https://api.github.com/users/tobiasdiez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tobiasdiez/subscriptions","organizations_url":"https://api.github.com/users/tobiasdiez/orgs","repos_url":"https://api.github.com/users/tobiasdiez/repos","events_url":"https://api.github.com/users/tobiasdiez/events{/privacy}","received_events_url":"https://api.github.com/users/tobiasdiez/received_events","type":"User","site_admin":false},"body":"This PR adds some basic benchmarks for parsing and writing a bib file. The results are as following for a database consisting of 1000 entries.\r\nBenchmark                         Score     Error  Units\r\nBenchmarks.parse                 49736.582 ± 788.879  ops/s\r\nBenchmarks.write                0.706 ±   0.012  ops/s\r\nBenchmarks.search                258.838 ±   5.604  ops/s\r\nBenchmarks.inferBibDatabaseMode  1297.622 ±  22.910  ops/s\r\n\r\nAs one can see the parse operation is by many orders of magnitudes quicker then writing. I had a closer look at the write operation and it turned out that 66% of the time is spent in Database.getMode(). Some small changes improved the situation by a factor of 10\r\nBenchmark                         Score      Error  Units\r\nBenchmarks.parse                42031.971 ± 8188.833  ops/s\r\nBenchmarks.write                 8.299 ±    0.304  ops/s\r\nBenchmarks.search               248.093 ±    7.573  ops/s\r\nBenchmarks.inferBibDatabaseMode  20759.711 ±  397.031  ops/s\r\n\r\nI suspect the changes in #1100 improve the situation even more (since there the database mode is cached).\r\n\r\n(By the way, `gradle jmh` runs the benchmarks. So its pretty simple to use.)\r\n\r\n\r\n- [ ] Change in CHANGELOG.md described\r\n- [ ] Tests created for changes\r\n- [ ] Screenshots added (for bigger UI changes)\r\n\r\n","created_at":"2016-04-05T11:05:49Z","updated_at":"2016-04-05T17:54:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"66a364a6ef423e1d44e5619a818825fd3afe1342","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/JabRef/jabref/pulls/1103/commits","review_comments_url":"https://api.github.com/repos/JabRef/jabref/pulls/1103/comments","review_comment_url":"https://api.github.com/repos/JabRef/jabref/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JabRef/jabref/issues/1103/comments","statuses_url":"https://api.github.com/repos/JabRef/jabref/statuses/774127e93509cd2eb3a1a3363f75afc3af972a52","head":{"label":"tobiasdiez:benchmark","ref":"benchmark","sha":"774127e93509cd2eb3a1a3363f75afc3af972a52","user":{"login":"tobiasdiez","id":5037600,"avatar_url":"https://avatars.githubusercontent.com/u/5037600?v=3","gravatar_id":"","url":"https://api.github.com/users/tobiasdiez","html_url":"https://github.com/tobiasdiez","followers_url":"https://api.github.com/users/tobiasdiez/followers","following_url":"https://api.github.com/users/tobiasdiez/following{/other_user}","gists_url":"https://api.github.com/users/tobiasdiez/gists{/gist_id}","starred_url":"https://api.github.com/users/tobiasdiez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tobiasdiez/subscriptions","organizations_url":"https://api.github.com/users/tobiasdiez/orgs","repos_url":"https://api.github.com/users/tobiasdiez/repos","events_url":"https://api.github.com/users/tobiasdiez/events{/privacy}","received_events_url":"https://api.github.com/users/tobiasdiez/received_events","type":"User","site_admin":false},"repo":{"id":25407066,"name":"jabref","full_name":"tobiasdiez/jabref","owner":{"login":"tobiasdiez","id":5037600,"avatar_url":"https://avatars.githubusercontent.com/u/5037600?v=3","gravatar_id":"","url":"https://api.github.com/users/tobiasdiez","html_url":"https://github.com/tobiasdiez","followers_url":"https://api.github.com/users/tobiasdiez/followers","following_url":"https://api.github.com/users/tobiasdiez/following{/other_user}","gists_url":"https://api.github.com/users/tobiasdiez/gists{/gist_id}","starred_url":"https://api.github.com/users/tobiasdiez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tobiasdiez/subscriptions","organizations_url":"https://api.github.com/users/tobiasdiez/orgs","repos_url":"https://api.github.com/users/tobiasdiez/repos","events_url":"https://api.github.com/users/tobiasdiez/events{/privacy}","received_events_url":"https://api.github.com/users/tobiasdiez/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tobiasdiez/jabref","description":"Graphical Java application for managing bibtex (.bib) databases","fork":true,"url":"https://api.github.com/repos/tobiasdiez/jabref","forks_url":"https://api.github.com/repos/tobiasdiez/jabref/forks","keys_url":"https://api.github.com/repos/tobiasdiez/jabref/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tobiasdiez/jabref/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tobiasdiez/jabref/teams","hooks_url":"https://api.github.com/repos/tobiasdiez/jabref/hooks","issue_events_url":"https://api.github.com/repos/tobiasdiez/jabref/issues/events{/number}","events_url":"https://api.github.com/repos/tobiasdiez/jabref/events","assignees_url":"https://api.github.com/repos/tobiasdiez/jabref/assignees{/user}","branches_url":"https://api.github.com/repos/tobiasdiez/jabref/branches{/branch}","tags_url":"https://api.github.com/repos/tobiasdiez/jabref/tags","blobs_url":"https://api.github.com/repos/tobiasdiez/jabref/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tobiasdiez/jabref/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tobiasdiez/jabref/git/refs{/sha}","trees_url":"https://api.github.com/repos/tobiasdiez/jabref/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tobiasdiez/jabref/statuses/{sha}","languages_url":"https://api.github.com/repos/tobiasdiez/jabref/languages","stargazers_url":"https://api.github.com/repos/tobiasdiez/jabref/stargazers","contributors_url":"https://api.github.com/repos/tobiasdiez/jabref/contributors","subscribers_url":"https://api.github.com/repos/tobiasdiez/jabref/subscribers","subscription_url":"https://api.github.com/repos/tobiasdiez/jabref/subscription","commits_url":"https://api.github.com/repos/tobiasdiez/jabref/commits{/sha}","git_commits_url":"https://api.github.com/repos/tobiasdiez/jabref/git/commits{/sha}","comments_url":"https://api.github.com/repos/tobiasdiez/jabref/comments{/number}","issue_comment_url":"https://api.github.com/repos/tobiasdiez/jabref/issues/comments{/number}","contents_url":"https://api.github.com/repos/tobiasdiez/jabref/contents/{+path}","compare_url":"https://api.github.com/repos/tobiasdiez/jabref/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tobiasdiez/jabref/merges","archive_url":"https://api.github.com/repos/tobiasdiez/jabref/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tobiasdiez/jabref/downloads","issues_url":"https://api.github.com/repos/tobiasdiez/jabref/issues{/number}","pulls_url":"https://api.github.com/repos/tobiasdiez/jabref/pulls{/number}","milestones_url":"https://api.github.com/repos/tobiasdiez/jabref/milestones{/number}","notifications_url":"https://api.github.com/repos/tobiasdiez/jabref/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tobiasdiez/jabref/labels{/name}","releases_url":"https://api.github.com/repos/tobiasdiez/jabref/releases{/id}","deployments_url":"https://api.github.com/repos/tobiasdiez/jabref/deployments","created_at":"2014-10-18T19:04:49Z","updated_at":"2014-11-29T22:04:20Z","pushed_at":"2016-04-05T17:53:41Z","git_url":"git://github.com/tobiasdiez/jabref.git","ssh_url":"git@github.com:tobiasdiez/jabref.git","clone_url":"https://github.com/tobiasdiez/jabref.git","svn_url":"https://github.com/tobiasdiez/jabref","homepage":"http://jabref.sourceforge.net/","size":84329,"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":"JabRef:master","ref":"master","sha":"312fc6f3465554d86d28cb129058bd80feca0dd8","user":{"login":"JabRef","id":3914421,"avatar_url":"https://avatars.githubusercontent.com/u/3914421?v=3","gravatar_id":"","url":"https://api.github.com/users/JabRef","html_url":"https://github.com/JabRef","followers_url":"https://api.github.com/users/JabRef/followers","following_url":"https://api.github.com/users/JabRef/following{/other_user}","gists_url":"https://api.github.com/users/JabRef/gists{/gist_id}","starred_url":"https://api.github.com/users/JabRef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JabRef/subscriptions","organizations_url":"https://api.github.com/users/JabRef/orgs","repos_url":"https://api.github.com/users/JabRef/repos","events_url":"https://api.github.com/users/JabRef/events{/privacy}","received_events_url":"https://api.github.com/users/JabRef/received_events","type":"Organization","site_admin":false},"repo":{"id":17634071,"name":"jabref","full_name":"JabRef/jabref","owner":{"login":"JabRef","id":3914421,"avatar_url":"https://avatars.githubusercontent.com/u/3914421?v=3","gravatar_id":"","url":"https://api.github.com/users/JabRef","html_url":"https://github.com/JabRef","followers_url":"https://api.github.com/users/JabRef/followers","following_url":"https://api.github.com/users/JabRef/following{/other_user}","gists_url":"https://api.github.com/users/JabRef/gists{/gist_id}","starred_url":"https://api.github.com/users/JabRef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JabRef/subscriptions","organizations_url":"https://api.github.com/users/JabRef/orgs","repos_url":"https://api.github.com/users/JabRef/repos","events_url":"https://api.github.com/users/JabRef/events{/privacy}","received_events_url":"https://api.github.com/users/JabRef/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JabRef/jabref","description":"Graphical Java application for managing bibtex (.bib) databases","fork":false,"url":"https://api.github.com/repos/JabRef/jabref","forks_url":"https://api.github.com/repos/JabRef/jabref/forks","keys_url":"https://api.github.com/repos/JabRef/jabref/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JabRef/jabref/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JabRef/jabref/teams","hooks_url":"https://api.github.com/repos/JabRef/jabref/hooks","issue_events_url":"https://api.github.com/repos/JabRef/jabref/issues/events{/number}","events_url":"https://api.github.com/repos/JabRef/jabref/events","assignees_url":"https://api.github.com/repos/JabRef/jabref/assignees{/user}","branches_url":"https://api.github.com/repos/JabRef/jabref/branches{/branch}","tags_url":"https://api.github.com/repos/JabRef/jabref/tags","blobs_url":"https://api.github.com/repos/JabRef/jabref/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JabRef/jabref/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JabRef/jabref/git/refs{/sha}","trees_url":"https://api.github.com/repos/JabRef/jabref/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JabRef/jabref/statuses/{sha}","languages_url":"https://api.github.com/repos/JabRef/jabref/languages","stargazers_url":"https://api.github.com/repos/JabRef/jabref/stargazers","contributors_url":"https://api.github.com/repos/JabRef/jabref/contributors","subscribers_url":"https://api.github.com/repos/JabRef/jabref/subscribers","subscription_url":"https://api.github.com/repos/JabRef/jabref/subscription","commits_url":"https://api.github.com/repos/JabRef/jabref/commits{/sha}","git_commits_url":"https://api.github.com/repos/JabRef/jabref/git/commits{/sha}","comments_url":"https://api.github.com/repos/JabRef/jabref/comments{/number}","issue_comment_url":"https://api.github.com/repos/JabRef/jabref/issues/comments{/number}","contents_url":"https://api.github.com/repos/JabRef/jabref/contents/{+path}","compare_url":"https://api.github.com/repos/JabRef/jabref/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JabRef/jabref/merges","archive_url":"https://api.github.com/repos/JabRef/jabref/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JabRef/jabref/downloads","issues_url":"https://api.github.com/repos/JabRef/jabref/issues{/number}","pulls_url":"https://api.github.com/repos/JabRef/jabref/pulls{/number}","milestones_url":"https://api.github.com/repos/JabRef/jabref/milestones{/number}","notifications_url":"https://api.github.com/repos/JabRef/jabref/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JabRef/jabref/labels{/name}","releases_url":"https://api.github.com/repos/JabRef/jabref/releases{/id}","deployments_url":"https://api.github.com/repos/JabRef/jabref/deployments","created_at":"2014-03-11T14:48:42Z","updated_at":"2016-04-05T05:59:55Z","pushed_at":"2016-04-05T17:53:44Z","git_url":"git://github.com/JabRef/jabref.git","ssh_url":"git@github.com:JabRef/jabref.git","clone_url":"https://github.com/JabRef/jabref.git","svn_url":"https://github.com/JabRef/jabref","homepage":"http://www.jabref.org/","size":87442,"stargazers_count":257,"watchers_count":257,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":167,"mirror_url":null,"open_issues_count":196,"forks":167,"open_issues":196,"watchers":257,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/1103"},"html":{"href":"https://github.com/JabRef/jabref/pull/1103"},"issue":{"href":"https://api.github.com/repos/JabRef/jabref/issues/1103"},"comments":{"href":"https://api.github.com/repos/JabRef/jabref/issues/1103/comments"},"review_comments":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/1103/comments"},"review_comment":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/1103/commits"},"statuses":{"href":"https://api.github.com/repos/JabRef/jabref/statuses/774127e93509cd2eb3a1a3363f75afc3af972a52"}}}}