Created
December 9, 2010 22:00
-
-
Save rtyley/735402 to your computer and use it in GitHub Desktop.
jgit pack-indexing performance test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.eclipse.jgit.transport; | |
import org.eclipse.jgit.lib.NullProgressMonitor; | |
import org.eclipse.jgit.lib.RepositoryTestCase; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.List; | |
import static java.util.Arrays.asList; | |
public class IndexPackPerformanceTest extends RepositoryTestCase { | |
public void testIndexingPerformanceVsStreamThresholdSize() throws IOException { | |
final String[] packFilePaths = { | |
"/home/roberto/development/google-guice-git/.git/objects/pack/pack-7da01e4809d62bb98f271bb65c40f286edc20b48.pack", | |
"/home/roberto/development/glug/.git/objects/pack/pack-eeb4b313214ece7599b8e778deb8b4c17b168f03.pack", | |
"/home/roberto/development/jgit/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/test/resources/pack-cbdeda40019ae0e6e789088ea0f51f164f489d14.pack", | |
"/home/roberto/kdenlive-upgrade/x264/.git/objects/pack/pack-cab2cef0f4b52ec3c137f1e2912877cf2230e3b9.pack", | |
"/home/roberto/android-repos/.repo/projects/external/webkit.git/objects/pack/pack-cccd4f5de08fd45ef4fe3875649cae6db3052fdf.pack" | |
}; | |
List<Integer> streamThresholdMagnitudes=asList(0, 2, 4, 6, 8, 10, 12, 14, 16, 20, 22 ); | |
int repeats=10; | |
List<Integer> testList=new ArrayList<Integer>(); | |
for (int i=0;i<repeats;++i) { | |
testList.addAll(streamThresholdMagnitudes); | |
} | |
Collections.shuffle(testList); | |
System.out.print("testNum,magnitude"); | |
for (String packFilePath : packFilePaths) { | |
final File file = new File(packFilePath); | |
System.out.print(","+ file.getName()+" ("+file.length()+" bytes)"); | |
} | |
System.out.println(); | |
for (int testNum=0;testNum<testList.size(); ++testNum) { | |
final Integer magnitude = testList.get(testNum); | |
System.out.print(testNum+","+magnitude); | |
for (String packFilePath : packFilePaths) { | |
long duration=execute(new File(packFilePath), testNum, magnitude); | |
System.out.print(","+duration); | |
try { | |
Thread.sleep(1000L); // allow any resulting GC to finish | |
} catch (InterruptedException e) {} | |
} | |
System.out.println(); | |
} | |
} | |
private long execute(File packFile, int testNum, int streamThresholdMagnitude) throws IOException { | |
InputStream is = new FileInputStream(packFile); | |
try { | |
long start=System.currentTimeMillis(); | |
IndexPack pack = new IndexPack(db, is, new File(trash,"tmp_pack_perf_"+packFile.getName()+"_run_" + streamThresholdMagnitude + "_" + testNum)); | |
pack.setStreamFileThreshold(1<<streamThresholdMagnitude); | |
pack.index(NullProgressMonitor.INSTANCE); | |
return System.currentTimeMillis()-start; | |
} finally { | |
is.close(); | |
} | |
} | |
} |
These performance tests relate to JGit Change I862afd4c - http://egit.eclipse.org/r/2040 (IndexPack: Use streaming for large whole blobs) - which is the fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=312868 (java.lang.OutOfMemoryError when fetching objects bigger than heap size)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The data generated by this test is at https://spreadsheets.google.com/ccc?key=tLCQElyyd2RKN9QevfvgwGQ&hl=en_GB#gid=1