예제 #1
0
파일: PerfTest.java 프로젝트: ETK/javersion
  private static void runClojure(Integer[] data) {
    out.println("Clojure PersistentHashMap");
    clojure.lang.PersistentHashMap cmap = clojure.lang.PersistentHashMap.EMPTY;

    // warmup
    for (Integer v : data) {
      cmap = (clojure.lang.PersistentHashMap) cmap.assoc(v, v);
    }
    cmap = null;
    System.gc();

    long begin = System.nanoTime();
    for (int i = 1; i <= data.length; i++) {
      start();
      cmap = clojure.lang.PersistentHashMap.EMPTY;
      for (int j = 0; j < i; j++) {
        cmap = (clojure.lang.PersistentHashMap) cmap.assoc(data[j], data[j]);
      }
      for (int j = 0; j < i; j++) {
        cmap = (clojure.lang.PersistentHashMap) cmap.without(data[j]);
      }
      out.println(end());
    }
    out.println(String.format("\n%s", System.nanoTime() - begin));
  }
예제 #2
0
파일: System.java 프로젝트: prasaadk/renjin
  @Internal
  public static DoubleVector gc(boolean verbose, boolean reset) {
    try {
      java.lang.System.gc();
    } catch (Exception e) {

    }
    return new DoubleArrayVector();
  }
예제 #3
0
  // Static main program for executing a test of the class.
  public static void main(String args[]) {
    // Define int variables.
    int width = 0;
    int height = 0;

    // If arguments are greater than zero.
    if (args.length > 0) {

      // If arguments are two.
      if (args.length >= 2) {
        // Use try block to parse for an integer.
        try {
          // Verify first argument is an integer.
          width = Integer.parseInt(args[0]);
          height = Integer.parseInt(args[1]);

          // Define a default instance of JMessagingFrame.
          JMessagingFrame f = new JMessagingFrame(width, height);

        } // Catch parsing failure exception.
        catch (NumberFormatException e) {
          // Print default runtime message.
          System.out.println("If you are testing the override constructor,");
          System.out.println("then you need to provide two integer values.");
        } // End try-catch block on integer parse.

      } // End of if two arguments provided.
      else // When there are less than or more than two arguments.
      {
        // Print default runtime message.
        System.out.println("If you are testing the override constructor,");
        System.out.println("then you need to provide two integer values.");
      } // End of else when there are less than or more than two arguments.

    } // End of else when there are two arguments.
    else // No arguments provided.
    {
      // Define a default instance of JMessagingFrame.
      JMessagingFrame f = new JMessagingFrame();

      // Clean-up by signaling the garbage collector.
      System.gc();
    } // End of else when no arguments are provided.
  } // End of static main.
 @Scheduled(fixedDelay = SCHEDULED_CHECK)
 public void checkActiveClients() {
   Set<String> users = user_vidNameMap.keySet();
   Iterator<String> it = users.iterator();
   long time = System.currentTimeMillis();
   int count = 0;
   while (it.hasNext()) {
     count++;
     String user = it.next();
     if (user == null) continue;
     if (userAliveMap.containsKey(user)) {
       if (userAliveMap.get(user).longValue() < time) {
         removeUser(user);
         userAliveMap.remove(user);
       }
     } else {
       throw new RuntimeException("user in user-vid map but not in user-alive map");
     }
   }
   // System.out.println("Debug: Scheduled Check count:"+count+" user
   // count:"+user_vidNameMap.size());
   System.gc();
 }
예제 #5
0
파일: PerfTest.java 프로젝트: ETK/javersion
  private static void runJaversion(Integer[] data) {
    out.println("Javersion PersistentHashMap");
    PersistentHashMap<Integer, Integer> jmap = PersistentHashMap.empty();
    // warmup
    for (Integer v : data) {
      jmap = jmap.assoc(v, v);
    }
    jmap = null;
    System.gc();

    long begin = System.nanoTime();
    for (int i = 1; i <= data.length; i++) {
      start();
      jmap = PersistentHashMap.empty();
      for (int j = 0; j < i; j++) {
        jmap = jmap.assoc(data[j], data[j]);
      }
      for (int j = 0; j < i; j++) {
        jmap = jmap.dissoc(data[j]);
      }
      out.println(end());
    }
    out.println(String.format("\n%s", System.nanoTime() - begin));
  }
예제 #6
0
 public static void begin() {
   System.gc();
   start = JVM.monotonicTimeMillis();
 }
  public SampleResult runTest(JavaSamplerContext runTestContext) {
    String indexFileSystemPath = runTestContext.getParameter("indexfilesystem.path");

    String timeStamp =
        new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(Calendar.getInstance().getTime());
    resultObj.put("Date and Execution Time", timeStamp);

    resultObj.put("Execution Plan", "Sequential Performance of Indexes FS");
    try {
      resultObj.put("Host", InetAddress.getLocalHost().getHostAddress());
    } catch (UnknownHostException e) {
      e.printStackTrace();
    }

    SampleResult result = new SampleResult();

    try {
      result.sampleStart();
      preallocateTestFile(FILE_NAME);

      for (final PerfTestCase testCase : testCases) {
        JSONArray readDuration = new JSONArray();
        JSONArray bytesRead = new JSONArray();
        JSONArray bytesWrite = new JSONArray();
        for (int i = 0; i < 5; i++) {
          System.gc();
          long writeDurationMs = testCase.test(PerfTestCase.Type.WRITE, FILE_NAME);
          System.gc();
          long readDurationMs = testCase.test(PerfTestCase.Type.READ, FILE_NAME);
          long bytesReadPerSec = (FILE_SIZE * 1000L) / readDurationMs;
          long bytesWrittenPerSec = (FILE_SIZE * 1000L) / writeDurationMs;
          readDuration.add(readDurationMs);
          bytesRead.add(bytesReadPerSec);
          bytesWrite.add(bytesWrittenPerSec);

          out.format(
              "%s\twrite=%,d\tread=%,d bytes/sec\n",
              testCase.getName(), bytesWrittenPerSec, bytesReadPerSec);

          String output =
              out.format(
                      "%s\twrite=%,d\tread=%,d bytes/sec\n",
                      testCase.getName(), bytesWrittenPerSec, bytesReadPerSec)
                  .toString();
          result.setSamplerData(testCase.getName() + "-- IO RESULTS --- " + output);
          // resultIo.setSamplerData(testCase.getName() + "-- Writen Bytes per second:" +
          // bytesWrittenPerSec + "-- Read Bytes per second:" + bytesReadPerSec);
          result.addSubResult(result);
        }

        resultObj.put(testCase.getName(), readDuration);
        resultObj.put(testCase.getName(), bytesRead);
        resultObj.put(testCase.getName(), bytesWrite);
      }

      deleteFile(indexFileSystemPath + "/" + FILE_NAME);

      try {

        FileWriter file = new FileWriter(resultsDirectory + "/" + OUTPUT_JSON_FILE_NAME);
        file.write(resultObj.toJSONString());
        file.flush();
        file.close();

      } catch (IOException e) {
        e.printStackTrace();
      }

      result.sampleEnd();
      result.setSuccessful(true);
      logger.info("Successfully Tested Index Disk IO  at path: " + indexFileSystemPath);
      result.setResponseMessage("Successfully Tested IO at  Indexes Disk");
      result.setResponseCodeOK();
    } catch (Exception e) {
      result.sampleEnd();
      result.setSuccessful(false);
      result.setResponseMessage("Failed to TestIO: " + e);
      StringWriter stringWriter = new StringWriter();
      e.printStackTrace(new PrintWriter(stringWriter));
      result.setResponseData(stringWriter.toString().getBytes());
      result.setDataType(SampleResult.TEXT);
      result.setResponseCode("500");
    }
    return result;
  }
예제 #8
0
  // create a new profile: read the script and possibly execute the queries,
  // save the stats (if 'import' == true, we assume the profile already exists
  // and don't run the queries)
  public void createWkld(String name, String scriptFile, boolean runQueries) {
    System.gc();
    Workload wkld = new Workload(name);

    if (showCmdsItem.getState()) {
      consoleFrame.echoCmd((!runQueries ? "importprof " : "newwkld ") + name + " " + scriptFile);
    }

    // construct the Workload object from the script;
    // first, check if the file exists
    try {
      FileReader reader = new FileReader(scriptFile);
      reader.close();
    } catch (FileNotFoundException e) {
      System.out.println("couldn't open " + scriptFile);
      return;
    } catch (IOException e) {
      System.out.println("couldn't close " + scriptFile);
    }

    // now, check if it contains only queries
    int scriptId = 0;
    try {
      scriptId = Libgist.openScript(scriptFile);
    } catch (LibgistException e) {
      System.out.println("couldn't open (C) " + scriptFile);
      return;
    }
    char[] arg1 = new char[64 * 1024];
    StringBuffer arg1Buf = new StringBuffer();
    char[] arg2 = new char[64 * 1024];
    StringBuffer arg2Buf = new StringBuffer();
    // for (;;) {
    // int cmd = Libgist.getCommand(scriptId, arg1, arg2);
    // if (cmd == Libgist.EOF) break;
    // if (cmd != Libgist.FETCH) {
    // there should only be queries
    // System.out.println("Script file contains non-SELECT command");
    // return;
    // }
    // }

    if (runQueries) {
      // turn profiling on and execute queries
      // Libgist.setProfilingEnabled(true);
      Libgist.disableBps(true); // we don't want to stop at breakpoints

      // rescan queries
      try {
        scriptId = Libgist.openScript(scriptFile);
      } catch (LibgistException e) {
        System.out.println("couldn't open (C) " + scriptFile);
        return;
      }
      int cnt = 1;
      // for (;;) {
      // int cmd = Libgist.getCommand(scriptId, arg1, arg2);
      // if (cmd == Libgist.EOF) break;
      // arg1Buf.setLength(0);
      // arg1Buf.append(arg1, 0, strlen(arg1));
      // arg2Buf.setLength(0);
      // arg2Buf.append(arg2, 0, strlen(arg2));
      // OpThread.execCmd(LibgistCommand.FETCH, arg1Buf.toString(),
      // arg2Buf.toString(), false);
      // System.out.print(cnt + " ");
      // System.out.println(cnt + ": execute " + arg2Buf.toString() + " "
      // + arg1Buf.toString());
      // cnt++;
      // }
      System.out.println();

      Libgist.disableBps(false);
      // compute optimal clustering and some more statistics
      // Libgist.computeMetrics(wkld.filename);
    }

    // save profile
    try {
      // we're saving Java and C++ data in separate files (filename and filename.prof)
      // the profile object only contains the filename, the queries will be
      // read in from the file when the profile is opened (faster that way)
      ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(wkld.filename));
      out.writeObject(wkld);
      out.close();
      System.out.println("copy query file");
      Runtime.getRuntime().exec("cp " + scriptFile + " " + wkld.filename + ".queries");
      System.out.println("saving tree and profile");
      Libgist.saveToFile(wkld.filename + ".idx");
      if (runQueries) {
        // Libgist.saveProfile(wkld.filename + ".prof");
      }
    } catch (Exception e) {
      System.out.println("Error saving profile: " + e);
      return;
    }

    if (runQueries) {
      // turn profiling off (after the metrics were computed and
      // the profile saved)
      // Libgist.setProfilingEnabled(false);
    }
  }