<Swing Dev> IndexOf with Char instead of String

Alexander Scherbatiy alexandr.scherbatiy at oracle.com
Mon Jan 26 15:35:33 UTC 2015


  The Swing part looks good to me.

  Could you create an issue in http://bugreport.java.com/bugreport
  and resend the fix with the title  [9] Review Request: bugID bug summary

  Thanks,
  Alexandr.

On 1/13/2015 1:23 AM, Otávio Gonçalves de Santana wrote:
>
> These String literals may be replaced by equivalent character 
> literals[1], gaining some performance enhancement.
>
> Webrev: 
> https://dl.dropboxusercontent.com/u/16109193/open_jdk/jdk/index_of_character/index.html
>
>
> [1]
> @State(Scope.Thread)
> @OutputTimeUnit(TimeUnit.SECONDS)
> public class IndexOfBenchmark {
>     private static final String WORDS = "I love java Language 8 
> because has Lambda, Stream and MetaSpace";
>     @Param("10000")
>     private int param;
>     @GenerateMicroBenchmark
>     public void indexOfString(BlackHole bh) {
>         for (int i = 0; i <= param; i++) {
>             int index = WORDS.indexOf(",");
>             bh.consume(index);
>         }
>     }
>     @GenerateMicroBenchmark
>     public void indexOfChar(BlackHole bh) {
>         for (int i = 0; i <= param; i++) {
>             int index = WORDS.indexOf(',');
>             bh.consume(index);
>         }
>     }
> }
>
> Benchmark                           (param)   Mode Samples         
> Mean   Mean error    Units
> m.IndexOfBenchmark.indexOfChar        10000  thrpt  10     5579.120   
>    114.179    ops/s
> m.IndexOfBenchmark.indexOfString      10000  thrpt  10     4562.178   
>     46.751    ops/s
>
> -- 
> Otávio Gonçalves de Santana
>
> blog: http://otaviosantana.blogspot.com.br/
> twitter: http://twitter.com/otaviojava
> site: _http://about.me/otaviojava_
> 55 (11) 98255-3513
>




More information about the swing-dev mailing list