'Search all versions of a file in git log takes long
I noticed that finding all versions of a specific file in git takes a long time when the number of files in the repo is more then a couple of thousand. Any idea how to improve the performance? Here is the code we use:
try (Git git = Git.init().setDirectory(targetDirectory).call()) {
/* Find all versions in git logs */
Iterable<RevCommit> logs3 = git.log().addPath(fileName + ".yaml").call();
/* verCount has number of git versions for the page */
int verCount = 0;
for (RevCommit rev3 : logs3) {
verCount++;
String versionName = "V." + verCount;
final String versionID = rev3.getName();
final Date versionDate = rev3.getAuthorIdent().getWhen();
final String versionComment = rev3.getFullMessage();
final String versionAuthor = rev3.getAuthorIdent().getName();
versionList.add(new VersionInfo(versionName, versionDate, versionAuthor,
versionID, versionComment));
}
}
Also is there a good way in Java to measure which line is taking long in my snippet? I have my guess but need to measure it somehow.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|