-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.13.3 - Fix a mistaken test data property changein the previous comm…
…it. Add some performance test.
- Loading branch information
1 parent
fecc691
commit ad33795
Showing
8 changed files
with
181 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
Binary file not shown.
Binary file not shown.
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
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,57 @@ | ||
package twg2.text.benchmark; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
|
||
import twg2.text.stringSearch.StringIndex; | ||
|
||
/** | ||
* @author TeamworkGuy2 | ||
* @since 2019-10-03 | ||
*/ | ||
public class StringIndexPerf { | ||
public List<String> strs = Arrays.asList( | ||
"Alpha", "", "alphA", "-==-AAA-==-", "none", "----------", "AAAAAAAAAA", "longer-than-normal-string-of-long-length-a", "1234567890-with-another-A-", "java.util.Arrays", | ||
"null", "[]", "Calm", "+==+ZZZ+==+", "none", "========", "**********=[]=**********", "abcdefghijklmnopqrstuvwxyz--A--", "abcdefghijklmnopqrstuvwxyz--Z--", "java.util.List" | ||
); | ||
public int loops = 10000; | ||
|
||
|
||
@Test | ||
public void indexOfTwg2() { | ||
int res = 0; | ||
|
||
for(int i = 0; i < loops; i++) { | ||
int sub = 0; | ||
for(int j = 0, size = strs.size(); j < size; j++) { | ||
sub += StringIndex.indexOf(strs.get(j), 0, "A") + (j < size - 1 ? StringIndex.indexOf(strs.get(j + 1), 0, '-') : 0); | ||
} | ||
if(i % 3 == 0 || i % 5 == 0) { | ||
res += sub; | ||
} | ||
} | ||
|
||
System.out.println(res); | ||
} | ||
|
||
|
||
@Test | ||
public void indexOfJava() { | ||
int res = 0; | ||
|
||
for(int i = 0; i < loops; i++) { | ||
int sub = 0; | ||
for(int j = 0, size = strs.size(); j < size; j++) { | ||
sub += strs.get(j).indexOf("A") + (j < size - 1 ? strs.get(j + 1).indexOf('-') : 0); | ||
} | ||
if(i % 3 == 0 || i % 5 == 0) { | ||
res += sub; | ||
} | ||
} | ||
|
||
System.out.println(res); | ||
} | ||
|
||
} |
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,57 @@ | ||
package twg2.text.benchmark; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
|
||
import twg2.text.stringUtils.StringReplace; | ||
|
||
/** | ||
* @author TeamworkGuy2 | ||
* @since 2019-10-03 | ||
*/ | ||
public class StringReplacePerf { | ||
public List<String> strs = Arrays.asList( | ||
"Alpha", "", "alphA", "-==-AAA-==-", "none", "----------", "AAAAAAAAAA", "longer-than-normal-string-of-long-length-a", "1234567890-with-another-A-", "java.util.Arrays", | ||
"null", "[]", "Calm", "+==+ZZZ+==+", "none", "========", "**********=[]=**********", "abcdefghijklmnopqrstuvwxyz--A--", "abcdefghijklmnopqrstuvwxyz--Z--", "java.util.List" | ||
); | ||
public int loops = 10000; | ||
|
||
|
||
@Test | ||
public void replaceTwg2() { | ||
int res = 0; | ||
|
||
for(int i = 0; i < loops; i++) { | ||
int sub = 0; | ||
for(int j = 0, size = strs.size(); j < size; j++) { | ||
sub += StringReplace.replace(StringReplace.replace(strs.get(j), "-a", "-A"), "A", "B").hashCode() - (j < size - 1 ? StringReplace.replace(strs.get(j + 1), "A", "B").hashCode() : 0); | ||
} | ||
if(i % 3 == 0 || i % 5 == 0) { | ||
res += sub; | ||
} | ||
} | ||
|
||
System.out.println(res); | ||
} | ||
|
||
|
||
@Test | ||
public void replaceJava() { | ||
int res = 0; | ||
|
||
for(int i = 0; i < loops; i++) { | ||
int sub = 0; | ||
for(int j = 0, size = strs.size(); j < size; j++) { | ||
sub += strs.get(j).replace("-a", "-A").replace("A", "B").hashCode() - (j < size - 1 ? strs.get(j + 1).replace("A", "B").hashCode() : 0); | ||
} | ||
if(i % 3 == 0 || i % 5 == 0) { | ||
res += sub; | ||
} | ||
} | ||
|
||
System.out.println(res); | ||
} | ||
|
||
} |
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,57 @@ | ||
package twg2.text.benchmark; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
|
||
import twg2.text.stringUtils.StringSplit; | ||
|
||
/** | ||
* @author TeamworkGuy2 | ||
* @since 2019-10-03 | ||
*/ | ||
public class StringSplitPerf { | ||
public List<String> strs = Arrays.asList( | ||
"Alpha", "", "alphA", "-==-AAA-==-", "none", "----------", "AAAAAAAAAA", "longer-than-normal-string-of-long-length-a", "1234567890-with-another-A-", "java.util.Arrays", | ||
"null", "[]", "Calm", "+==+ZZZ+==+", "none", "========", "**********=[]=**********", "abcdefghijklmnopqrstuvwxyz--A--", "abcdefghijklmnopqrstuvwxyz--Z--", "java.util.List" | ||
); | ||
public int loops = 10000; | ||
|
||
|
||
@Test | ||
public void splitTwg2() { | ||
int res = 0; | ||
|
||
for(int i = 0; i < loops; i++) { | ||
int sub = 0; | ||
for(int j = 0, size = strs.size(); j < size; j++) { | ||
sub += StringSplit.split(strs.get(j), "A", 3).length - (j < size - 1 ? StringSplit.split(strs.get(j + 1), '-').size() : 0); | ||
} | ||
if(i % 3 == 0 || i % 5 == 0) { | ||
res += sub; | ||
} | ||
} | ||
|
||
System.out.println(res); | ||
} | ||
|
||
|
||
@Test | ||
public void splitJava() { | ||
int res = 0; | ||
|
||
for(int i = 0; i < loops; i++) { | ||
int sub = 0; | ||
for(int j = 0, size = strs.size(); j < size; j++) { | ||
sub += strs.get(j).split("A", 3).length - (j < size - 1 ? strs.get(j + 1).split("-", -1).length : 0); | ||
} | ||
if(i % 3 == 0 || i % 5 == 0) { | ||
res += sub; | ||
} | ||
} | ||
|
||
System.out.println(res); | ||
} | ||
|
||
} |
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