Use ObjectId[] instead of List for parents
[egit.git] / org.spearce.jgit / tst / org / spearce / jgit / lib / T0005_ShallowSpeedTest.java
blobb598a130789f34fde2a79ac40c42ef0e3558424f
1 /*
2 * Copyright (C) 2006 Robin Rosenberg <robin.rosenberg@dewire.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License, version 2.1, as published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
17 package org.spearce.jgit.lib;
19 import java.io.File;
20 import java.io.IOException;
22 import junit.textui.TestRunner;
24 public class T0005_ShallowSpeedTest extends SpeedTestBase {
26 protected void setUp() throws Exception {
27 prepare(new String[] { "git", "rev-list", "365bbe0d0caaf2ba74d56556827babf0bc66965d" });
30 public void testShallowHistoryScan() throws IOException {
31 long start = System.currentTimeMillis();
32 Repository db = new Repository(new File(kernelrepo));
33 Commit commit = db.mapCommit("365bbe0d0caaf2ba74d56556827babf0bc66965d");
34 int n = 1;
35 do {
36 // System.out.println("commit="+commit.getCommitId());
37 ObjectId[] parents = commit.getParentIds();
38 if (parents.length > 0) {
39 ObjectId parentId = parents[0];
40 commit = db.mapCommit(parentId);
41 commit.getCommitId().toString();
42 ++n;
43 } else {
44 commit = null;
46 } while (commit != null);
47 assertEquals(12275, n);
48 long stop = System.currentTimeMillis();
49 long time = stop - start;
50 System.out.println("native="+nativeTime);
51 System.out.println("jgit="+time);
52 // ~0.750s (hot cache), ok
54 native=1795
55 jgit=722
57 // native git seems to run SLOWER than jgit here, at roughly half the speed
58 // creating the git process is not the issue here, btw.
59 long factor10 = (nativeTime*150/time+50)/100;
60 assertEquals(3, factor10);
63 public static void main(String[] args) {
64 TestRunner.run(T0005_ShallowSpeedTest.class);