Skip to content

Commit

Permalink
Revert "Added profiling for FormatterStepImpl and StepEqualityTester."
Browse files Browse the repository at this point in the history
This reverts commit 2b4f0dc1dd963082386016112ff929a392112e71.
  • Loading branch information
nedtwigg committed Jan 5, 2017
1 parent 7160b1c commit b8dbd8b
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 46 deletions.
2 changes: 0 additions & 2 deletions lib-extra/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ apply from: rootProject.file('gradle/java-setup.gradle')
apply from: rootProject.file('gradle/java-publish.gradle')

dependencies {
// temporary, for profiling
compile 'com.diffplug.durian:durian-debug:1.0.0'
compile project(':lib')
// misc useful utilities
compile "com.diffplug.durian:durian-core:${VER_DURIAN}"
Expand Down
2 changes: 0 additions & 2 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ apply from: rootProject.file('gradle/java-setup.gradle')
apply from: rootProject.file('gradle/java-publish.gradle')

dependencies {
// temporary, for profiling
compile 'com.diffplug.durian:durian-debug:1.0.0'
// zero runtime reqs is a hard requirements for spotless-lib
// if you need a dep, put it in lib-extra
testCompile "junit:junit:${VER_JUNIT}"
Expand Down
5 changes: 0 additions & 5 deletions lib/src/main/java/com/diffplug/spotless/Formatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,8 @@

import javax.annotation.Nullable;

import com.diffplug.common.debug.LapTimer;
import com.diffplug.common.debug.StepProfiler;

/** Formatter which performs the full formatting. */
public final class Formatter {
public static final StepProfiler PROFILER = new StepProfiler(LapTimer.createNanoWrap2Sec());

private final LineEnding.Policy lineEndingsPolicy;
private final Charset encoding;
private final Path rootDir;
Expand Down
27 changes: 3 additions & 24 deletions lib/src/main/java/com/diffplug/spotless/FormatterStepImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,7 @@ public String getName() {

@Override
protected State calculateState() throws Exception {
try {
Formatter.PROFILER.startStep(name + " calculateKey");
return stateSupplier.get();
} finally {
Formatter.PROFILER.finish();
}
return stateSupplier.get();
}

static final class Standard<State extends Serializable> extends FormatterStepImpl<State> {
Expand All @@ -75,16 +70,9 @@ static final class Standard<State extends Serializable> extends FormatterStepImp
@Override
protected String format(State state, String rawUnix, File file) throws Exception {
if (formatter == null) {
Formatter.PROFILER.startStep(name + " createFormatter");
formatter = stateToFormatter.apply(state());
Formatter.PROFILER.finish();
}
try {
Formatter.PROFILER.startStep(name + " apply");
return formatter.apply(rawUnix);
} finally {
Formatter.PROFILER.finish();
}
return formatter.apply(rawUnix);
}
}

Expand All @@ -102,24 +90,15 @@ static class Closeable<State extends Serializable> extends FormatterStepImpl<Sta
@Override
protected String format(State state, String rawUnix, File file) throws Exception {
if (formatter == null) {
Formatter.PROFILER.startStep(name + " openFormatter");
formatter = stateToFormatter.apply(state());
Formatter.PROFILER.finish();
}
try {
Formatter.PROFILER.startStep(name + " apply");
return formatter.apply(rawUnix);
} finally {
Formatter.PROFILER.finish();
}
return formatter.apply(rawUnix);
}

@Override
public void finish() {
if (formatter != null) {
Formatter.PROFILER.startStep(name + " closeFormatter");
formatter.close();
Formatter.PROFILER.finish();
formatter = null;
}
}
Expand Down
2 changes: 0 additions & 2 deletions plugin-gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ apply plugin: 'com.gradle.plugin-publish'
apply plugin: 'java-gradle-plugin'

dependencies {
// temporary, for profiling
compile 'com.diffplug.durian:durian-debug:1.0.0'
compile project(':lib')
compile project(':lib-extra')
compile "com.diffplug.durian:durian-core:${VER_DURIAN}"
Expand Down
2 changes: 0 additions & 2 deletions testlib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ ext.version = project.versionLib
apply from: rootProject.file('gradle/java-setup.gradle')

dependencies {
// temporary, for profiling
compile 'com.diffplug.durian:durian-debug:1.0.0'
compile project(':lib')
compile "com.diffplug.durian:durian-core:${VER_DURIAN}"
compile "com.diffplug.durian:durian-io:${VER_DURIAN}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import java.util.List;

import com.diffplug.common.base.Box;
import com.diffplug.common.debug.LapTimer;
import com.diffplug.common.debug.StepProfiler;
import com.diffplug.common.testing.EqualsTester;

public abstract class StepEqualityTester {
Expand All @@ -36,17 +34,13 @@ public interface API {
void areDifferentThan();
}

public static final StepProfiler PROFILER = new StepProfiler(LapTimer.createNanoWrap2Sec());

public void testEquals() {
List<List<Object>> allGroups = new ArrayList<>();
Box<List<Object>> currentGroup = Box.of(new ArrayList<>());
API api = new API() {
@Override
public void assertThis() {
PROFILER.startStep("create");
currentGroup.get().add(create());
PROFILER.finish();
}

@Override
Expand All @@ -70,9 +64,6 @@ public void areDifferentThan() {
for (List<Object> step : allGroups) {
tester.addEqualityGroup(step.toArray());
}
PROFILER.startStep("equals");
tester.testEquals();
PROFILER.finish();
PROFILER.printResults();
}
}

0 comments on commit b8dbd8b

Please sign in to comment.