Exemplo n.º 1
0
  public void execute() throws Pausable {
    int i = REPETITIONS;

    do {
      result = mymb.get();
    } while (0 != --i);
  }
Exemplo n.º 2
0
 @Override
 public void execute() throws Pausable {
   HttpResponse resp = null;
   try {
     point.write(req.toBuffer());
     resp = new HttpResponse();
     resp.readHead(point);
     resp.readBody(point);
     mailbox.put(resp);
   } catch (IOException e) {
     point.close();
     // do it to running schedule for to call selector's wakeup
     Task.yield();
     mailbox.put(new ErrorMsg(e));
   }
 }
Exemplo n.º 3
0
  public void execute() throws Pausable {
    int i = REPETITIONS;
    int value = 888;
    do {

      mymb.put(value);
    } while (0 != --i);
  }
Exemplo n.º 4
0
  public static void performanceRun(int runNumber) {
    final long start = System.nanoTime();
    Mailbox<Integer> mbox = new Mailbox<Integer>(QUEUE_CAPACITY, QUEUE_CAPACITY);
    Mailbox<ExitMsg> exitmb1 = new Mailbox<ExitMsg>();
    Mailbox<ExitMsg> exitmb2 = new Mailbox<ExitMsg>();
    Producer1 p1 = new Producer1(mbox);
    p1.informOnExit(exitmb1);

    PerfTest t2 = new PerfTest(mbox);
    t2.informOnExit(exitmb2);

    p1.start();

    t2.start();
    exitmb1.getb();
    exitmb2.getb();
    final long duration = System.nanoTime() - start;
    final long ops = (REPETITIONS * 1000L * 1000L * 1000L) / duration;
    System.out.format("%d - ops/sec=%,d", Integer.valueOf(runNumber), Long.valueOf(ops));
  }
Exemplo n.º 5
0
  public static void print_all_stack_traces() {
    System.err.println("== Trace ==");

    Mailbox<EObject> mbox = new Mailbox<>(EProc.process_count());

    ESeq all = EProc.processes();
    for (EObject o : all) {
      EInternalPID pid = (EInternalPID) o;
      pid.task().printStackTrace(mbox);
    }

    while (true) {
      EObject o = mbox.getb(1000);
      if (o == null) break;

      ETuple2 tup = ETuple2.cast(o);
      EHandle handle = tup.elm(1).testHandle();
      ESeq stack = tup.elm(2).testSeq();

      System.err.println("\n == " + handle + " : " + handle.name);
      for (EObject elm : stack) {

        ETuple4 tup4 = ETuple4.cast(elm);

        if (tup4 != null) {
          ESeq args = tup4.elem3.testSeq();
          ESmall arity = tup4.elem3.testSmall();
          if (arity == null && args != null) {
            arity = ERT.box(args.length());
          }

          StringBuffer file_line = new StringBuffer();

          ESeq info = tup4.elem4.testSeq();
          if (info != null) {
            String file = "?";
            int line = -1;
            for (EObject inf : info) {
              ETuple2 t;
              if ((t = ETuple2.cast(inf)) != null) {
                ESmall n;
                EString f;
                if (t.elem1 == ErlangException.am_line && ((n = t.elem2.testSmall()) != null)) {
                  line = n.value;
                } else if (t.elem1 == ErlangException.am_file
                    && ((f = t.elem2.testString()) != null)) {
                  file = f.stringValue();
                }
              }
            }
            if (line != -1) {
              file_line.append('(').append(file).append(':').append(line).append(')');
            }
          }

          String module = tup4.elem1.toString();
          String mfa;
          System.err.print(mfa = make_width(20, module) + ":" + tup4.elem2 + "/" + arity);
          System.err.println(" " + make_width(65 - mfa.length(), file_line.toString()));
        } else {
          System.err.println(elm);
        }
      }
    }
  }