scripts and results (was Helping to find the usefulness of a proposal)

Ulf Zibis Ulf.Zibis at gmx.de
Wed Apr 15 07:33:04 PDT 2009


Hi Ruslan,

I would like to see the results for

     "objects and expressions in switch"

which includes:
- string in switch
- instanceof switch

I guess a very big chunk of all if-else if-structures would be covered by:
http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/001182.html

A n y   C A P A C I T Y   t o   a d d   t h i s  p a t t e r n   t o   y 
o u r   s c r i p t ? ?

As I argued before, I'm against the current syntax of the "string in 
switch"-proposal, as it weakens switch..case semantics for identity, and 
it encumbers later enhancements for the future. See: 
http://mail.openjdk.java.net/pipermail/coin-dev/2009-April/001328.html.

- Ulf



Am 07.04.2009 02:33, Ruslan Shevchenko schrieb:
>  Good day,
>
> Few days ago Stephan give idea about writing simple script, which
>  count amount of possible-optimizations of existing code.
>
> So, I wrote few checks for some of such entries. They count
> low bound of number of code patterns, which can be optimized with
> some of coin proposal and situated on distinct source lines.
>
> I'm afraid that information, which come from count of such code patterns
> can give incorrect direction:  when we have such patterns in code,
> it's means that problem is not so big and we can easy live with one.
>  Big language problems solved (or not) in non-trivial way, when we have no
> common (may be ugly) workaround.
> For example. in Java we rare will see BigDecimal.add()  because it is not
> easy to work with BigDecimals, instead people work with double and have
> troubles
> with floating points rounding issues (see
> http://www.ddj.com/java/184405721)).
> Yet one example - choosing another language for implementing db-intensive
> parts of projects.
>
> Ok, you warned;  data still can be interesting:
>
> Checked patterns was:
>   string in switch
>   instanceof switch
>   byte literals
>   multi catch
>   loop by iterator, with call remove inside loop
>
>  (if you want include other checks, you can add one at
>  etc/checkers_coin.def or ask me [but without any warranty])
>
> <BTW>
> Exists one proposal, which I can't find on Joe blog: is change of variable
> subtype inside 'if instance' statement
> I. e. patterns look:
> if (x instanceof something)
> {
>  something sx = (something)x;
> }
> And proposal tell type 'x' as 'something' inside dominate if block.
> Are anybody remember such proposal or it's was my fantasy ?
> </BTW>
>
> Some results:
>
> For jetty6_11: (web server)
> byte literal    :       52
> elvis   :       43
> instanceof switch       :       8
> loop with remove        :       0
> multi catch     :       22
> string in switch        :       19
> Files:187
>
> For gwt-user (google ajax library)
> byte literal    :       2
> elvis   :       30
> instanceof switch       :       6
> loop with remove        :       5
> multi catch     :       9
> string in switch        :       10
> Files:920
>
> For openjdk-jdk part: (system library)
> byte literal    :       1245
> elvis   :       725
> instanceof switch       :       252
> loop with remove        :       61
> multi catch     :       349
> string in switch        :       380
> Files:7375
>
>
>
> If you want to play with checks - most easy way is get special modified
> source
> distributive of JavaChecker, which I published as 2.5.0p0 and run it, i.e.
> (assuming you on Unix console)
>
> retrive distributive:
>
>  wget
> http://datacenter.gradsoft.ua/public.repository/ua.gradsoft/javachecker/installations/JavaCheckerSourceInstaller-2.5.0p0.jar
>
> run installer:
> java -jar JavaCheckerSourceInstaller-2.5.0p0.jar
>  (install one from UI)
>
> cd <where-you-install-javacheker>
>
> vi build-check-external.xml, look at few last tasks at end
>
> vi check-external.properties
>
> add own task and run one, as example:
> ant -f build-check-external.xml check-coin-openjdk
>
> Note, that speed of JavaChecker is far from ideal: openJDK-jdk
>  processed near 50 minutes, so be patient ;)
>
> Hope, this information can be useful, as one (and not main) of  sources.
>
> Regards !
>
>
>
>
>   




More information about the coin-dev mailing list