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

📄 timetest.java

📁 java版的数据结构的完全代码 免费提供了 学习数据结构的请下载
💻 JAVA
字号:
// Introduced in Chapter 7/** Time tests to compare performance of various algorithms. */public class TimeTest {  /** Number of Objects to store in each data structure. */  public static final int LIST_LENGTH = 100;  /** Number of times to perform the operation being timed. */  public static final int TEST_RUNS = 1000000;  /**   * Store LIST_LENGTH Objects in list.  Time list's get() method,   * printing the number of milliseconds taken.   */  public static void test(List<Object> list) {    for (int i = 0; i < LIST_LENGTH; i++) {      list.add(new Object());    }    long before = System.currentTimeMillis();    for (int i = 0; i < TEST_RUNS; i++) {      list.get(5);    }    long after = System.currentTimeMillis();    System.out.println((after - before) + " milliseconds");  }    /** Compare ArrayList with LinkedList. */  public static void main(String[] args) {    System.out.print("ArrayList: ");    test(new ArrayList<Object>());    System.out.print("LinkedList: ");    test(new LinkedList<Object>());  }}

⌨️ 快捷键说明

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