Skip to content

Commit d871819

Browse files
committed
Stylistic changes after async-profiler#1628
1 parent bf84fad commit d871819

File tree

5 files changed

+18
-25
lines changed

5 files changed

+18
-25
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ SOURCES := $(sort $(wildcard src/*.cpp))
6969
HEADERS := $(wildcard src/*.h)
7070
RESOURCES := $(wildcard src/res/*)
7171
JAVA_HELPER_CLASSES := $(wildcard src/helper/one/profiler/*.class)
72-
API_SOURCE_PATH := src/api/one/profiler
73-
API_SOURCES := $(wildcard $(API_SOURCE_PATH)/*.java)
72+
API_SOURCES := $(wildcard src/api/one/profiler/*.java)
73+
JAR_MANIFEST := src/api/one/profiler/MANIFEST.MF
7474
CONVERTER_SOURCES := $(shell find src/converter -name '*.java')
7575
TEST_SOURCES := $(shell find test -name '*.java' ! -path 'test/stubs/*')
7676
TESTS ?=
@@ -197,10 +197,10 @@ build/$(ASPROF_HEADER): src/asprof.h
197197
mkdir -p build/include
198198
cp -f $< build/include
199199

200-
build/$(API_JAR): $(API_SOURCES)
200+
build/$(API_JAR): $(API_SOURCES) $(JAR_MANIFEST)
201201
mkdir -p build/api
202202
$(JAVAC) $(JAVAC_OPTIONS) -d build/api $(API_SOURCES)
203-
$(JAR) cfm $@ $(API_SOURCE_PATH)/MANIFEST.MF -C build/api .
203+
$(JAR) cfm $@ $(JAR_MANIFEST) -C build/api .
204204
$(RM) -r build/api
205205

206206
build/$(CONVERTER_JAR): $(CONVERTER_SOURCES) $(RESOURCES)

src/api/one/profiler/Agent.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55

66
package one.profiler;
77

8-
import java.lang.management.ManagementFactory;
9-
108
import javax.management.ObjectName;
9+
import java.lang.management.ManagementFactory;
1110

1211
public class Agent {
1312

@@ -16,13 +15,12 @@ public static void premain(String args) throws Exception {
1615
}
1716

1817
public static void agentmain(String args) throws Exception {
19-
AsyncProfiler instance = AsyncProfiler.getInstance();
18+
AsyncProfiler profiler = AsyncProfiler.getInstance();
2019
ManagementFactory.getPlatformMBeanServer().registerMBean(
21-
instance,
20+
profiler,
2221
new ObjectName(AsyncProfilerMXBean.OBJECT_NAME));
2322
if (args != null && !args.isEmpty()) {
24-
instance.execute(args);
23+
profiler.execute(args);
2524
}
2625
}
27-
2826
}

src/api/one/profiler/AsyncProfilerMXBean.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* }</pre>
1818
*/
1919
public interface AsyncProfilerMXBean {
20-
public static final String OBJECT_NAME = "one.profiler:type=AsyncProfiler";
20+
String OBJECT_NAME = "one.profiler:type=AsyncProfiler";
2121

2222
void start(String event, long interval) throws IllegalStateException;
2323
void resume(String event, long interval) throws IllegalStateException;

test/test/api/ApiTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ public void metrics(TestProcess p) throws Exception {
4242
@Test(
4343
mainClass = JavaAgent.class,
4444
output = true,
45-
jvmArgs = "-javaagent:build/jar/async-profiler.jar=start,event=cpu,interval=1000000,file=%f.collapsed"
45+
jvmArgs = "-javaagent:build/jar/async-profiler.jar=start,event=cpu,interval=1ms,file=%f.collapsed"
4646
)
4747
public void javaAgent(TestProcess p) throws Exception {
4848
Output out = p.waitForExit(TestProcess.STDOUT);
4949
assert p.exitCode() == 0;
50-
assert out.contains("async-profiler version:");
50+
assert out.contains("async-profiler version: \\d+");
5151
Output profile = p.readFile("%f");
5252
assert profile.contains("BusyLoops.method1;");
5353
assert profile.contains("BusyLoops.method2;");

test/test/api/JavaAgent.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,25 @@
55

66
package test.api;
77

8-
import java.lang.management.ManagementFactory;
8+
import one.profiler.Counter;
99

10-
import javax.management.AttributeNotFoundException;
11-
import javax.management.InstanceNotFoundException;
12-
import javax.management.MBeanException;
13-
import javax.management.MalformedObjectNameException;
1410
import javax.management.MBeanServer;
1511
import javax.management.ObjectName;
16-
import javax.management.ReflectionException;
12+
import java.lang.management.ManagementFactory;
1713

18-
import one.profiler.Counter;
14+
public class JavaAgent {
1915

20-
public class JavaAgent extends BusyLoops {
2116
public static void main(String[] args) throws Exception {
2217
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
2318
ObjectName obj = new ObjectName("one.profiler:type=AsyncProfiler");
2419

2520
String version = (String) mbs.getAttribute(obj, "Version");
2621
System.out.println(String.format("async-profiler version: %s", version));
2722

28-
for (int i = 0; i < 5; i++) {
29-
method1();
30-
method2();
31-
method3();
23+
for (int i = 0; i < 3; i++) {
24+
BusyLoops.method1();
25+
BusyLoops.method2();
26+
BusyLoops.method3();
3227
}
3328

3429
String profile = (String) mbs.invoke(

0 commit comments

Comments
 (0)