?? test.java
字號:
package patternMatching;
import java.lang.management.*;
public class Test {
/**
* @param args
*/
public static void main(String[] args) throws java.io.FileNotFoundException {
long start;
long end;
ThreadMXBean mBeanServer = ManagementFactory.getThreadMXBean();
start = mBeanServer.getCurrentThreadCpuTime();
String text = ReadIn.readIn("NBA_NIKE新浪競技風暴_新浪網.htm");
//System.out.println(text);
end = mBeanServer.getCurrentThreadCpuTime();
System.out.println("Loading costs:"+(end-start)+"\n");
String strPattern = "大仙:阿泰是無麥時刻最強支柱 沒他火箭回舊社會";
PatternMatcher pattern;
int result;
System.out.println("BruteForce");
start = mBeanServer.getCurrentThreadCpuTime();
pattern = new BruteForce(strPattern);
result = pattern.match(text);
end = mBeanServer.getCurrentThreadCpuTime();
System.out.println("The pattern "+strPattern+" is found with index of "+result);
System.out.println("The time cost is "+(end-start)+"\n");
System.out.println("BoyerMoore");
start = mBeanServer.getCurrentThreadCpuTime();
pattern = new BoyerMoore(strPattern);
result = pattern.match(text);
end = mBeanServer.getCurrentThreadCpuTime();
System.out.println("the pattern "+strPattern+" is found with index of "+result);
System.out.println("The time cost is "+(end-start)+"\n");
System.out.println("KnuthMorrisPratt");
start = mBeanServer.getCurrentThreadCpuTime();
pattern = new KnuthMorrisPratt(strPattern);
result = pattern.match(text);
end = mBeanServer.getCurrentThreadCpuTime();
System.out.println("the pattern "+strPattern+" is found with index of "+result);
System.out.println("The time cost is "+(end-start)+"\n");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -