📄 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 + -