ReadDirCache.java

  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. package org.eclipse.jgit.pgm.debug;

  12. import static java.lang.Long.valueOf;

  13. import java.text.MessageFormat;

  14. import org.eclipse.jgit.pgm.Command;
  15. import org.eclipse.jgit.pgm.TextBuiltin;
  16. import org.eclipse.jgit.pgm.internal.CLIText;

  17. @Command(usage = "usage_ReadDirCache")
  18. class ReadDirCache extends TextBuiltin {
  19.     /** {@inheritDoc} */
  20.     @Override
  21.     protected void run() throws Exception {
  22.         final int cnt = 100;
  23.         final long start = System.currentTimeMillis();
  24.         for (int i = 0; i < cnt; i++)
  25.             db.readDirCache();
  26.         final long end = System.currentTimeMillis();
  27.         outw.print(" "); //$NON-NLS-1$
  28.         outw.println(MessageFormat.format(CLIText.get().averageMSPerRead,
  29.                 valueOf((end - start) / cnt)));
  30.     }
  31. }