Hi,
I'm having performanbce issues with StreamReader and was wondering
what I could do to improve it...
The following takes around 3 seconds to process! The content of the
response is:
"<?xml version="1.0" ?><ERROR>ORA-01403: no data found</ERROR>"
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strURIQuery);
req.Method = "GET";
req.Credentials = new NetworkCredential(strUser, strPass);
StreamReader stream = new
StreamReader(req.GetResponse().GetResponseStream() );
StringBuilder sbXMLResponse0 = new StringBuilder();
//## start timer here
while((strLineXMLResponse = stream.ReadLine()) != null)
{
if(strLineXMLResponse.Length > 0 )
{
sbXMLResponse0.Append(strLineXMLResponse);
}
}
//## end timer here
I also tried:
strLineXMLResponse = stream.ReadToEnd();
with similar processing times. The response times are sub-second - I
think I have correctly isolated the performance issue to the
StreamReader.
Any help would be much appreciated.
Thanks,
Oafyuf 9 12709
oafyuf <oa****@hotmail.com> wrote: I'm having performanbce issues with StreamReader and was wondering what I could do to improve it...
The following takes around 3 seconds to process! The content of the response is:
"<?xml version="1.0" ?><ERROR>ORA-01403: no data found</ERROR>"
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strURIQuery); req.Method = "GET"; req.Credentials = new NetworkCredential(strUser, strPass); StreamReader stream = new StreamReader(req.GetResponse().GetResponseStream() ); StringBuilder sbXMLResponse0 = new StringBuilder();
//## start timer here while((strLineXMLResponse = stream.ReadLine()) != null) { if(strLineXMLResponse.Length > 0 ) { sbXMLResponse0.Append(strLineXMLResponse); } } //## end timer here
I also tried: strLineXMLResponse = stream.ReadToEnd(); with similar processing times. The response times are sub-second - I think I have correctly isolated the performance issue to the StreamReader.
Try reading straight from the response stream - I suspect it will take
about the same length of time. I'd be very surprised if it really was
StreamReader being slow.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Hi,
How is your connection with the server? what about the time to process the
request?
maybe there is the bottleneck, and not in the length of the response.
StreamReader should not add any overhead.
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"oafyuf" <oa****@hotmail.com> wrote in message
news:ea**************************@posting.google.c om... Hi, I'm having performanbce issues with StreamReader and was wondering what I could do to improve it...
The following takes around 3 seconds to process! The content of the response is:
"<?xml version="1.0" ?><ERROR>ORA-01403: no data found</ERROR>"
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strURIQuery); req.Method = "GET"; req.Credentials = new NetworkCredential(strUser, strPass); StreamReader stream = new StreamReader(req.GetResponse().GetResponseStream() ); StringBuilder sbXMLResponse0 = new StringBuilder();
//## start timer here while((strLineXMLResponse = stream.ReadLine()) != null) { if(strLineXMLResponse.Length > 0 ) { sbXMLResponse0.Append(strLineXMLResponse); } } //## end timer here
I also tried: strLineXMLResponse = stream.ReadToEnd(); with similar processing times. The response times are sub-second - I think I have correctly isolated the performance issue to the StreamReader.
Any help would be much appreciated. Thanks, Oafyuf
Are you sure it's not the GetResponseStream that's taking so long? I mean,
that function call performs a network trip to the host specified in the URI,
which of course will take a considerable amount of time.
My experience with StreamReader so far have not shown any significant
performance problems.
--
John Wood
EMail: first name, dot, last name, at priorganize.com
"oafyuf" <oa****@hotmail.com> wrote in message
news:ea**************************@posting.google.c om... Hi, I'm having performanbce issues with StreamReader and was wondering what I could do to improve it...
The following takes around 3 seconds to process! The content of the response is:
"<?xml version="1.0" ?><ERROR>ORA-01403: no data found</ERROR>"
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strURIQuery); req.Method = "GET"; req.Credentials = new NetworkCredential(strUser, strPass); StreamReader stream = new StreamReader(req.GetResponse().GetResponseStream() ); StringBuilder sbXMLResponse0 = new StringBuilder();
//## start timer here while((strLineXMLResponse = stream.ReadLine()) != null) { if(strLineXMLResponse.Length > 0 ) { sbXMLResponse0.Append(strLineXMLResponse); } } //## end timer here
I also tried: strLineXMLResponse = stream.ReadToEnd(); with similar processing times. The response times are sub-second - I think I have correctly isolated the performance issue to the StreamReader.
Any help would be much appreciated. Thanks, Oafyuf
Thanks for all your responses. Sorry it takes me so long to reply but
the site I'm on at the moment does not allow newsserver access and I'm
doing this through Google...
I understand that StreamReader is regarded as fast, but the 3 seconds
average timing I'm getting is between my "start timer here" and "end
timer here" comments. I have another timer block around the HTTP GET
which is returning a response sub-second. The network connection is
currently on a dev LAN with little other traffic. I should probably
mention that I'm doing URI Queries on an Oracle 9i database (getting
XML back in the response). Perhaps there is a way to allocate the size
of the StreamReader before it reads the stream or use another kind of
buffering?
I suppose it's not the StringBuilder because I still get the same
timing with this:
while((strLineXMLResponse = stream.ReadLine()) != null)
// do nothing
}
and this:
strLineXMLResponse = stream.ReadToEnd();
It seems the issue may not be with StreamReader, but it appears to be
in reading the stream into a string. I believe I *must* do this before
I can load it in an XmlDocument, but is there a way of loading the
stream directly into the XmlDocument?
Is the XmlTextReader more appropriate?
Thanks,
Oafyuf
"John Wood" <j@ro.com> wrote in message news:<uS*************@TK2MSFTNGP10.phx.gbl>... Are you sure it's not the GetResponseStream that's taking so long? I mean, that function call performs a network trip to the host specified in the URI, which of course will take a considerable amount of time.
My experience with StreamReader so far have not shown any significant performance problems.
-- John Wood EMail: first name, dot, last name, at priorganize.com "oafyuf" <oa****@hotmail.com> wrote in message news:ea**************************@posting.google.c om... Hi, I'm having performanbce issues with StreamReader and was wondering what I could do to improve it...
The following takes around 3 seconds to process! The content of the response is:
"<?xml version="1.0" ?><ERROR>ORA-01403: no data found</ERROR>"
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strURIQuery); req.Method = "GET"; req.Credentials = new NetworkCredential(strUser, strPass); StreamReader stream = new StreamReader(req.GetResponse().GetResponseStream() ); StringBuilder sbXMLResponse0 = new StringBuilder();
//## start timer here while((strLineXMLResponse = stream.ReadLine()) != null) { if(strLineXMLResponse.Length > 0 ) { sbXMLResponse0.Append(strLineXMLResponse); } } //## end timer here
I also tried: strLineXMLResponse = stream.ReadToEnd(); with similar processing times. The response times are sub-second - I think I have correctly isolated the performance issue to the StreamReader.
Any help would be much appreciated. Thanks, Oafyuf
oafyuf <oa****@hotmail.com> wrote:
<snip> It seems the issue may not be with StreamReader, but it appears to be in reading the stream into a string. I believe I *must* do this before I can load it in an XmlDocument, but is there a way of loading the stream directly into the XmlDocument?
Well, you could use XmlDocument.Load(Stream) but I doubt that it will
be significantly faster.
I suggest, just for the sake of testing, that you read the entire
contents of the stream into a MemoryStream, reset the position and
*then* use StreamReader - I suspect it'll show the StreamReader being
fast, and the reading from the network to be slow.
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Hi Jon,
The following times about the same (3 seconds):
XmlTextReader reader = new
XmlTextReader(req.GetResponse().GetResponseStream( ))
.... which doesn't distinguish between the HTTP response time and the
load into XmlTextReader but maybe it supports your proposition?
However, pasting the URI Query directly into a browser returns data in
around 1.5 seconds. Anyhow, I *think* I am doing my timing after the
response has been completed, unless:
StreamReader stream = new
StreamReader(req.GetResponse().GetResponseStream() );
doesn't do the request when you declare/assign it but when it is read.
Thanks,
Oafyuf
Jon Skeet [C# MVP] <sk***@pobox.com> wrote in message news:<MP************************@msnews.microsoft. com>... oafyuf <oa****@hotmail.com> wrote: I'm having performanbce issues with StreamReader and was wondering what I could do to improve it...
The following takes around 3 seconds to process! The content of the response is:
"<?xml version="1.0" ?><ERROR>ORA-01403: no data found</ERROR>"
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strURIQuery); req.Method = "GET"; req.Credentials = new NetworkCredential(strUser, strPass); StreamReader stream = new StreamReader(req.GetResponse().GetResponseStream() ); StringBuilder sbXMLResponse0 = new StringBuilder();
//## start timer here while((strLineXMLResponse = stream.ReadLine()) != null) { if(strLineXMLResponse.Length > 0 ) { sbXMLResponse0.Append(strLineXMLResponse); } } //## end timer here
I also tried: strLineXMLResponse = stream.ReadToEnd(); with similar processing times. The response times are sub-second - I think I have correctly isolated the performance issue to the StreamReader.
Try reading straight from the response stream - I suspect it will take about the same length of time. I'd be very surprised if it really was StreamReader being slow.
oafyuf <oa****@hotmail.com> wrote: The following times about the same (3 seconds):
XmlTextReader reader = new XmlTextReader(req.GetResponse().GetResponseStream( ))
... which doesn't distinguish between the HTTP response time and the load into XmlTextReader but maybe it supports your proposition?
Not really. Chances are XmlTextReader is using the same kind of code as
StringReader, so if one is genuinely slow, the other is likely to be as
well.
However, pasting the URI Query directly into a browser returns data in around 1.5 seconds. Anyhow, I *think* I am doing my timing after the response has been completed, unless:
StreamReader stream = new StreamReader(req.GetResponse().GetResponseStream() );
doesn't do the request when you declare/assign it but when it is read.
Just because you've got the response stream doesn't mean it's read all
the data, necessarily, does it? (Not sure how much it buffers, if any,
to be honest.)
Just try timing the read from the stream until its end - see how long
that takes.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Sorry All,
You are all correct, it is the response time that is slow. I tried:
XmlTextReader reader = new XmlTextReader("http://myURL/data.xml");
.... which is extremely fast, as opposed to:
XmlTextReader reader = new
XmlTextReader(req.GetResponse().GetResponseStream( ));
.... which is tediously slow. I just can't understand why I was getting
the timings in the part of the code which does the read instead of the
HTTP response. It's just as well that I'm not on the test team ;)
Oafyuf
"John Wood" <j@ro.com> wrote in message news:<uS*************@TK2MSFTNGP10.phx.gbl>... Are you sure it's not the GetResponseStream that's taking so long? I mean, that function call performs a network trip to the host specified in the URI, which of course will take a considerable amount of time.
My experience with StreamReader so far have not shown any significant performance problems.
-- John Wood EMail: first name, dot, last name, at priorganize.com "oafyuf" <oa****@hotmail.com> wrote in message news:ea**************************@posting.google.c om... Hi, I'm having performanbce issues with StreamReader and was wondering what I could do to improve it...
The following takes around 3 seconds to process! The content of the response is:
"<?xml version="1.0" ?><ERROR>ORA-01403: no data found</ERROR>"
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strURIQuery); req.Method = "GET"; req.Credentials = new NetworkCredential(strUser, strPass); StreamReader stream = new StreamReader(req.GetResponse().GetResponseStream() ); StringBuilder sbXMLResponse0 = new StringBuilder();
//## start timer here while((strLineXMLResponse = stream.ReadLine()) != null) { if(strLineXMLResponse.Length > 0 ) { sbXMLResponse0.Append(strLineXMLResponse); } } //## end timer here
I also tried: strLineXMLResponse = stream.ReadToEnd(); with similar processing times. The response times are sub-second - I think I have correctly isolated the performance issue to the StreamReader.
Any help would be much appreciated. Thanks, Oafyuf
Thanks Jon,
I tried using a MemoryStream and it confirmed my other posting in that
it is the response that is the problem - it was just that my original
diagnosis was faulty. So... I'm off to an Oracle NG to find out if I
can improve the performance of URI queries. Thanks for your help!
Oafyuf
Jon Skeet [C# MVP] <sk***@pobox.com> wrote in message news:<MP************************@msnews.microsoft. com>... oafyuf <oa****@hotmail.com> wrote:
<snip>
It seems the issue may not be with StreamReader, but it appears to be in reading the stream into a string. I believe I *must* do this before I can load it in an XmlDocument, but is there a way of loading the stream directly into the XmlDocument?
Well, you could use XmlDocument.Load(Stream) but I doubt that it will be significantly faster.
I suggest, just for the sake of testing, that you read the entire contents of the stream into a MemoryStream, reset the position and *then* use StreamReader - I suspect it'll show the StreamReader being fast, and the reading from the network to be slow.
Could you post a short but complete program which demonstrates the problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of what I mean by that. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: David Gray |
last post by:
Hello Gurus,
SQL Server 2000
Windows 2003 Server, Standard Edition.
Firstly I'm not a SQL server DBA but have a little experience with
Oracle 9i and Oracle Rdb.
An application that I've...
|
by: Evan Smith |
last post by:
My database is suffering from poor performance of late. Reports that
used to run in a reasonable time, now take a while. The explain output
show that the query is fully indexed, and the statistics...
|
by: sac |
last post by:
I am using DB2 v8.1 on UNIX.
At times the database shows extremely poor performance.
I do not have dba/admin rights nor do I have the web based client for
db2 v8.1.
I have only command line...
|
by: Bill Thorne |
last post by:
We have a COM object that has been wrappered for use in .NET and which can
make calls which can take a while to execute. These are mainframe
integration calls that might perform a lot of data...
|
by: Joel Vazquez |
last post by:
Visual Basic.NET Application RunTime Crashes and Stalls
Im a newbie if you could say in .NET ive been working with it the past
3 months and have done lots of things with it, without any prior...
|
by: Jim Devenish |
last post by:
I have converted an Access back-end to SQL Server back-end but am
having some problems. The Access to Access application has been
running well for some years.
I have successfully copied all the...
|
by: BAS |
last post by:
Hi ,
Can anyone throw some light on this,
We have test,dev and production environments with DB2 8.1 fix pack10
running on aix 5.3.
Ours is an ERP finance application module, The reports which...
|
by: Billy |
last post by:
Hi All,
I'm attempting to use the MapNetworkDrive <snippedbelow from entire
code below with very poor performance results.
Basically, I have very small 73kb text files that are rewritten daily...
|
by: yoram.ayalon |
last post by:
we are deploying a ASP.NET 2.0 web application (written in vb.net) to
a windows Server 2003 web edition in which .NET framework 2.0 has been
instaled. the application connects to an Oracle 9i...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |