-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLDR-17342 speedup CoverageLevel2 construction
- use CLDRLocale instead of LanguageTagParser - about a 3x speedup for construct + 1 lookup
- Loading branch information
Showing
2 changed files
with
33 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
tools/cldr-code/src/test/java/org/unicode/cldr/util/TestCoverageLevel2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.unicode.cldr.util; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.unicode.cldr.test.CoverageLevel2; | ||
|
||
public class TestCoverageLevel2 { | ||
|
||
final int ITERATIONS = 100000; // keep this low for normal testing | ||
|
||
private static SupplementalDataInfo sdi; | ||
|
||
@BeforeAll | ||
private static void setup() { | ||
sdi = CLDRConfig.getInstance().getSupplementalDataInfo(); | ||
CoverageLevel2 c = CoverageLevel2.getInstance(sdi, "fr_CA"); | ||
} | ||
|
||
@Test | ||
public void TestCoveragePerf() { | ||
for (int i = 0; i < ITERATIONS; i++) { | ||
CoverageLevel2 c = CoverageLevel2.getInstance(sdi, "fr_CA"); | ||
assertEquals( | ||
Level.MODERATE, | ||
c.getLevel( | ||
"//ldml/characters/parseLenients[@scope=\"number\"][@level=\"lenient\"]/parseLenient[@sample=\",\"]")); | ||
} | ||
} | ||
} |