⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timing.java

📁 Standord Classifier实现了一个基于Java的最大熵分类器。用于模式识别
💻 JAVA
字号:
package edu.stanford.nlp.util;

import java.io.PrintStream;

/** A class for measuring how long things take.
 *  @author Christopher Manning
 */
public class Timing {

    /** Stores the time of the current operation start. */
    private static long startTime = System.currentTimeMillis();

    /** This class cannot be instantiated. */
    private Timing() {}

    /** Start the timing operation.
     */
    public static void startTime() {
	startTime = System.currentTimeMillis();
    }

    /** Print how long the timed operation took to System.err.
     *  @param str Additional string to be printed out at end of timing
     *  @return Number of elapsed milliseconds
     */
    public static long endTime(String str) {
	return endTime(str, System.err);
    }

    /** Print how long the timed operation took.
     *  @param str Additional string to be printed out at end of timing
     *  @param stream PrintStream on which to write output
     *  @return Number of elapsed milliseconds
     */
    public static long endTime(String str, PrintStream stream) {
	long elapsed = System.currentTimeMillis() - startTime;
	stream.println("Time elapsed " + str  + ": " +
			   elapsed + " milliseconds");
	return elapsed;
    }

    /** Print how long the timed operation took.
     *  @return Number of elapsed milliseconds
     */
    public static long endTime() {
	return endTime("");
    }

    /** Print how much time has passed to System.out.
     *  Time is measured from the last
     *  <code>tick</code> call, or the last call to <code>startTime</code> or
     *  when the class was loaded if there has been no previous call.
     *  @param str Prefix of string printed with time
     *  @return Number of elapsed milliseconds from tick (or start)
     */
    public static long tick(String str) {
	return tick(str, System.out);
    }

    /** Print how much time has passed.  Time is measured from the last
     *  <code>tick</code> call, or the last call to <code>startTime</code> or
     *  when the class was loaded if there has been no previous call.
     *  @param str Prefix of string printed with time
     *  @param stream PrintStream that is written to
     *  @return Number of elapsed milliseconds from tick (or start)
     */
    public static long tick(String str, PrintStream stream) {
	long time2 = System.currentTimeMillis();
	long elapsed = time2 - startTime;
	startTime = time2;
	stream.println(str+" "+(elapsed/100)/10.0+" sec.");
	return elapsed;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -