Skip to content

Commit

Permalink
8332980: [IR Framework] Add option to measure IR rule processing time
Browse files Browse the repository at this point in the history
Reviewed-by: kvn, chagedorn
  • Loading branch information
Theo Weidmann authored and chhagedorn committed Jan 27, 2025
1 parent b8c68c0 commit 175e58b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions test/hotspot/jtreg/compiler/lib/ir_framework/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ The framework provides various stress and debug flags. They should mainly be use
- `-DVerbose=true`: Enable more fain-grained logging (slows the execution down).
- `-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).
- `-DPrintTimes=true`: Print the execution time measurements of each executed test.
- `-DPrintRuleMatchingTime=true`: Print the time of matching IR rules per method. Slows down the execution as the rules are warmed up before meassurement.
- `-DVerifyVM=true`: The framework runs the test VM with additional verification flags (slows the execution down).
- `-DExcluceRandom=true`: The framework randomly excludes some methods from compilation. IR verification is disabled completely with this flag.
- `-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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -148,6 +148,7 @@ public class TestFramework {
);

public static final boolean VERBOSE = Boolean.getBoolean("Verbose");
public static final boolean PRINT_RULE_MATCHING_TIME = Boolean.getBoolean("PrintRuleMatchingTime");
public static final boolean TESTLIST = !System.getProperty("Test", "").isEmpty();
public static final boolean EXCLUDELIST = !System.getProperty("Exclude", "").isEmpty();
private static final boolean REPORT_STDOUT = Boolean.getBoolean("ReportStdout");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -39,6 +39,8 @@
import java.util.ArrayList;
import java.util.List;

import static compiler.lib.ir_framework.TestFramework.PRINT_RULE_MATCHING_TIME;

/**
* This class represents a {@link Test @Test} annotated method that has an associated non-empty list of applicable
* {@link IR @IR} rules.
Expand Down Expand Up @@ -83,6 +85,20 @@ public String name() {
*/
@Override
public MatchResult match() {
return new IRMethodMatchResult(method, matcher.match());
if (!PRINT_RULE_MATCHING_TIME) {
return new IRMethodMatchResult(method, matcher.match());
}

List<MatchResult> match;
for (int i = 0; i < 10; i++) { // warm up
match = matcher.match();
}

long startTime = System.nanoTime();
match = matcher.match();
long endTime = System.nanoTime();
long duration = (endTime - startTime);
System.out.println("Verifying IR rules for " + name() + ": " + duration + " ns = " + (duration / 1000000) + " ms");
return new IRMethodMatchResult(method, match);
}
}

0 comments on commit 175e58b

Please sign in to comment.