Skip to content

Commit

Permalink
stresstool fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
FeiWongReed committed Apr 28, 2015
1 parent 3755251 commit 42f15b1
Show file tree
Hide file tree
Showing 23 changed files with 85 additions and 59 deletions.
2 changes: 1 addition & 1 deletion projects/test-utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ This can be done by following code:
StressScenario scenario = StressScenario.of(TimerResolution.NANOSECONDS);
StressResult result = scenario.measure(10, 400, new Action() {
@Override
protected void doAction(MeasureProvider p) throws Exception {
public void doAction(MeasureProvider p) throws Exception {
final Long value = p.invoke("code-block1", new Get<Long>() {
@Override
public Long get() throws Exception {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author <a href="mailto:ketoth.xupack@gmail.com">Ketoth Xupack</a>
* @since 2013-12-29 18:19
*/
class MeasureData {
public class MeasureData {
private final int concurrency;

private final int threadId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.nohope.test.stress;

import org.nohope.test.stress.action.Get;
import org.nohope.test.stress.action.Invoke;
import org.nohope.test.stress.functors.Get;
import org.nohope.test.stress.functors.Invoke;

import java.util.concurrent.ConcurrentMap;
import java.util.function.Function;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.nohope.test.stress;

import com.google.common.cache.LoadingCache;
import org.nohope.test.stress.action.Get;
import org.nohope.test.stress.action.Invoke;
import org.nohope.test.stress.functors.Get;
import org.nohope.test.stress.functors.Invoke;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import static java.util.Map.Entry;
import static java.util.concurrent.TimeUnit.*;
import static org.nohope.test.stress.TimeUtils.*;
import static org.nohope.test.stress.util.TimeUtils.*;

/**
* @author <a href="mailto:ketoth.xupack@gmail.com">ketoth xupack</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.nohope.test.stress;

import org.nohope.test.stress.actions.NamedAction;

/**
* @author <a href="mailto:ketoth.xupack@gmail.com">ketoth xupack</a>
* @since 2013-12-27 16:18
Expand All @@ -19,7 +21,6 @@ protected void invoke(final int threadId,
final MeasureData p = new MeasureData(threadId, operationNumber, getConcurrency());
this.invoke(threadId, () -> {
action.doAction(p);
return null;
});
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.nohope.test.stress;

import org.apache.commons.lang3.tuple.ImmutablePair;
import org.nohope.test.stress.action.Get;
import org.nohope.test.stress.action.Invoke;
import org.nohope.test.stress.functors.Get;
import org.nohope.test.stress.functors.Invoke;

import javax.annotation.Nonnull;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package org.nohope.test.stress;

import org.apache.commons.lang3.StringUtils;
import org.nohope.test.stress.util.Memory;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeSet;

import static java.util.concurrent.TimeUnit.SECONDS;
import static org.nohope.test.stress.TimeUtils.throughputTo;
import static org.nohope.test.stress.TimeUtils.timeTo;
import static org.nohope.test.stress.util.TimeUtils.throughputTo;
import static org.nohope.test.stress.util.TimeUtils.timeTo;

/**
* @author <a href="mailto:ketoth.xupack@gmail.com">ketoth xupack</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.nohope.test.stress.actions.Action;
import org.nohope.test.stress.actions.NamedAction;
import org.nohope.test.stress.actions.PooledAction;
import org.nohope.test.stress.util.Memory;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.nohope.test.stress.actions;

import org.nohope.test.stress.MeasureData;

/**
* @author <a href="mailto:ketoth.xupack@gmail.com">Ketoth Xupack</a>
* @since 2013-12-27 23:55
*/
public abstract class AbstractAction<P extends MeasureData> {
public abstract void doAction(final P p) throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.nohope.test.stress.actions;

import org.nohope.test.stress.MeasureProvider;

/**
* @author <a href="mailto:ketoth.xupack@gmail.com">ketoth xupack</a>
* @since 2013-12-27 16:21
*/
public abstract class Action extends AbstractAction<MeasureProvider> {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package org.nohope.test.stress;
package org.nohope.test.stress.actions;

import org.nohope.test.stress.MeasureData;

/**
* @author <a href="mailto:ketoth.xupack@gmail.com">ketoth xupack</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package org.nohope.test.stress;
package org.nohope.test.stress.actions;

import org.nohope.test.stress.PooledMeasureProvider;

/**
* @author <a href="mailto:ketoth.xupack@gmail.com">ketoth xupack</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.nohope.test.stress.action;
package org.nohope.test.stress.functors;

/**
* @author <a href="mailto:ketoth.xupack@gmail.com">Ketoth Xupack</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.nohope.test.stress.action;
package org.nohope.test.stress.functors;

/**
* @author <a href="mailto:ketoth.xupack@gmail.com">Ketoth Xupack</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.nohope.test.stress;
package org.nohope.test.stress.util;

import static org.apache.commons.io.FileUtils.byteCountToDisplaySize;

/**
* @author <a href="mailto:ketoth.xupack@gmail.com">Ketoth Xupack</a>
* @since 2014-03-18 12:15
*/
class Memory {
public class Memory {
private final long maxMemory;
private final long totalMemory;
private final long freeMemory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.nohope.test.stress;
package org.nohope.test.stress.util;

import javax.annotation.Nonnull;
import java.util.concurrent.TimeUnit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.nohope.test.stress;
package org.nohope.test.stresstooltest;

import org.junit.Test;
import org.nohope.test.stress.util.Memory;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;

/**
* @author <a href="mailto:ketoth.xupack@gmail.com">Ketoth Xupack</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
package org.nohope.test.stress;
package org.nohope.test.stresstooltest;

import org.junit.Ignore;
import org.junit.Test;
import org.nohope.test.stress.MeasureData;
import org.nohope.test.stress.MeasureProvider;
import org.nohope.test.stress.PooledMeasureProvider;
import org.nohope.test.stress.Result;
import org.nohope.test.stress.StressResult;
import org.nohope.test.stress.StressScenario;
import org.nohope.test.stress.TimerResolution;
import org.nohope.test.stress.actions.Action;
import org.nohope.test.stress.actions.NamedAction;
import org.nohope.test.stress.actions.PooledAction;

import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;

import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.Assert.*;
import static org.nohope.test.stress.TimeUtils.throughputTo;
import static org.nohope.test.stress.util.TimeUtils.throughputTo;

/**
* @author <a href="mailto:ketoth.xupack@gmail.com">Ketoth Xupack</a>
Expand All @@ -23,7 +33,7 @@ public void roughTest() throws InterruptedException {
StressScenario.of(TimerResolution.MILLISECONDS)
.measure(50, 1000, new NamedAction("test1") {
@Override
protected void doAction(final MeasureData p)
public void doAction(final MeasureData p)
throws Exception {
Thread.sleep(10);
}
Expand All @@ -32,7 +42,7 @@ protected void doAction(final MeasureData p)
StressScenario.of(TimerResolution.NANOSECONDS)
.measure(50, 1000, new NamedAction("test2") {
@Override
protected void doAction(final MeasureData p)
public void doAction(final MeasureData p)
throws Exception {
Thread.sleep(10);
}
Expand All @@ -47,7 +57,7 @@ protected void doAction(final MeasureData p)
StressScenario.of(TimerResolution.MILLISECONDS)
.measure(50, 1000, new Action() {
@Override
protected void doAction(final MeasureProvider p)
public void doAction(final MeasureProvider p)
throws Exception {
p.call("test1", () -> Thread.sleep(10));
}
Expand All @@ -56,7 +66,7 @@ protected void doAction(final MeasureProvider p)
StressScenario.of(TimerResolution.NANOSECONDS)
.measure(50, 1000, new Action() {
@Override
protected void doAction(final MeasureProvider p)
public void doAction(final MeasureProvider p)
throws Exception {
p.call("test1", () -> Thread.sleep(10));
}
Expand All @@ -74,7 +84,7 @@ public void counts() throws InterruptedException {
StressScenario.of(TimerResolution.NANOSECONDS)
.measure(2, 100, new NamedAction("test") {
@Override
protected void doAction(final MeasureData p)
public void doAction(final MeasureData p)
throws Exception {
if (p.getOperationNumber() >= 100) {
//System.err.println(p.getOperationNumber());
Expand Down Expand Up @@ -125,7 +135,7 @@ protected void doAction(final MeasureData p)
StressScenario.of(TimerResolution.NANOSECONDS)
.measure(2, 100, new Action() {
@Override
protected void doAction(final MeasureProvider p)
public void doAction(final MeasureProvider p)
throws Exception {
p.call("test", () -> {
if (p.getOperationNumber() >= 100) {
Expand Down Expand Up @@ -165,7 +175,7 @@ protected void doAction(final MeasureProvider p)
StressScenario.of(TimerResolution.MILLISECONDS)
.measure(2, 100, new NamedAction("test") {
@Override
protected void doAction(final MeasureData p) throws Exception {
public void doAction(final MeasureData p) throws Exception {
Thread.sleep(10);
}
});
Expand All @@ -177,7 +187,7 @@ protected void doAction(final MeasureData p) throws Exception {
StressScenario.of(TimerResolution.MILLISECONDS)
.measure(2, 100, new Action() {
@Override
protected void doAction(final MeasureProvider p) throws Exception {
public void doAction(final MeasureProvider p) throws Exception {
p.call("test", () -> Thread.sleep(10));
}
});
Expand All @@ -189,7 +199,7 @@ protected void doAction(final MeasureProvider p) throws Exception {
StressScenario.of(TimerResolution.MILLISECONDS)
.measure(2, 100, new Action() {
@Override
protected void doAction(final MeasureProvider p) throws Exception {
public void doAction(final MeasureProvider p) throws Exception {
p.get("test", () -> {
Thread.sleep(10);
return null;
Expand All @@ -206,7 +216,7 @@ protected void doAction(final MeasureProvider p) throws Exception {
StressScenario.of(TimerResolution.MILLISECONDS)
.measurePooled(2, 100, 2, new PooledAction() {
@Override
protected void doAction(final PooledMeasureProvider p) throws Exception {
public void doAction(final PooledMeasureProvider p) throws Exception {
p.invoke("test", () -> Thread.sleep(10));
}
});
Expand All @@ -219,7 +229,7 @@ protected void doAction(final PooledMeasureProvider p) throws Exception {
StressScenario.of(TimerResolution.MILLISECONDS)
.measurePooled(2, 100, 2, new PooledAction() {
@Override
protected void doAction(final PooledMeasureProvider p) throws Exception {
public void doAction(final PooledMeasureProvider p) throws Exception {
p.invoke("test", () -> {
Thread.sleep(10);
return null;
Expand All @@ -242,7 +252,7 @@ public void pooled() throws InterruptedException {
StressScenario.of(TimerResolution.NANOSECONDS)
.measure(500, 100, new Action() {
@Override
protected void doAction(final MeasureProvider p) throws Exception {
public void doAction(final MeasureProvider p) throws Exception {
p.get("test1", () -> {
long old;
for (; ; ) {
Expand All @@ -268,7 +278,7 @@ protected void doAction(final MeasureProvider p) throws Exception {
StressScenario.of(TimerResolution.MILLISECONDS)
.measurePooled(500, 100, 10, new PooledAction() {
@Override
protected void doAction(final PooledMeasureProvider p) throws Exception {
public void doAction(final PooledMeasureProvider p) throws Exception {
p.invoke("test1", () -> {
long old;
while (true) {
Expand All @@ -293,7 +303,7 @@ public void sortedOutput() throws InterruptedException {
final StressResult result =
StressScenario.of(TimerResolution.MILLISECONDS).measure(10, 1, new Action() {
@Override
protected void doAction(final MeasureProvider p) throws Exception {
public void doAction(final MeasureProvider p) throws Exception {
p.call("action4", () -> {
});
p.call("action1", () -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package org.nohope.test.stress;
package org.nohope.test.stresstooltest;

import org.junit.Test;
import org.nohope.test.UtilityClassUtils;
import org.nohope.test.stress.util.TimeUtils;

import java.util.concurrent.TimeUnit;

import static org.junit.Assert.assertEquals;
import static org.nohope.test.stress.TimeUtils.throughputTo;
import static org.nohope.test.stress.TimeUtils.timeTo;
import static org.nohope.test.stress.util.TimeUtils.throughputTo;
import static org.nohope.test.stress.util.TimeUtils.timeTo;

/**
* @author <a href="mailto:ketoth.xupack@gmail.com">Ketoth Xupack</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package org.nohope.test.stress;
package org.nohope.test.stresstooltest;

import org.junit.Test;
import org.nohope.test.EnumUtils;
import org.nohope.test.stress.TimerResolution;

/**
* @author <a href="mailto:ketoth.xupack@gmail.com">Ketoth Xupack</a>
Expand Down

0 comments on commit 42f15b1

Please sign in to comment.