Faster, regexp-free versions of getRubyCasedName and getJavaPropertyN… · jruby/jruby@74b7a65 · GitHub
Skip to content

Commit 74b7a65

Browse files
committed
Faster, regexp-free versions of getRubyCasedName and getJavaPropertyName.
These were showing up on Ruboto startup profiles. * getRubyCasedName: 8-10x faster * getJavaPropertyName: 6-7x faster
1 parent a8e5382 commit 74b7a65

3 files changed

Lines changed: 112 additions & 27 deletions

File tree

‎bench/BenchJavaPropName.java‎

Lines changed: 15 additions & 0 deletions

‎bench/BenchRubyCasedName.java‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
public class BenchRubyCaseName {
2+
3+
4+
public static void main(String[] args) {
5+
String[] names = new String[] {"fooBarBAZMah", "fooBarBAZMag", "fooBarBAZMaf", "fooBarBAZMad", "fooBarBAZMas"};
6+
for (int c = 0; c < 100; c++) {
7+
long t = System.currentTimeMillis();
8+
for (int i = 0; i < 1000000; i++) {
9+
String name = org.jruby.javasupport.JavaUtil.getRubyCasedName(names[i % 5]);
10+
if (i % 100001 == 0) System.out.println(name);
11+
}
12+
System.out.println(System.currentTimeMillis() - t);
13+
}
14+
}
15+
}

‎src/org/jruby/javasupport/JavaUtil.java‎

Lines changed: 82 additions & 27 deletions

0 commit comments

Comments
 (0)