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
;
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");
36 ObjectId
[] parents
= commit
.getParentIds();
37 if (parents
.length
== 0)
39 ObjectId parentId
= parents
[0];
40 commit
= db
.mapCommit(parentId
);
41 commit
.getCommitId().toString();
44 assertEquals(12275, n
);
45 long stop
= System
.currentTimeMillis();
46 long time
= stop
- start
;
47 System
.out
.println("native="+nativeTime
);
48 System
.out
.println("jgit="+time
);
49 // ~0.750s (hot cache), ok
54 // native git seems to run SLOWER than jgit here, at roughly half the speed
55 // creating the git process is not the issue here, btw.
56 long factor10
= (nativeTime
*150/time
+50)/100;
57 assertEquals(3, factor10
);
60 public static void main(String
[] args
) {
61 TestRunner
.run(T0005_ShallowSpeedTest
.class);