diff test/org/tmatesoft/hg/test/TestStatus.java @ 100:b71b3f7d24d4

Primitive performance test
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 28 Jan 2011 02:15:12 +0100
parents 4d7bb95d553b
children 777ab7034c1b
line wrap: on
line diff
--- a/test/org/tmatesoft/hg/test/TestStatus.java	Thu Jan 27 23:08:51 2011 +0100
+++ b/test/org/tmatesoft/hg/test/TestStatus.java	Fri Jan 28 02:15:12 2011 +0100
@@ -47,6 +47,7 @@
 		TestStatus test = new TestStatus(repo);
 		test.testLowLevel();
 		test.testStatusCommand();
+		test.testPerformance();
 	}
 	
 	public TestStatus(HgRepository hgRepo) {
@@ -112,6 +113,29 @@
 		 */
 	}
 	
+	/*
+	 * With warm-up of previous tests, 10 runs, time in milliseconds
+	 * 'hg status -A': Native client total 953 (95 per run), Java client 94 (9)
+	 * 'hg status -A --rev 3:80': Native client total 1828 (182 per run), Java client 235 (23)
+	 * 'hg log --debug', 10 runs: Native client total 1766 (176 per run), Java client 78 (7)
+	 */
+	public void testPerformance() throws Exception {
+		final int runs = 10;
+		final long start1 = System.currentTimeMillis();
+		for (int i = 0; i < runs; i++) {
+			statusParser.reset();
+			eh.run("hg", "status", "-A", "--rev", "3:80");
+		}
+		final long start2 = System.currentTimeMillis();
+		for (int i = 0; i < runs; i++) {
+			HgStatusCollector.Record r = new HgStatusCollector.Record();
+			new StatusCommand(repo).all().base(3).revision(80).execute(r);
+		}
+		final long end = System.currentTimeMillis();
+		System.out.printf("'hg status -A --rev 3:80', %d runs:  Native client total %d (%d per run), Java client %d (%d)\n", runs, start2-start1, (start2-start1)/runs, end-start2, (end-start2)/runs);
+	}
+	
+	
 	private static void report(String what, HgStatusCollector.Record r, StatusOutputParser statusParser) {
 		System.out.println(">>>" + what);
 		reportNotEqual("MODIFIED", r.getModified(), statusParser.getModified());