Skip to content

Commit ad33795

Browse files
committed
0.13.3 - Fix a mistaken test data property changein the previous commit. Add some performance test.
1 parent fecc691 commit ad33795

File tree

8 files changed

+181
-3
lines changed

8 files changed

+181
-3
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ This project does its best to adhere to [Semantic Versioning](http://semver.org/
44

55

66
--------
7-
### [0.13.2](N/A) - 2019-09-30
7+
### [0.13.3](N/A) - 2019-10-03
8+
#### Changed
9+
* Fix accidental test class property name change in previous commit
10+
* First `twg2.text.benchmark` tests added
11+
12+
13+
--------
14+
### [0.13.2](https://github.com/TeamworkGuy2/JTextUtil/commit/fecc69175e8b8bab7319ee659457ff6d50c27e17) - 2019-09-30
815
#### Added
916
* `StringSplit.split(String, char, int)`
1017
* Additional unit tests

bin/jtext_util-with-tests.jar

4.41 KB
Binary file not shown.

bin/jtext_util.jar

158 Bytes
Binary file not shown.

package-lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version" : "0.13.2",
2+
"version" : "0.13.3",
33
"name" : "jtext-util",
44
"description" : "String search, replace, and transform functions that provide more control, at the trade-off of verbosity, than those already in the Java API",
55
"homepage" : "https://github.com/TeamworkGuy2/JTextUtil",
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package twg2.text.benchmark;
2+
3+
import java.util.Arrays;
4+
import java.util.List;
5+
6+
import org.junit.Test;
7+
8+
import twg2.text.stringSearch.StringIndex;
9+
10+
/**
11+
* @author TeamworkGuy2
12+
* @since 2019-10-03
13+
*/
14+
public class StringIndexPerf {
15+
public List<String> strs = Arrays.asList(
16+
"Alpha", "", "alphA", "-==-AAA-==-", "none", "----------", "AAAAAAAAAA", "longer-than-normal-string-of-long-length-a", "1234567890-with-another-A-", "java.util.Arrays",
17+
"null", "[]", "Calm", "+==+ZZZ+==+", "none", "========", "**********=[]=**********", "abcdefghijklmnopqrstuvwxyz--A--", "abcdefghijklmnopqrstuvwxyz--Z--", "java.util.List"
18+
);
19+
public int loops = 10000;
20+
21+
22+
@Test
23+
public void indexOfTwg2() {
24+
int res = 0;
25+
26+
for(int i = 0; i < loops; i++) {
27+
int sub = 0;
28+
for(int j = 0, size = strs.size(); j < size; j++) {
29+
sub += StringIndex.indexOf(strs.get(j), 0, "A") + (j < size - 1 ? StringIndex.indexOf(strs.get(j + 1), 0, '-') : 0);
30+
}
31+
if(i % 3 == 0 || i % 5 == 0) {
32+
res += sub;
33+
}
34+
}
35+
36+
System.out.println(res);
37+
}
38+
39+
40+
@Test
41+
public void indexOfJava() {
42+
int res = 0;
43+
44+
for(int i = 0; i < loops; i++) {
45+
int sub = 0;
46+
for(int j = 0, size = strs.size(); j < size; j++) {
47+
sub += strs.get(j).indexOf("A") + (j < size - 1 ? strs.get(j + 1).indexOf('-') : 0);
48+
}
49+
if(i % 3 == 0 || i % 5 == 0) {
50+
res += sub;
51+
}
52+
}
53+
54+
System.out.println(res);
55+
}
56+
57+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package twg2.text.benchmark;
2+
3+
import java.util.Arrays;
4+
import java.util.List;
5+
6+
import org.junit.Test;
7+
8+
import twg2.text.stringUtils.StringReplace;
9+
10+
/**
11+
* @author TeamworkGuy2
12+
* @since 2019-10-03
13+
*/
14+
public class StringReplacePerf {
15+
public List<String> strs = Arrays.asList(
16+
"Alpha", "", "alphA", "-==-AAA-==-", "none", "----------", "AAAAAAAAAA", "longer-than-normal-string-of-long-length-a", "1234567890-with-another-A-", "java.util.Arrays",
17+
"null", "[]", "Calm", "+==+ZZZ+==+", "none", "========", "**********=[]=**********", "abcdefghijklmnopqrstuvwxyz--A--", "abcdefghijklmnopqrstuvwxyz--Z--", "java.util.List"
18+
);
19+
public int loops = 10000;
20+
21+
22+
@Test
23+
public void replaceTwg2() {
24+
int res = 0;
25+
26+
for(int i = 0; i < loops; i++) {
27+
int sub = 0;
28+
for(int j = 0, size = strs.size(); j < size; j++) {
29+
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);
30+
}
31+
if(i % 3 == 0 || i % 5 == 0) {
32+
res += sub;
33+
}
34+
}
35+
36+
System.out.println(res);
37+
}
38+
39+
40+
@Test
41+
public void replaceJava() {
42+
int res = 0;
43+
44+
for(int i = 0; i < loops; i++) {
45+
int sub = 0;
46+
for(int j = 0, size = strs.size(); j < size; j++) {
47+
sub += strs.get(j).replace("-a", "-A").replace("A", "B").hashCode() - (j < size - 1 ? strs.get(j + 1).replace("A", "B").hashCode() : 0);
48+
}
49+
if(i % 3 == 0 || i % 5 == 0) {
50+
res += sub;
51+
}
52+
}
53+
54+
System.out.println(res);
55+
}
56+
57+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package twg2.text.benchmark;
2+
3+
import java.util.Arrays;
4+
import java.util.List;
5+
6+
import org.junit.Test;
7+
8+
import twg2.text.stringUtils.StringSplit;
9+
10+
/**
11+
* @author TeamworkGuy2
12+
* @since 2019-10-03
13+
*/
14+
public class StringSplitPerf {
15+
public List<String> strs = Arrays.asList(
16+
"Alpha", "", "alphA", "-==-AAA-==-", "none", "----------", "AAAAAAAAAA", "longer-than-normal-string-of-long-length-a", "1234567890-with-another-A-", "java.util.Arrays",
17+
"null", "[]", "Calm", "+==+ZZZ+==+", "none", "========", "**********=[]=**********", "abcdefghijklmnopqrstuvwxyz--A--", "abcdefghijklmnopqrstuvwxyz--Z--", "java.util.List"
18+
);
19+
public int loops = 10000;
20+
21+
22+
@Test
23+
public void splitTwg2() {
24+
int res = 0;
25+
26+
for(int i = 0; i < loops; i++) {
27+
int sub = 0;
28+
for(int j = 0, size = strs.size(); j < size; j++) {
29+
sub += StringSplit.split(strs.get(j), "A", 3).length - (j < size - 1 ? StringSplit.split(strs.get(j + 1), '-').size() : 0);
30+
}
31+
if(i % 3 == 0 || i % 5 == 0) {
32+
res += sub;
33+
}
34+
}
35+
36+
System.out.println(res);
37+
}
38+
39+
40+
@Test
41+
public void splitJava() {
42+
int res = 0;
43+
44+
for(int i = 0; i < loops; i++) {
45+
int sub = 0;
46+
for(int j = 0, size = strs.size(); j < size; j++) {
47+
sub += strs.get(j).split("A", 3).length - (j < size - 1 ? strs.get(j + 1).split("-", -1).length : 0);
48+
}
49+
if(i % 3 == 0 || i % 5 == 0) {
50+
res += sub;
51+
}
52+
}
53+
54+
System.out.println(res);
55+
}
56+
57+
}

test/twg2/text/test/DataUnescapePartialQuoted.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class DataUnescapePartialQuoted {
4343

4444

4545
/** 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 */
46-
public static List<Integer> _expectedIndexesIncludingTrueEndingChar = Arrays.asList(
46+
public static List<Integer> expectedIndexesIncludingTrueEndingChar = Arrays.asList(
4747
inputs.get(0).lastIndexOf("\"") + 1,
4848
inputs.get(1).lastIndexOf(','),
4949
inputs.get(2).lastIndexOf(','),

0 commit comments

Comments
 (0)