This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: gcj's IO performance vs blackdown JDK
- From: Mohan Embar <gnustuff at thisiscool dot com>
- To: Christopher Marshall <christopherlmarshall at yahoo dot com>, Bryce McKinlay <bryce at mckinlay dot net dot nz>
- Cc: java at gcc dot gnu dot org, tromey at redhat dot com
- Date: Tue, 23 Dec 2003 20:39:57 -0600
- Subject: Re: gcj's IO performance vs blackdown JDK
- Reply-to: gnustuff at thisiscool dot com
>In the code below...
Forgot the code. Here it is. I stashed the CNI native
method in posix.cc for testing purposes. I've left it
here, commented out.
-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/
Index: posix.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/posix.cc,v
retrieving revision 1.10
diff -c -3 -p -r1.10 posix.cc
*** posix.cc 8 Jul 2003 04:49:16 -0000 1.10
--- posix.cc 24 Dec 2003 02:21:31 -0000
*************** _Jv_select (int n, fd_set *readfds, fd_s
*** 179,181 ****
--- 179,198 ----
return 0;
#endif
}
+
+ /*
+ #include <java/io/BufferedReader.h>
+
+ jint java::io::BufferedReader::lineEnd ()
+ {
+ jchar *pbuf = elements (buffer);
+ int i = pos;
+ for (; i < limit; i++)
+ {
+ jchar ch = pbuf[i];
+ if (ch == '\n' || ch == '\r')
+ break;
+ }
+ return i;
+ }
+ */
Index: java/io/BufferedReader.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/BufferedReader.java,v
retrieving revision 1.14
diff -c -3 -p -r1.14 BufferedReader.java
*** java/io/BufferedReader.java 14 Jun 2003 05:44:38 -0000 1.14
--- java/io/BufferedReader.java 24 Dec 2003 02:21:36 -0000
*************** package java.io;
*** 45,51 ****
*/
/**
! * This subclass of <code>FilterReader</code> buffers input from an
* underlying implementation to provide a possibly more efficient read
* mechanism. It maintains the buffer and buffer state in instance
* variables that are available to subclasses. The default buffer size
--- 45,51 ----
*/
/**
! * This subclass of <code>Reader</code> buffers input from an
* underlying implementation to provide a possibly more efficient read
* mechanism. It maintains the buffer and buffer state in instance
* variables that are available to subclasses. The default buffer size
*************** package java.io;
*** 60,66 ****
*/
public class BufferedReader extends Reader
{
- Reader in;
char[] buffer;
/* Index of current read position. Must be >= 0 and <= limit. */
/* There is a special case where pos may be equal to limit+1; this
--- 60,65 ----
*************** public class BufferedReader extends Read
*** 89,94 ****
--- 88,103 ----
static final int DEFAULT_BUFFER_SIZE = 8192;
/**
+ * Our wrapped <code>Reader</code>.
+ */
+ private Reader in;
+
+ /**
+ * The line buffer for <code>readLine</code>.
+ */
+ private StringBuffer sbuf = new StringBuffer(200);
+
+ /**
* Create a new <code>BufferedReader</code> that will read from the
* specified subordinate stream with a default buffer size of 8192 chars.
*
*************** public class BufferedReader extends Read
*** 378,394 ****
synchronized (lock)
{
checkStatus();
! if (pos >= limit && fill () <= 0)
! return -1;
! return buffer[pos++];
}
}
/* Return the end of the line starting at this.pos and ending at limit.
* The index returns is *before* any line terminators, or limit
* if no line terminators were found.
*/
! private int lineEnd(int limit)
{
int i = pos;
for (; i < limit; i++)
--- 387,408 ----
synchronized (lock)
{
checkStatus();
! return doRead();
}
}
+ private int doRead() throws IOException
+ {
+ if (pos >= limit && fill () <= 0)
+ return -1;
+ return buffer[pos++];
+ }
+
/* Return the end of the line starting at this.pos and ending at limit.
* The index returns is *before* any line terminators, or limit
* if no line terminators were found.
*/
! private int lineEnd()
{
int i = pos;
for (; i < limit; i++)
*************** public class BufferedReader extends Read
*** 426,432 ****
if (ch != '\n')
--pos;
}
! int i = lineEnd(limit);
if (i < limit)
{
String str = new String(buffer, pos, i - pos);
--- 440,446 ----
if (ch != '\n')
--pos;
}
! int i = lineEnd();
if (i < limit)
{
String str = new String(buffer, pos, i - pos);
*************** public class BufferedReader extends Read
*** 440,446 ****
pos++;
return str;
}
! StringBuffer sbuf = new StringBuffer(200);
sbuf.append(buffer, pos, i - pos);
pos = i;
// We only want to return null when no characters were read before
--- 454,461 ----
pos++;
return str;
}
!
! sbuf.setLength(0);
sbuf.append(buffer, pos, i - pos);
pos = i;
// We only want to return null when no characters were read before
*************** public class BufferedReader extends Read
*** 448,475 ****
// would treat an empty `sbuf' as an EOF condition, which is wrong
// when there is just a newline.
boolean eof = false;
! for (;;)
{
! int ch = read();
! if (ch < 0)
! {
! eof = true;
! break;
! }
! if (ch == '\n' || ch == '\r')
{
! // Check here if a '\r' was the last char in the buffer; if so,
! // mark it as in the comment above to indicate future reads
! // should skip a newline that is the next char read after
! // refilling the buffer.
! if (ch == '\r')
! if (pos == limit || buffer[pos] == '\n')
! pos++;
! break;
}
- i = lineEnd(limit);
- sbuf.append(buffer, pos - 1, i - (pos - 1));
- pos = i;
}
return (sbuf.length() == 0 && eof) ? null : sbuf.toString();
}
--- 463,494 ----
// would treat an empty `sbuf' as an EOF condition, which is wrong
// when there is just a newline.
boolean eof = false;
!
! synchronized (lock)
{
! for (;;)
{
! int ch = doRead();
! if (ch < 0)
! {
! eof = true;
! break;
! }
! if (ch == '\n' || ch == '\r')
! {
! // Check here if a '\r' was the last char in the buffer; if so,
! // mark it as in the comment above to indicate future reads
! // should skip a newline that is the next char read after
! // refilling the buffer.
! if (ch == '\r')
! if (pos == limit || buffer[pos] == '\n')
! pos++;
! break;
! }
! i = lineEnd();
! sbuf.append(buffer, pos - 1, i - (pos - 1));
! pos = i;
}
}
return (sbuf.length() == 0 && eof) ? null : sbuf.toString();
}
*************** public class BufferedReader extends Read
*** 507,513 ****
// one element or not.
int ch;
if (pos > limit)
! if ((ch = read()) < 0)
return 0;
else
--pos;
--- 526,532 ----
// one element or not.
int ch;
if (pos > limit)
! if ((ch = doRead()) < 0)
return 0;
else
--pos;
*************** public class BufferedReader extends Read
*** 542,547 ****
--- 561,571 ----
}
return count - todo;
}
+ }
+
+ final Reader in()
+ {
+ return in;
}
private void checkStatus() throws IOException
Index: java/io/LineNumberReader.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/LineNumberReader.java,v
retrieving revision 1.10
diff -c -3 -p -r1.10 LineNumberReader.java
*** java/io/LineNumberReader.java 18 Sep 2003 06:07:09 -0000 1.10
--- java/io/LineNumberReader.java 24 Dec 2003 02:21:37 -0000
*************** public class LineNumberReader extends Bu
*** 229,235 ****
markPos = -1;
if (markPos < 0)
pos = limit = 0;
! int count = in.read(buffer, limit, buffer.length - limit);
if (count <= 0)
return -1;
limit += count;
--- 229,235 ----
markPos = -1;
if (markPos < 0)
pos = limit = 0;
! int count = in().read(buffer, limit, buffer.length - limit);
if (count <= 0)
return -1;
limit += count;