Skip to content

Commit 37ca88f

Browse files
committed
async-profiler 4.0 (fix style)
1 parent ceb72d8 commit 37ca88f

File tree

1 file changed

+53
-47
lines changed

1 file changed

+53
-47
lines changed

Formula/a/async-profiler.rb

Lines changed: 53 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,56 @@
11
class AsyncProfiler < Formula
2-
desc "Sampling CPU and HEAP profiler for Java featuring AsyncGetCallTrace + perf_events"
3-
homepage "https://github.com/async-profiler/async-profiler"
4-
url "https://github.com/async-profiler/async-profiler/archive/refs/tags/v4.0.tar.gz"
5-
version "4.0"
6-
sha256 "7beb736868af485d6b0b624e42141f78df0ca8403188adc17965b7153261aa55"
7-
license "Apache-2.0"
8-
head "https://github.com/async-profiler/async-profiler.git", branch: "master"
9-
10-
depends_on "cmake" => :build
11-
depends_on "openjdk" => :test
12-
13-
def install
14-
args = []
15-
args << "COMMIT_TAG=#{Utils.git_head}" if build.head?
16-
args << "FAT_BINARY=true" if OS.mac?
17-
# args << "CC=/usr/local/musl/bin/musl-gcc" if OS.linux?
18-
19-
system "make", *args, "all"
20-
21-
bin.install Dir["build/bin/*"]
22-
lib.install Dir["build/lib/*"]
23-
libexec.install Dir["build/jar/*"]
24-
end
25-
26-
test do
27-
assert_match "Async-profiler #{version}", shell_output("#{bin}/asprof --version")
28-
29-
(testpath/"Main.java").write <<~JAVA
30-
public class Main {
31-
public static void main(String[] args) throws Exception {
32-
Thread.sleep(8_000);
33-
}
2+
desc "Sampling CPU & HEAP profiler for Java using AsyncGetCallTrace + perf_events"
3+
homepage "https://github.com/async-profiler/async-profiler"
4+
url "https://github.com/async-profiler/async-profiler/archive/refs/tags/v4.0.tar.gz"
5+
sha256 "7beb736868af485d6b0b624e42141f78df0ca8403188adc17965b7153261aa55"
6+
license "Apache-2.0"
7+
head "https://github.com/async-profiler/async-profiler.git", branch: "master"
8+
9+
depends_on "cmake" => :build
10+
depends_on "openjdk" => :test
11+
12+
def install
13+
args = []
14+
args << "COMMIT_TAG=#{Utils.git_head}" if build.head?
15+
args << "FAT_BINARY=true" if OS.mac?
16+
# args << "CC=/usr/local/musl/bin/musl-gcc" if OS.linux?
17+
18+
system "make", *args, "all"
19+
20+
bin.install Dir["build/bin/*"]
21+
lib.install Dir["build/lib/*"]
22+
libexec.install Dir["build/jar/*"]
23+
end
24+
25+
test do
26+
assert_match "Async-profiler #{version}", shell_output("#{bin}/asprof --version")
27+
28+
(testpath/"Main.java").write <<~JAVA
29+
public class Main {
30+
public static void main(String[] args) throws Exception {
31+
Thread.sleep(8_000);
3432
}
35-
JAVA
36-
37-
pid = spawn Formula["openjdk"].bin/"java", testpath/"Main.java"
38-
system bin/"asprof", "-d", "2", "-f", testpath/"test-profile-via-attach.html", "jps"
39-
assert_predicate testpath/"test-profile-via-attach.html", :exist?
40-
41-
system Formula["openjdk"].bin/"java", "-agentpath:#{lib}/libasyncProfiler.dylib=start,event=cpu,lock=10ms,file=test-profile-via-lib.jfr", testpath/"Main.java"
42-
assert_predicate testpath/"test-profile-via-lib.jfr", :exist?
43-
44-
system bin/"jfrconv", "-o", "pprof", testpath/"test-profile-via-lib.jfr", testpath/"test-profile-via-lib.pprof"
45-
assert_predicate testpath/"test-profile-via-lib.pprof", :exist?
46-
ensure
47-
Process.kill("TERM", pid)
48-
end
33+
}
34+
JAVA
35+
36+
pid = spawn Formula["openjdk"].bin/"java", testpath/"Main.java"
37+
system bin/"asprof",
38+
"-d", "2",
39+
"-f", testpath/"test-profile-via-attach.html",
40+
"jps"
41+
assert_path_exists testpath/"test-profile-via-attach.html"
42+
43+
system Formula["openjdk"].bin/"java",
44+
"-agentpath:#{lib}/libasyncProfiler.dylib=start,event=cpu,lock=10ms,file=test-profile-via-lib.jfr",
45+
testpath/"Main.java"
46+
assert_path_exists testpath/"test-profile-via-lib.jfr"
47+
48+
system bin/"jfrconv",
49+
"-o", "pprof",
50+
testpath/"test-profile-via-lib.jfr",
51+
testpath/"test-profile-via-lib.pprof"
52+
assert_path_exists testpath/"test-profile-via-lib.pprof"
53+
ensure
54+
Process.kill("TERM", pid)
4955
end
50-
56+
end

0 commit comments

Comments
 (0)