View Javadoc
1   /*
2    * Copyright (C) 2008, Google Inc.
3    * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
4    *
5    * This program and the accompanying materials are made available under the
6    * terms of the Eclipse Distribution License v. 1.0 which is available at
7    * https://www.eclipse.org/org/documents/edl-v10.php.
8    *
9    * SPDX-License-Identifier: BSD-3-Clause
10   */
11  
12  package org.eclipse.jgit.pgm.debug;
13  
14  import static java.lang.Long.valueOf;
15  
16  import java.text.MessageFormat;
17  
18  import org.eclipse.jgit.pgm.Command;
19  import org.eclipse.jgit.pgm.TextBuiltin;
20  import org.eclipse.jgit.pgm.internal.CLIText;
21  
22  @Command(usage = "usage_ReadDirCache")
23  class ReadDirCache extends TextBuiltin {
24  	/** {@inheritDoc} */
25  	@Override
26  	protected void run() throws Exception {
27  		final int cnt = 100;
28  		final long start = System.currentTimeMillis();
29  		for (int i = 0; i < cnt; i++)
30  			db.readDirCache();
31  		final long end = System.currentTimeMillis();
32  		outw.print(" "); //$NON-NLS-1$
33  		outw.println(MessageFormat.format(CLIText.get().averageMSPerRead,
34  				valueOf((end - start) / cnt)));
35  	}
36  }