Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.lang.java.programmer > #5861

Re: Passing a Method Name to a Method, Redux

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From blmblm@myrealbox.com <blmblm.myrealbox@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Passing a Method Name to a Method, Redux
Date 5 Jul 2011 19:07:37 GMT
Organization None
Lines 93
Message-ID <97h5npFhaeU1@mid.individual.net> (permalink)
References <fpg7079ca2dtgipdphr8rm234kgmkd1t3l@4ax.com> <jcu707d1fb592i91m40fsjtfg0784knkd1@4ax.com> <97cq72FbqnU1@mid.individual.net> <20c411d9-8955-4f4c-9a78-fea7540ed9a1@p10g2000prf.googlegroups.com>
X-Trace individual.net VvTaJGf6iJEHYvc83xgwoQfmUIKOMtSWCv/NrZxZhY9/jUZsED
X-Orig-Path not-for-mail
Cancel-Lock sha1:7QoeTPumXq7oUeUY8p+koZ05cgk=
X-Newsreader trn 4.0-test76 (Apr 2, 2001)
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5861

Show key headers only | View raw


In article <20c411d9-8955-4f4c-9a78-fea7540ed9a1@p10g2000prf.googlegroups.com>,
lewbloch  <lewbloch@gmail.com> wrote:
> On Jul 3, 8:26 pm, blm...@myrealbox.com <blmblm.myreal...@gmail.com>
> wrote:
> > In article <jcu707d1fb592i91m40fsjtfg0784kn...@4ax.com>,
> > Gene Wirchenko  <ge...@ocis.net> wrote:

[ snip ]

> > Another "no separate method" approach would be to use the String
> > class's indexOf method:
> >
> >     static boolean StringLibSearch
> >         (
> >          char CurrChar
> >         )
> >         {
> >             return IdentChars.indexOf(CurrChar) >= 0;
> >         }
> >
> > I added this to your benchmark suite and found it to give performance
> > comparable to the TreeSet implementation (indeed, usually it was a
> > bit faster).  The overhead of building the TreeSet probably doesn't
> > matter in the grand scheme of things, and probably it also doesn't
> > matter a lot that every call to the TreeSet's "contains" method
> > (AFAIK) has to convert a character primitive to a Character object,
> > but -- <shrug>.
> >
> > But if you're going to use a Set, why a TreeSet?  As best I can tell,
> > you don't use/need the sorted-ness it provides.  Just out of curiosity,
> > I also added to your benchmark suite something that declares the set
> > as a Set and creates it as an instance of HashSet, and the resulting
> > code was noticeably faster than any of the other alternatives.
> >
> > And finally, I wondered how all of these methods compared to
> > something using regular expressions (the java.util.regex classes), so
> > i tried that too, replacing your whole parse code with the following:
> >
> >     import java.util.regex.*;
> >
> >     // ....
> >
> >     static Pattern IdentRegexPattern=Pattern.compile("[" + IdentChars + "]+");
> >
> >     // ....
> >
> >     // code to be called repeatedly from timing loop
> >     static void ParseRegex()
> >     {
> >         Matcher IdentMatcher = IdentRegexPattern.matcher(cParseString);
> >         String sIdent;
> >         while (IdentMatcher.find())
> >         {
> >             sIdent = IdentMatcher.group();
> >             if (nRepetitions==1)
> >                 System.out.println(sIdent);
> >         }
> >     }
> >
> >     // ....
> >
> > This was a clear winner (with regard to performance) on the system
> > where I measured performance, *unless* I ran the tests with the
> > "-server" flag, in which case it took second place, behind the
> > HashSet-based approach.  As I understand things, though, the
> > "-server" flag results in the compiler doing more to try to optimize
> > the code, including being more aggressive about eliminating dead
> > code, so I'm not entirely confident about the results I'm getting
> > being meaningful.
> >
> > (Probably your actual code needs to do something other than
> > finding and printing identifiers, so the above code would need
> > some adjustment.  Still, if you like regular expressions, it's
> > another possibility, maybe .... )
> >
> > [ snip ]
> >
> 
> Your points are excellent, but the ongoing violations of the naming
> conventions is making my brain hurt.  Can't we please revert to
> conformant names in our replies at least?


Well ....  I guess I figure it's a choice between two things that
seem desirable -- (1) working in with the conventions of the code
I'm modifying and (2) applying the conventions used by most Java
programmers.  I chose the former, though it rather makes my brain
hurt as well.  :-)?


-- 
B. L. Massingill
ObDisclaimer:  I don't speak for my employers; they return the favor.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Passing a Method Name to a Method, Redux Gene Wirchenko <genew@ocis.net> - 2011-06-23 16:03 -0700
  Re: Passing a Method Name to a Method, Redux Gene Wirchenko <genew@ocis.net> - 2011-06-23 16:26 -0700
    Re: Passing a Method Name to a Method, Redux blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-06-27 21:41 +0000
  Re: Passing a Method Name to a Method, Redux markspace <-@.> - 2011-06-23 17:24 -0700
    Re: Passing a Method Name to a Method, Redux Gene Wirchenko <genew@ocis.net> - 2011-06-23 19:46 -0700
      Re: Passing a Method Name to a Method, Redux blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-07-04 03:26 +0000
        Re: Passing a Method Name to a Method, Redux lewbloch <lewbloch@gmail.com> - 2011-07-04 03:41 -0700
          Re: Passing a Method Name to a Method, Redux blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-07-05 19:07 +0000
  Re: Passing a Method Name to a Method, Redux markspace <-@.> - 2011-06-23 17:34 -0700
    Re: Passing a Method Name to a Method, Redux Gene Wirchenko <genew@ocis.net> - 2011-06-23 19:42 -0700
  Re: Passing a Method Name to a Method, Redux markspace <-@.> - 2011-06-23 18:30 -0700
    Re: Passing a Method Name to a Method, Redux Gene Wirchenko <genew@ocis.net> - 2011-06-23 19:48 -0700
      Re: Passing a Method Name to a Method, Redux markspace <-@.> - 2011-06-23 21:02 -0700
        Re: Passing a Method Name to a Method, Redux lewbloch <lewbloch@gmail.com> - 2011-06-24 08:38 -0700
          Re: Passing a Method Name to a Method, Redux markspace <-@.> - 2011-06-24 09:04 -0700
            Re: Passing a Method Name to a Method, Redux Lew <noone@lewscanon.com> - 2011-06-26 13:43 -0400
              Re: Passing a Method Name to a Method, Redux Lew <noone@lewscanon.com> - 2011-06-26 14:31 -0400
        Re: Passing a Method Name to a Method, Redux Gene Wirchenko <genew@ocis.net> - 2011-06-24 11:45 -0700
          Re: Passing a Method Name to a Method, Redux markspace <-@.> - 2011-06-24 12:19 -0700
            Re: Passing a Method Name to a Method, Redux Gene Wirchenko <genew@ocis.net> - 2011-06-26 20:39 -0700
              Re: Passing a Method Name to a Method, Redux markspace <-@.> - 2011-06-26 23:33 -0700
                Re: Passing a Method Name to a Method, Redux Gene Wirchenko <genew@ocis.net> - 2011-06-27 13:53 -0700
                Re: Passing a Method Name to a Method, Redux markspace <-@.> - 2011-06-27 18:03 -0700
                Re: Passing a Method Name to a Method, Redux Gene Wirchenko <genew@ocis.net> - 2011-06-28 11:41 -0700
        Re: Passing a Method Name to a Method, Redux blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-06-24 19:19 +0000
  Re: Passing a Method Name to a Method, Redux Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-23 19:36 -0700
    Re: Passing a Method Name to a Method, Redux Gene Wirchenko <genew@ocis.net> - 2011-06-24 11:50 -0700
      Re: Passing a Method Name to a Method, Redux Jeff Higgins <jeff@invalid.invalid> - 2011-06-24 17:25 -0400
        Re: Passing a Method Name to a Method, Redux Gene Wirchenko <genew@ocis.net> - 2011-06-26 20:42 -0700
          Re: Passing a Method Name to a Method, Redux markspace <-@.> - 2011-06-26 23:27 -0700
          Re: Passing a Method Name to a Method, Redux Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-27 03:04 -0400
            Re: Passing a Method Name to a Method, Redux Gene Wirchenko <genew@ocis.net> - 2011-06-27 13:12 -0700
              Re: Passing a Method Name to a Method, Redux Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-27 13:36 -0700
      Re: Passing a Method Name to a Method, Redux Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-24 15:50 -0700

csiph-web