Skip to content

Commit 8200520

Browse files
Theo Weidmannpull[bot]
Theo Weidmann
authored andcommitted
8332980: [IR Framework] Add option to measure IR rule processing time
Reviewed-by: kvn, chagedorn
1 parent 2a2085c commit 8200520

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

test/hotspot/jtreg/compiler/lib/ir_framework/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ The framework provides various stress and debug flags. They should mainly be use
178178
- `-DVerbose=true`: Enable more fain-grained logging (slows the execution down).
179179
- `-DReproduce=true`: Flag to use when directly running a test VM to bypass dependencies to the driver VM state (for example, when reproducing an issue).
180180
- `-DPrintTimes=true`: Print the execution time measurements of each executed test.
181+
- `-DPrintRuleMatchingTime=true`: Print the time of matching IR rules per method. Slows down the execution as the rules are warmed up before meassurement.
181182
- `-DVerifyVM=true`: The framework runs the test VM with additional verification flags (slows the execution down).
182183
- `-DExcluceRandom=true`: The framework randomly excludes some methods from compilation. IR verification is disabled completely with this flag.
183184
- `-DFlipC1C2=true`: The framework compiles all `@Test` annotated method with C1 if a C2 compilation would have been applied and vice versa. IR verification is disabled completely with this flag.

test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -148,6 +148,7 @@ public class TestFramework {
148148
);
149149

150150
public static final boolean VERBOSE = Boolean.getBoolean("Verbose");
151+
public static final boolean PRINT_RULE_MATCHING_TIME = Boolean.getBoolean("PrintRuleMatchingTime");
151152
public static final boolean TESTLIST = !System.getProperty("Test", "").isEmpty();
152153
public static final boolean EXCLUDELIST = !System.getProperty("Exclude", "").isEmpty();
153154
private static final boolean REPORT_STDOUT = Boolean.getBoolean("ReportStdout");

test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irmethod/IRMethod.java

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -39,6 +39,8 @@
3939
import java.util.ArrayList;
4040
import java.util.List;
4141

42+
import static compiler.lib.ir_framework.TestFramework.PRINT_RULE_MATCHING_TIME;
43+
4244
/**
4345
* This class represents a {@link Test @Test} annotated method that has an associated non-empty list of applicable
4446
* {@link IR @IR} rules.
@@ -83,6 +85,20 @@ public String name() {
8385
*/
8486
@Override
8587
public MatchResult match() {
86-
return new IRMethodMatchResult(method, matcher.match());
88+
if (!PRINT_RULE_MATCHING_TIME) {
89+
return new IRMethodMatchResult(method, matcher.match());
90+
}
91+
92+
List<MatchResult> match;
93+
for (int i = 0; i < 10; i++) { // warm up
94+
match = matcher.match();
95+
}
96+
97+
long startTime = System.nanoTime();
98+
match = matcher.match();
99+
long endTime = System.nanoTime();
100+
long duration = (endTime - startTime);
101+
System.out.println("Verifying IR rules for " + name() + ": " + duration + " ns = " + (duration / 1000000) + " ms");
102+
return new IRMethodMatchResult(method, match);
87103
}
88104
}

0 commit comments

Comments
 (0)