You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2010/07/07 05:51:52 UTC
svn commit: r961091 - in /activemq/sandbox/activemq-apollo-actor:
activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/perf/
activemq-util/src/main/java/org/apache/activemq/util/
Author: chirino
Date: Wed Jul 7 03:51:52 2010
New Revision: 961091
URL: http://svn.apache.org/viewvc?rev=961091&view=rev
Log:
store perf stats to a csv file
Added:
activemq/sandbox/activemq-apollo-actor/activemq-util/src/main/java/org/apache/activemq/util/ProcessSupport.java
Modified:
activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/perf/BaseBrokerPerfSupport.scala
activemq/sandbox/activemq-apollo-actor/activemq-util/src/main/java/org/apache/activemq/util/IOHelper.java
Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/perf/BaseBrokerPerfSupport.scala
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/perf/BaseBrokerPerfSupport.scala?rev=961091&r1=961090&r2=961091&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/perf/BaseBrokerPerfSupport.scala (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/perf/BaseBrokerPerfSupport.scala Wed Jul 7 03:51:52 2010
@@ -26,13 +26,14 @@ import org.apache.activemq.transport.Tra
import _root_.scala.collection.JavaConversions._
import _root_.org.fusesource.hawtdispatch.ScalaDispatch._
import org.apache.activemq.broker.store.{Store, StoreFactory}
-import java.io.{File, IOException}
import java.util.ArrayList
import org.fusesource.hawtdispatch.BaseRetained
import java.util.concurrent.{CountDownLatch, TimeUnit}
import org.apache.activemq.apollo.broker._
import org.scalatest._
import _root_.org.fusesource.hawtbuf._
+import java.io.{PrintStream, FileOutputStream, File, IOException}
+import org.apache.activemq.util.ProcessSupport
object BaseBrokerPerfSupport {
var PERFORMANCE_SAMPLES = Integer.parseInt(System.getProperty("PERFORMANCE_SAMPLES", "3"))
@@ -124,17 +125,23 @@ abstract class BaseBrokerPerfSupport ext
}
}
-
- override protected def afterEach() = {
- println("Spread sheet stats:")
- println(spread_sheet_stats.map(_._1).mkString(","))
- println(spread_sheet_stats.map(_._2).mkString(","))
+ override protected def afterAll() = {
+ var basedir = new File(System.getProperty("user.home", "."))
+ var csvfile = new File(basedir, "perf-"+getClass.getName+".csv");
+ val exists = csvfile.exists
+ var out = new PrintStream(new FileOutputStream(csvfile, true));
+ val version = new String(ProcessSupport.system("git", "rev-list", "--max-count=1", "HEAD").toByteArray).trim
+ spread_sheet_stats ::= ("Version", version)
+ if( !exists ) {
+ out.println(spread_sheet_stats.map(x=>csv_esc(x._1)).mkString(","))
+ }
+ out.println(spread_sheet_stats.map(x=>csv_esc(x._2)).mkString(","))
+ out.close
+ println("Updated: "+csvfile);
}
- override protected def afterAll() = {
- println("Spread sheet stats:")
- println(spread_sheet_stats.map(_._1).mkString(","))
- println(spread_sheet_stats.map(_._2).mkString(","))
+ def csv_esc(value:Any) = {
+ "\""+value.toString.replace("\"", "\"\"")+"\""
}
def getBrokerWireFormat() = "multi"
Modified: activemq/sandbox/activemq-apollo-actor/activemq-util/src/main/java/org/apache/activemq/util/IOHelper.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-util/src/main/java/org/apache/activemq/util/IOHelper.java?rev=961091&r1=961090&r2=961091&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-util/src/main/java/org/apache/activemq/util/IOHelper.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-util/src/main/java/org/apache/activemq/util/IOHelper.java Wed Jul 7 03:51:52 2010
@@ -158,16 +158,33 @@ public final class IOHelper {
}
public static void copyInputStream(InputStream in, OutputStream out) throws IOException {
- byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
- int len = in.read(buffer);
- while (len >= 0) {
- out.write(buffer, 0, len);
- len = in.read(buffer);
+ try {
+ byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
+ int len = in.read(buffer);
+ while (len >= 0) {
+ out.write(buffer, 0, len);
+ len = in.read(buffer);
+ }
+ } finally {
+ close(in);
+ close(out);
}
- in.close();
- out.close();
}
-
+
+ public static void close(OutputStream out) {
+ try {
+ out.close();
+ } catch (IOException e) {
+ }
+ }
+
+ public static void close(InputStream in) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ }
+ }
+
static {
MAX_DIR_NAME_LENGTH = Integer.valueOf(System.getProperty("MaximumDirNameLength","200")).intValue();
MAX_FILE_NAME_LENGTH = Integer.valueOf(System.getProperty("MaximumFileNameLength","64")).intValue();
Added: activemq/sandbox/activemq-apollo-actor/activemq-util/src/main/java/org/apache/activemq/util/ProcessSupport.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-util/src/main/java/org/apache/activemq/util/ProcessSupport.java?rev=961091&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-util/src/main/java/org/apache/activemq/util/ProcessSupport.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-util/src/main/java/org/apache/activemq/util/ProcessSupport.java Wed Jul 7 03:51:52 2010
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.util;
+
+import org.fusesource.hawtbuf.Buffer;
+import org.fusesource.hawtbuf.ByteArrayOutputStream;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+
+/**
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+public class ProcessSupport {
+ static private ThreadLocal<Integer> EXIT_CODE = new ThreadLocal<Integer> ();
+
+ static public Buffer system(String...command) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ final Process process = Runtime.getRuntime().exec(command);
+ Thread pumper = pump(process.getErrorStream(), System.err);
+ IOHelper.copyInputStream(process.getInputStream(), baos);
+ pumper.join();
+ EXIT_CODE.set(process.waitFor());
+ } catch (Exception e) {
+ EXIT_CODE.set(-1);
+ }
+ return baos.toBuffer();
+ }
+
+ static public int lastExitCode() {
+ final Integer code = EXIT_CODE.get();
+ if( code == null )
+ return 0;
+ return code;
+ }
+
+
+ private static Thread pump(final InputStream in, final PrintStream out) {
+ Thread rc = new Thread(){
+ public void run() {
+ try {
+ IOHelper.copyInputStream(in, out);
+ } catch (IOException e) {
+ }
+ }
+ };
+ rc.start();
+ return rc;
+ }
+
+}