Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


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

Re: NIO not so hot

From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.java.programmer
Subject Re: NIO not so hot
Date 2014-05-26 23:50 +0200
Message-ID <buhr8pFau9sU1@mid.individual.net> (permalink)
References <t24en9putph3mbnulkveghdjbrnisp105h@4ax.com> <btrkdnFjc3qU1@mid.individual.net> <81u5o9pfr44rtq9loivhrpe178lcql92r5@4ax.com>

Show all headers | View raw


On 26.05.2014 10:24, Roedy Green wrote:
> On Sun, 18 May 2014 13:38:30 +0200, Robert Klemme
> <shortcutter@googlemail.com> wrote, quoted or indirectly quoted
> someone who said :
>
>> However, the test is quite unrealistic since this is not how NIO is
>> usually used.
>
> With this particular benchmark I was not trying to demonstrate the use
> of NIO, but decide the optimal way to read a whole file of characters
> at a time, something I do very often.

Why do you do that?  Wouldn't that run the risk of using too much 
memory?  I mean, usually you want to extract information from the file

> I just have vague notion that if you keep your data in buffers, off
> the Java heap, and ignore most of it, NIO will work faster than
> ordinary I/O.

You do not necessarily have to ignore it.  But as long as you just do 
raw IO (i.e. copying data from one place to the other) then direct 
ByteBuffer seems to perform best.

> I would be happy to post some sample code, explanations etc. at
> http://mindprod.com/jgloss/nio.html
> if you are up to expounding on NIO.

Others have more time and experience to do that.  NIO is more 
complicated and offers more control for a greater variety of use cases. 
  If you just want to serially read a file using blocking IO the old IO 
is probably best - even performance wise, as we have seen.

Kind regards

	robert

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


Thread

NIO not so hot Roedy Green <see_website@mindprod.com.invalid> - 2014-05-17 04:28 -0700
  Re: NIO not so hot Robert Klemme <shortcutter@googlemail.com> - 2014-05-18 13:38 +0200
    Re: NIO not so hot Robert Klemme <shortcutter@googlemail.com> - 2014-05-18 13:38 +0200
      Re: NIO not so hot Robert Klemme <shortcutter@googlemail.com> - 2014-05-18 14:12 +0200
        Re: NIO not so hot Robert Klemme <shortcutter@googlemail.com> - 2014-05-18 19:09 +0200
          Re: NIO not so hot Roedy Green <see_website@mindprod.com.invalid> - 2014-05-26 00:51 -0700
            Re: NIO not so hot Robert Klemme <shortcutter@googlemail.com> - 2014-05-26 20:14 +0200
    Re: NIO not so hot Roedy Green <see_website@mindprod.com.invalid> - 2014-05-26 01:15 -0700
    Re: NIO not so hot Roedy Green <see_website@mindprod.com.invalid> - 2014-05-26 01:24 -0700
      Re: NIO not so hot Robert Klemme <shortcutter@googlemail.com> - 2014-05-26 23:50 +0200
  Re: NIO not so hot Rupert Smith <rupertlssmith@googlemail.com> - 2014-05-31 02:29 -0700
    Re: NIO not so hot Robert Klemme <shortcutter@googlemail.com> - 2014-06-01 12:15 +0200
      Re: NIO not so hot Rupert Smith <rupertlssmith@googlemail.com> - 2014-06-02 07:37 -0700
        Re: NIO not so hot Robert Klemme <shortcutter@googlemail.com> - 2014-06-03 23:07 +0200
          Re: NIO not so hot Rupert Smith <rupertlssmith@googlemail.com> - 2014-06-06 01:32 -0700
      Re: NIO not so hot Rupert Smith <rupertlssmith@googlemail.com> - 2014-06-02 07:46 -0700

csiph-web