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

📄 consume.java

📁 java连接mysql包!! !!! 支持
💻 JAVA
字号:
import jcsp.lang.*;

class Consume implements CSProcess {

  private int nIterations;
  private ChannelInputInt in;

  public Consume (int nIterations, ChannelInputInt in) {
    this.nIterations = nIterations;
    this.in = in;
  }

  public void run () {

    int check = 0;
    int errors = 0;
    int x = -1;
    final int warm_up = 1001;
    System.out.print ("warming up ... ");
    for (int i = 0; i < warm_up; i++) {
      x = in.read ();
      if (x != check) {
        System.out.println ("*** ERROR : expected " + check + ", received " + x);
	errors++;
      }
      check++;
    }
    System.out.println ("last number received = " + x);

    System.out.println ("warm-up (" + warm_up +
                        ") cycles completed ... timing now starting ...\n");

    while (true) {

      long t0 = System.currentTimeMillis ();
      for (int i = 0; i < nIterations; i++) {
        x = in.read ();
        if (x != check) {
          System.out.println ("*** ERROR : expected " + check + ", received " + x);
	  errors++;
        }
        check++;
      }
      long t1 = System.currentTimeMillis ();

      System.out.println ("last number received = " + x);
      long microseconds   = (t1 - t0) * 1000;
      long timePerIteration_us = (microseconds / ((long) nIterations));
      System.out.println ("   " + timePerIteration_us + " microseconds / iteration");
      timePerIteration_us = (microseconds / ((long) (4*nIterations)));
      System.out.println ("   " + timePerIteration_us + " microseconds / communication");
      timePerIteration_us = (microseconds / ((long) (8*nIterations)));
      System.out.println ("   " + timePerIteration_us + " microseconds / context switch");
      System.out.println ("   " + errors + " errors!");
      System.out.println ("   " + SpuriousLog.numberSpuriousWakeUps () + " spurious wakeups!!");

    }

  }

}

⌨️ 快捷键说明

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