Skip to content

Commit

Permalink
refactored package layout
Browse files Browse the repository at this point in the history
added list-variable and range-variable support


git-svn-id: http://developer.marklogic.com/svn/performance-meters/trunk@746 e04f4502-82db-0310-b1af-f799f365da79
  • Loading branch information
Mike committed Dec 7, 2007
1 parent c8c9b0d commit 12405f5
Show file tree
Hide file tree
Showing 22 changed files with 312 additions and 86 deletions.
2 changes: 1 addition & 1 deletion src/build.xml
Expand Up @@ -24,7 +24,7 @@
<target name="build"
description="Compile main source tree java files">
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}" target="1.4">
<javac destdir="${build.dir}" target="1.5">
<src path="${src.dir}"/>
<classpath refid="master-classpath"/>
</javac>
Expand Down
33 changes: 18 additions & 15 deletions src/java/com/marklogic/performance/Configuration.java
Expand Up @@ -25,6 +25,9 @@

import com.marklogic.xdmp.XDMPConnection;

import com.marklogic.performance.reporter.Reporter;
import com.marklogic.performance.reporter.XMLReporter;

public class Configuration {

/**
Expand All @@ -40,7 +43,8 @@ public class Configuration {
/**
*
*/
public static final String REPORTER_DEFAULT = "XMLReporter";
public static final String REPORTER_DEFAULT = XMLReporter.class
.getCanonicalName();

/**
*
Expand Down Expand Up @@ -156,7 +160,8 @@ public class Configuration {

public Configuration(String[] paths, boolean loadSystemProperties)
throws IOException {
// set up the initial object using a set of paths, plus system properties
// set up the initial object using a set of paths, plus system
// properties
// if the user wants to supply more properties,
// the load() method is public.
props = new Properties();
Expand All @@ -171,8 +176,7 @@ public Configuration(String[] paths, boolean loadSystemProperties)
load(System.getProperties());
}
}



// for unit testing
public Configuration(Properties _props) {
props = new Properties();
Expand Down Expand Up @@ -290,9 +294,8 @@ public void load(Properties _props) {
// System.err.println("reporterClassName = " + reporterClassName);

if (reporterClassName.indexOf('.') < 1) {
// prepend this class's package name
reporterClassName = Configuration.class.getPackage()
.getName()
// prepend the reporter package name
reporterClassName = Reporter.class.getPackage().getName()
+ "." + reporterClassName;
}

Expand Down Expand Up @@ -341,23 +344,23 @@ public String configString() {
+ recordResults + " -DtestType=" + testType;
}

String getHost() {
public String getHost() {
if (host == null) {
return null;
}

if (host.length < 2) {
return host[0];
}
// round-robin across available hosts
return host[hostIndex++ % host.length];
}

String getUser() {
public String getUser() {
return user;
}

String getPassword() {
public String getPassword() {
return password;
}

Expand All @@ -373,19 +376,19 @@ int getNumThreads() {
return numThreads;
}

int getPort() {
public int getPort() {
return port;
}

boolean isReportTime() {
public boolean isReportTime() {
return reportTime;
}

long getRandomSeed() {
public long getRandomSeed() {
return randomSeed;
}

boolean getRecordResults() {
public boolean getRecordResults() {
return recordResults;
}

Expand Down
51 changes: 51 additions & 0 deletions src/java/com/marklogic/performance/ListVariable.java
@@ -0,0 +1,51 @@
/**
* Copyright (c) 2007 Mark Logic Corporation. All rights reserved.
*/
package com.marklogic.performance;

import com.marklogic.xcc.types.XName;
import com.marklogic.xcc.types.XdmValue;
import com.marklogic.xcc.types.XdmVariable;

/**
* @author Michael Blakeley, michael.blakeley@marklogic.com
*
*/
public class ListVariable implements XdmVariable {

private XName xname;
private XdmValue[] xvalues;

/**
* @param name
* @param namespace
* @param type
* @param values
*/
public ListVariable(String name, String namespace, String type,
String[] values) {
xname = new XName(namespace, name);
xvalues = new XdmValue[values.length];
// copy the input values
for (int i = 0; i < values.length; i++) {
xvalues[i] = XMLFileTest.newValue(type, values[i]);
}
}

/* (non-Javadoc)
* @see com.marklogic.xcc.types.XdmVariable#getName()
*/
public XName getName() {
return xname;
}

/* (non-Javadoc)
* @see com.marklogic.xcc.types.XdmVariable#getValue()
*/
public XdmValue getValue() {
// return a random value from the sequence
// TODO also allow sequential values?
return xvalues[(int)(Math.random() * xvalues.length)];
}

}
10 changes: 9 additions & 1 deletion src/java/com/marklogic/performance/PerformanceMeters.java
Expand Up @@ -27,6 +27,14 @@
import java.util.Date;
import java.util.List;

import com.marklogic.performance.reporter.ReporterException;
import com.marklogic.performance.reporter.Reporter;
import com.marklogic.performance.sampler.HTTPSampler;
import com.marklogic.performance.sampler.Sampler;
import com.marklogic.performance.sampler.URISampler;
import com.marklogic.performance.sampler.XCCSampler;
import com.marklogic.performance.sampler.XDBCSampler;

/**
* @author Ron Avnur, ron.avnur@marklogic.com
* @author Michael Blakeley, michael.blakeley@marklogic.com
Expand Down Expand Up @@ -64,7 +72,6 @@ public static void main(String args[]) throws Exception {
// use reflection to create the reporter, for output
Class<? extends Reporter> reporterClass = Class
.forName(config.getReporterClassName()).asSubclass(Reporter.class);
// System.err.println("reporter class: " + reporterClass.getName());
Constructor<? extends Reporter> reporterConstructor = reporterClass
.getConstructor(new Class[0]);
reporter = reporterConstructor.newInstance(new Object[0]);
Expand Down Expand Up @@ -123,6 +130,7 @@ void run() throws Exception {
ti = new OffsetTestIterator(tests, i * offsetPerThread);
}

// TODO use reflection instead?
if (config.isHTTP()) {
sampler = new HTTPSampler(ti, config);
} else if (config.isURI()) {
Expand Down
80 changes: 80 additions & 0 deletions src/java/com/marklogic/performance/RangeVariable.java
@@ -0,0 +1,80 @@
/**
* Copyright (c) 2007 Mark Logic Corporation. All rights reserved.
*/
package com.marklogic.performance;

import com.marklogic.xcc.ValueFactory;
import com.marklogic.xcc.exceptions.UnimplementedFeatureException;
import com.marklogic.xcc.types.ValueType;
import com.marklogic.xcc.types.XName;
import com.marklogic.xcc.types.XSDouble;
import com.marklogic.xcc.types.XSInteger;
import com.marklogic.xcc.types.XdmValue;
import com.marklogic.xcc.types.XdmVariable;

/**
* @author Michael Blakeley, michael.blakeley@marklogic.com
*
*/
public class RangeVariable implements XdmVariable {

private XName xname;

private XdmValue xMin;

private XdmValue xMax;

private String type;

/**
* @param name
* @param namespace
* @param type
* @param minValue
* @param maxValue
*/
public RangeVariable(String name, String namespace, String type,
String minValue, String maxValue) {
// TODO Auto-generated constructor stub
xname = new XName(namespace, name);
// prepare min, max values
xMin = XMLFileTest.newValue(type, minValue);
xMax = XMLFileTest.newValue(type, maxValue);
this.type = type;
}

/*
* (non-Javadoc)
*
* @see com.marklogic.xcc.types.XdmVariable#getName()
*/
public XName getName() {
return xname;
}

/*
* (non-Javadoc)
*
* @see com.marklogic.xcc.types.XdmVariable#getValue()
*/
public XdmValue getValue() {
if (xMin instanceof XSInteger) {
long min = ((XSInteger) xMin).asPrimitiveLong();
long range = ((XSInteger) xMax).asPrimitiveLong() - min;
return ValueFactory.newXSInteger(min
+ (long) (Math.random() * range));
}

if (xMin instanceof XSDouble) {
double min = ((XSDouble) xMin).asPrimitiveDouble();
double range = ((XSDouble) xMax).asPrimitiveDouble() - min;
return ValueFactory.newValue(ValueType.XS_DOUBLE, min
+ (Math.random() * range));
}

// TODO implement types as needed

throw new UnimplementedFeatureException(
"cannot use ranges of type " + type);
}
}
2 changes: 1 addition & 1 deletion src/java/com/marklogic/performance/Result.java
Expand Up @@ -165,7 +165,7 @@ public void setQueryResult(String res, boolean e) {
bytesReceived += res.length();
}

void print() {
public void print() {
System.out.println(queryResult);
}

Expand Down
2 changes: 2 additions & 0 deletions src/java/com/marklogic/performance/SummaryResults.java
Expand Up @@ -25,6 +25,8 @@
import java.util.List;
import java.util.Vector;

import com.marklogic.performance.sampler.Sampler;

/**
* @author Michael Blakeley, michael.blakeley@marklogic.com
*
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c)2005-2006 Mark Logic Corporation
* Copyright (c)2005-2007 Mark Logic Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,11 +18,13 @@
*/
package com.marklogic.performance;

import java.io.IOException;

/**
* @author Michael Blakeley, michael.blakeley@marklogic.com
*
*/
public class UnknownResultFieldException extends ReporterException {
public class UnknownResultFieldException extends IOException {

/**
* @param message
Expand Down

0 comments on commit 12405f5

Please sign in to comment.