I am writing some kind of network testing tool and I have wrote the
following code in ASP.NET with C#
int size= 10048576; // around 10 MB data
string buffer = "";
for (int j=1; j<=1024; j++) {
buffer = String.Concat(buffer, "x");
// I tried buffer += "x"; same performance
}
for (int i=1; i<=(size/1024); i++) {
Response.Write(buffer);
// I tried using <asp:literal> same thing
}
From another computer, I downloaded this file by making that as a link in
HTML. It was so slow.. I get around 8 Mbps on a 100 Mbps LAN.. In order
to compare, I tested with a real JPG file I got 25 Mbps! Also, I wrote the
same thing in PHP using exactly same algorithm. I got around 25 Mbps!
Anyone knows why ASPX performance is slow? is it configruation problem?
IIS? or is it Response.write not good? I also tried using <asp: literal>
same thing.. help..
Thanks in advance 8 2323
Try your test and replace String.Concat with a StringBuilder. Basically in
your current code you are doing string allocations on each pass of the loop.
So what you want is something like:
int size= 10048576; // around 10 MB data
System.Text.StringBuilder sb=new System.Text.StringBuilder()
string buffer = "";
for (int j=1; j<=1024; j++) {
sb.Append("x");
// I tried buffer += "x"; same performance
}
buffer=sb.ToString();
hth
Chris Torgerson
"BlueBall" <ba*************@hotmail.com> wrote in message
news:o2*******************@twister01.bloor.is.net. cable.rogers.com... I am writing some kind of network testing tool and I have wrote the following code in ASP.NET with C#
int size= 10048576; // around 10 MB data string buffer = ""; for (int j=1; j<=1024; j++) { buffer = String.Concat(buffer, "x"); // I tried buffer += "x"; same performance }
for (int i=1; i<=(size/1024); i++) { Response.Write(buffer); // I tried using <asp:literal> same thing }
From another computer, I downloaded this file by making that as a link in HTML. It was so slow.. I get around 8 Mbps on a 100 Mbps LAN.. In order to compare, I tested with a real JPG file I got 25 Mbps! Also, I wrote the same thing in PHP using exactly same algorithm. I got around 25 Mbps!
Anyone knows why ASPX performance is slow? is it configruation problem? IIS? or is it Response.write not good? I also tried using <asp: literal> same thing.. help..
Thanks in advance
String concatenation, whether you user String.Concat or +=, is
incredibly expensive because it makes a new copy of the string every
time. Try this instead:
int size= 10048576; // around 10 MB data
StringBuilder buffer = new StringBuilder(size);
for (int j=1; j<=size; j++)
{
buffer.Append("x");
}
Response.Write(buffer.ToString());
-Jason
BlueBall wrote: I am writing some kind of network testing tool and I have wrote the following code in ASP.NET with C#
int size= 10048576; // around 10 MB data string buffer = ""; for (int j=1; j<=1024; j++) { buffer = String.Concat(buffer, "x"); // I tried buffer += "x"; same performance }
for (int i=1; i<=(size/1024); i++) { Response.Write(buffer); // I tried using <asp:literal> same thing }
From another computer, I downloaded this file by making that as a link in HTML. It was so slow.. I get around 8 Mbps on a 100 Mbps LAN.. In order to compare, I tested with a real JPG file I got 25 Mbps! Also, I wrote the same thing in PHP using exactly same algorithm. I got around 25 Mbps!
Anyone knows why ASPX performance is slow? is it configruation problem? IIS? or is it Response.write not good? I also tried using <asp: literal> same thing.. help..
Thanks in advance
StringBuilder doesn't help because in my code, I don't actually repeat the
buffer generating part.
Try to run it on your IIS, you will see what I mean. In order to verify
this is an ASPX performance problem (or possible my coding algorithm or
config problem), I have created an old fashion ASP page:
<%
dim i, j, size, buffer
size= 10048576
for i = 1 to 1024
buffer = buffer & "x"
next
for j = 1 to (size / 1024)
response.write(buffer)
next
%>
Create a hyper link in a new HTML page and link to this ASP page, and then
create another link that links to ASPX page you wrote (or the one I posted
earlier). You can see the BIG difference in performance. ASP page is
faster than ASPX page at least 3 times... I am frustrated!!!
B.B.
"Jason DeFontes" <ja***@defontes.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl... String concatenation, whether you user String.Concat or +=, is incredibly expensive because it makes a new copy of the string every time. Try this instead:
int size= 10048576; // around 10 MB data StringBuilder buffer = new StringBuilder(size); for (int j=1; j<=size; j++) { buffer.Append("x"); } Response.Write(buffer.ToString());
-Jason
BlueBall wrote:
I am writing some kind of network testing tool and I have wrote the following code in ASP.NET with C#
int size= 10048576; // around 10 MB data string buffer = ""; for (int j=1; j<=1024; j++) { buffer = String.Concat(buffer, "x"); // I tried buffer += "x"; same performance }
for (int i=1; i<=(size/1024); i++) { Response.Write(buffer); // I tried using <asp:literal> same thing }
From another computer, I downloaded this file by making that as a link
in HTML. It was so slow.. I get around 8 Mbps on a 100 Mbps LAN.. In
order to compare, I tested with a real JPG file I got 25 Mbps! Also, I wrote
the same thing in PHP using exactly same algorithm. I got around 25 Mbps!
Anyone knows why ASPX performance is slow? is it configruation problem? IIS? or is it Response.write not good? I also tried using <asp:
literal> same thing.. help..
Thanks in advance
BlueBall wrote: StringBuilder doesn't help because in my code, I don't actually repeat the buffer generating part.
Try to run it on your IIS, you will see what I mean. In order to verify this is an ASPX performance problem (or possible my coding algorithm or config problem), I have created an old fashion ASP page:
<% dim i, j, size, buffer size= 10048576 for i = 1 to 1024 buffer = buffer & "x" next for j = 1 to (size / 1024) response.write(buffer) next %>
Create a hyper link in a new HTML page and link to this ASP page, and then create another link that links to ASPX page you wrote (or the one I posted earlier). You can see the BIG difference in performance. ASP page is faster than ASPX page at least 3 times... I am frustrated!!!
B.B.
I think I can see where your problem is.
By default, ASP does not buffer output whereas ASP.NET does. Therefore,
your ASP code is sending the response directly to the client, whereas
ASP.Net is building the entire output before sending.
Try setting Response.BufferOuput to false in your Page.Load event
handler and then try your test again.
--
Ed Courtenay
[MCP, MCSD] http://www.edcourtenay.co.uk
I tried adding it but that makes the performance even worse...it's like
crawling. I am posting my 2 pieces of codes, so that anyone can try it on
your server. Thanks in advance!
Create a HTML page and make 2 hyper links pointing to these 2 files, then
Right-click -> save target as -> You will see the BIG difference between the
performance between the two.
-------------------------------------------------------
test.aspx
-------------------------------------------------------
<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<script language="C#" runat="server">
void Page_Load() {
// Response.BufferOutput = false;
int size= 10485760; // around 10 MB data
StringBuilder buffer = new StringBuilder(size);
String str = "";
for (int i=1; i<=1024; i++)
buffer.Append("x");
str = buffer.ToString();
for (int j=1; j<=size/1024; j++)
Response.Write(str);
} // load
</script>
-------------------------------------------------------
test.asp
-------------------------------------------------------
<%
dim i, j, size, buffer
size = 10485760
for i = 1 to 1024
buffer = buffer & "x"
next
for j = 1 to (size / 1024)
response.write(buffer)
next
%>
-------------------------------------------------------
"Ed Courtenay" <re*****************************@edcourtenay.co.uk > wrote in
message news:%2****************@tk2msftngp13.phx.gbl... BlueBall wrote: StringBuilder doesn't help because in my code, I don't actually repeat
the buffer generating part.
Try to run it on your IIS, you will see what I mean. In order to verify this is an ASPX performance problem (or possible my coding algorithm or config problem), I have created an old fashion ASP page:
<% dim i, j, size, buffer size= 10048576 for i = 1 to 1024 buffer = buffer & "x" next for j = 1 to (size / 1024) response.write(buffer) next %>
Create a hyper link in a new HTML page and link to this ASP page, and
then create another link that links to ASPX page you wrote (or the one I
posted earlier). You can see the BIG difference in performance. ASP page is faster than ASPX page at least 3 times... I am frustrated!!!
B.B.
I think I can see where your problem is.
By default, ASP does not buffer output whereas ASP.NET does. Therefore, your ASP code is sending the response directly to the client, whereas ASP.Net is building the entire output before sending.
Try setting Response.BufferOuput to false in your Page.Load event handler and then try your test again. --
Ed Courtenay [MCP, MCSD] http://www.edcourtenay.co.uk
Well, I tried it, and your ASP was about 3x *slower* than your ASPX, and
my ASPX with the StringBuilder and only 1 call to Response.Write,
instead of your ~10000 calls, was about 1/3 faster than your ASPX. So
who knows... I imagine there are many, many factors that could affect
this, and our two samples hardly make a conclusive data set.
-Jason
BlueBall wrote: StringBuilder doesn't help because in my code, I don't actually repeat the buffer generating part.
Try to run it on your IIS, you will see what I mean. In order to verify this is an ASPX performance problem (or possible my coding algorithm or config problem), I have created an old fashion ASP page:
<% dim i, j, size, buffer size= 10048576 for i = 1 to 1024 buffer = buffer & "x" next for j = 1 to (size / 1024) response.write(buffer) next %>
Create a hyper link in a new HTML page and link to this ASP page, and then create another link that links to ASPX page you wrote (or the one I posted earlier). You can see the BIG difference in performance. ASP page is faster than ASPX page at least 3 times... I am frustrated!!!
B.B. "Jason DeFontes" <ja***@defontes.com> wrote in message news:%2***************@tk2msftngp13.phx.gbl...
String concatenation, whether you user String.Concat or +=, is incredibly expensive because it makes a new copy of the string every time. Try this instead:
int size= 10048576; // around 10 MB data StringBuilder buffer = new StringBuilder(size); for (int j=1; j<=size; j++) { buffer.Append("x"); } Response.Write(buffer.ToString());
-Jason
BlueBall wrote:
I am writing some kind of network testing tool and I have wrote the following code in ASP.NET with C#
int size= 10048576; // around 10 MB data string buffer = ""; for (int j=1; j<=1024; j++) { buffer = String.Concat(buffer, "x"); // I tried buffer += "x"; same performance }
for (int i=1; i<=(size/1024); i++) { Response.Write(buffer); // I tried using <asp:literal> same thing }
From another computer, I downloaded this file by making that as a link in HTML. It was so slow.. I get around 8 Mbps on a 100 Mbps LAN.. In order to compare, I tested with a real JPG file I got 25 Mbps! Also, I wrote the same thing in PHP using exactly same algorithm. I got around 25 Mbps!
Anyone knows why ASPX performance is slow? is it configruation problem? IIS? or is it Response.write not good? I also tried using <asp: literal> same thing.. help..
Thanks in advance
"BlueBall" <ba*************@hotmail.com> wrote in message news:o2*******************@twister01.bloor.is.net. cable.rogers.com... I am writing some kind of network testing tool and I have wrote the following code in ASP.NET with C#
int size= 10048576; // around 10 MB data string buffer = ""; for (int j=1; j<=1024; j++) { buffer = String.Concat(buffer, "x"); // I tried buffer += "x"; same performance }
for (int i=1; i<=(size/1024); i++) { Response.Write(buffer); // I tried using <asp:literal> same thing }
From another computer, I downloaded this file by making that as a link in HTML. It was so slow.. I get around 8 Mbps on a 100 Mbps LAN.. In order to compare, I tested with a real JPG file I got 25 Mbps! Also, I wrote the same thing in PHP using exactly same algorithm. I got around 25 Mbps!
Anyone knows why ASPX performance is slow? is it configruation problem? IIS? or is it Response.write not good? I also tried using <asp: literal> same thing.. help..
Thanks in advance
In addition to the other replies:
When did you time the performance? The first time an aspx page
is accessed, it gets compiled to native code. This will have a performance
hit, but only the first time this page is accessed (in the lifetime
of the application).
Neither php or asp have this automatic compile feature so there
you get no speed dirrerence between the first and second time.
Hans Kesting
1. You should try to use StringBuilder for concatenation. This will greatly
improve performance.
2. You are outputting buffer 9813 times. The problem is that ASP.NET saves
the output into temporary buffer and only when you done it outputs the
buffer to browser. The size of the buffer is preset to something big but
much less than 10Mb. And ASP.NET has to constantly expand the buffer as
needed when you are outputting it. Which is a big performance hit.
If you just bluntly set Response.Buffer = false then you going to have
another problem since ASP.NET will have to use IIS APIs every time you do
Response.Write which is another performance hit.
You can minimize it by seting Response.Buffer = true but calling
Response.Flush every 20th time.
George.
"BlueBall" <ba*************@hotmail.com> wrote in message
news:o2*******************@twister01.bloor.is.net. cable.rogers.com... I am writing some kind of network testing tool and I have wrote the following code in ASP.NET with C#
int size= 10048576; // around 10 MB data string buffer = ""; for (int j=1; j<=1024; j++) { buffer = String.Concat(buffer, "x"); // I tried buffer += "x"; same performance }
for (int i=1; i<=(size/1024); i++) { Response.Write(buffer); // I tried using <asp:literal> same thing }
From another computer, I downloaded this file by making that as a link in HTML. It was so slow.. I get around 8 Mbps on a 100 Mbps LAN.. In order to compare, I tested with a real JPG file I got 25 Mbps! Also, I wrote the same thing in PHP using exactly same algorithm. I got around 25 Mbps!
Anyone knows why ASPX performance is slow? is it configruation problem? IIS? or is it Response.write not good? I also tried using <asp: literal> same thing.. help..
Thanks in advance
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Bailo |
last post by:
I wrote a webservice to output a report file. The fields of the report
are formatted based on information in an in-memory XmlDocument. As
each row of a SqlDataReader are looped through, a...
|
by: Scott |
last post by:
I have a customer that had developed an Access97 application to track
their business information. The application grew significantly and
they used the Upsizing Wizard to move the tables to SQL...
|
by: Bob Alston |
last post by:
Most of my Access database implementations have been fairly small in
terms of data volume and number of concurrent users. So far I haven't
had performance issues to worry about. <knock on wood>
...
|
by: Martin |
last post by:
I am using graphics as backgrounds for forms,buttons,labels etc.
The question is: is it faster to load all graphics from files on app start
or
to use it embeded (places in editor during design)....
|
by: jdipalmajr |
last post by:
I am using a strongly typed dataset with a design time schema. I load
data into the dataset tables from xml. The problem I am having is
after the XML load. The first time I Add a row to a table...
| |
by: BlueBall |
last post by:
I am writing some kind of network testing tool and I have wrote the
following code in ASP.NET with C#
int size= 10048576; // around 10 MB data
string buffer = "";
for (int j=1; j<=1024;...
|
by: Mario Soto |
last post by:
Hi. i hava a postresql 7.4.2 in a production server.
tha machine is a Pentium IV 2,6 GHZ AND 1 GB IN RAM with lINUX RH 9.0.
The postresql.conf say:
...
|
by: frankgerlach |
last post by:
>From my simple performance tests of SOAP it seems that it is about ten
times slower than binary object request protocols such as RMI, IIOP or
SimpleORB.
Is this also YOUR experience ?
|
by: Ryan Liu |
last post by:
Hi,
I spend most time works on Windows form application and VS 2008 runs at a
acceptable speed.
While I edit aspx file, especially change to Designer View, it seems very
slow.
Some time...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |