Skip to content

Commit

Permalink
Code: Update FilterMatcherTest
Browse files Browse the repository at this point in the history
Merge Master
  • Loading branch information
GoldenGnu committed Apr 29, 2024
2 parents d8bfd1c + 025c956 commit 93f7472
Showing 1 changed file with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ public String toString() {
private Number numberColumn = null;
private Date dateColumn = null;
private Percent percentColumn = null;

private static final int BENCHMARK_ITERATIONS = 50000;

private static final String TEXT = "Text";
private static final String TEXT_FORMAT = "Text\"'-";
private static final String TEXT_PART = "Tex";
Expand Down Expand Up @@ -147,64 +150,70 @@ public void testTime() {
* @param args
*/
public static void main(final String[] args) {
initLog();
Images.preload();
FilterMatcherTest filterMatcherTest = new FilterMatcherTest();
filterMatcherTest.testEqualsSingle();
filterMatcherTest.testRexexSingle();
filterMatcherTest.testEqualsAll();
filterMatcherTest.testRexexAll();
filterMatcherTest.testRexexAll();
filterMatcherTest.testEqualsAll();
filterMatcherTest.testRexexSingle();
filterMatcherTest.testEqualsSingle();
long duration = 0;
duration += filterMatcherTest.testEqualsSingle();
duration += filterMatcherTest.testRexexSingle();
duration += filterMatcherTest.testEqualsAll();
duration += filterMatcherTest.testRexexAll();
duration += filterMatcherTest.testEqualsSingle();
duration += filterMatcherTest.testRexexSingle();
duration += filterMatcherTest.testEqualsAll();
duration += filterMatcherTest.testRexexAll();
}

private void testEqualsSingle() {
private long testEqualsSingle() {
long startTime = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) {
for (int i = 0; i < BENCHMARK_ITERATIONS; i++) {
//Equals
matches(true, TestEnum.TEXT, Filter.CompareType.EQUALS, TEXT);
matches(false, TestEnum.TEXT, Filter.CompareType.EQUALS, TEXT_PART);
matches(false, TestEnum.TEXT, Filter.CompareType.EQUALS, TEXT_NOT);
}
long endTime = System.currentTimeMillis();
System.out.println("Equals Single time:" + (endTime - startTime) + "ms");
return (endTime - startTime);
}

private void testRexexSingle() {
private long testRexexSingle() {
long startTime = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) {
for (int i = 0; i < BENCHMARK_ITERATIONS; i++) {
//Regex
matches(true, TestEnum.TEXT, Filter.CompareType.REGEX, TEXT);
matches(false, TestEnum.TEXT, Filter.CompareType.REGEX, TEXT_PART);
matches(true, TestEnum.TEXT, Filter.CompareType.REGEX, TEXT_PART);
matches(false, TestEnum.TEXT, Filter.CompareType.REGEX, TEXT_NOT);
}
long endTime = System.currentTimeMillis();
System.out.println("Rexex Single time:" + (endTime - startTime) + "ms");
return (endTime - startTime);
}

private void testEqualsAll() {
private long testEqualsAll() {
long startTime = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) {
for (int i = 0; i < BENCHMARK_ITERATIONS; i++) {
//Equals
matches(true, new AllColumn<>(), Filter.CompareType.EQUALS, TEXT);
matches(false, new AllColumn<>(), Filter.CompareType.EQUALS, TEXT_PART);
matches(false, new AllColumn<>(), Filter.CompareType.EQUALS, TEXT_NOT);
}
long endTime = System.currentTimeMillis();
System.out.println("Equals All time:" + (endTime - startTime) + "ms");
return (endTime - startTime);
}

private void testRexexAll() {
private long testRexexAll() {
long startTime = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) {
for (int i = 0; i < BENCHMARK_ITERATIONS; i++) {
//Regex
matches(true, TestEnum.TEXT, Filter.CompareType.REGEX, TEXT);
matches(false, TestEnum.TEXT, Filter.CompareType.REGEX, TEXT_PART);
matches(true, TestEnum.TEXT, Filter.CompareType.REGEX, TEXT_PART);
matches(false, TestEnum.TEXT, Filter.CompareType.REGEX, TEXT_NOT);
}
long endTime = System.currentTimeMillis();
System.out.println("Rexex All time:" + (endTime - startTime) + "ms");
return (endTime - startTime);
}

/**
Expand Down

0 comments on commit 93f7472

Please sign in to comment.