Skip to content

Commit

Permalink
0.13.3 - Fix a mistaken test data property changein the previous comm…
Browse files Browse the repository at this point in the history
…it. Add some performance test.
  • Loading branch information
TeamworkGuy2 committed Oct 4, 2019
1 parent fecc691 commit ad33795
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 3 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ This project does its best to adhere to [Semantic Versioning](http://semver.org/


--------
### [0.13.2](N/A) - 2019-09-30
### [0.13.3](N/A) - 2019-10-03
#### Changed
* Fix accidental test class property name change in previous commit
* First `twg2.text.benchmark` tests added


--------
### [0.13.2](https://github.com/TeamworkGuy2/JTextUtil/commit/fecc69175e8b8bab7319ee659457ff6d50c27e17) - 2019-09-30
#### Added
* `StringSplit.split(String, char, int)`
* Additional unit tests
Expand Down
Binary file modified bin/jtext_util-with-tests.jar
Binary file not shown.
Binary file modified bin/jtext_util.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion package-lib.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version" : "0.13.2",
"version" : "0.13.3",
"name" : "jtext-util",
"description" : "String search, replace, and transform functions that provide more control, at the trade-off of verbosity, than those already in the Java API",
"homepage" : "https://github.com/TeamworkGuy2/JTextUtil",
Expand Down
57 changes: 57 additions & 0 deletions test/twg2/text/benchmark/StringIndexPerf.java
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);
}

}
57 changes: 57 additions & 0 deletions test/twg2/text/benchmark/StringReplacePerf.java
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);
}

}
57 changes: 57 additions & 0 deletions test/twg2/text/benchmark/StringSplitPerf.java
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);
}

}
2 changes: 1 addition & 1 deletion test/twg2/text/test/DataUnescapePartialQuoted.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class DataUnescapePartialQuoted {


/** The index of the last ending character (i.e. if the string is a quoted string followed by an ending char, return the index of the ending char, not the closing quote */
public static List<Integer> _expectedIndexesIncludingTrueEndingChar = Arrays.asList(
public static List<Integer> expectedIndexesIncludingTrueEndingChar = Arrays.asList(
inputs.get(0).lastIndexOf("\"") + 1,
inputs.get(1).lastIndexOf(','),
inputs.get(2).lastIndexOf(','),
Expand Down

0 comments on commit ad33795

Please sign in to comment.