Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / December 2005

Tip: Looking for answers? Try searching our database.

== Why there is a huge jump in the time used? ==

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
J.J. - 14 Dec 2005 03:42 GMT
Hi,

I've a quetion which has bugged me for quite a while.

I wrote a C#/.NET Web service which is hosted by IIS 5.1 on a Windows XP SP2
machine. This Web service just get the content of the specified txt file and
send the content back to the client. The processing time on the server side
was logged by IIS.
The file sizes and results are listed below (in millisecond):

FileSize:     1K       2K      4K      8K      16K    32K     64K    128K  
256K
TimeUsed:  10.0   10.5   10.5     12.0    14.5    116.0   140.5   141      
151  

As you can seen, the weird thing is, when the file size changes from 16K to
32K, there is big jump in the processing time on the server side. Actually
the jump is between 30K and 31K: when file size is 30K, the time used on the
server side is about 15ms, when file size is 31K, it jumps to about 150ms
(this is the average value. In one of ten, the value is still very small,
like 10-20ms, but most of them are about 150-200ms).

And here is the code I used to implement the Web service:

  public string GetLocalFile(string fileName)
 {
   string returnString = "";

   string filePath = @"C:\Inetpub\wwwroot\Files\";

   string fullName = filePath + fileName;

   StreamReader fs = File.OpenText(fullName);

   returnString = fs.ReadToEnd();

   fs.Close();

   return returnString;  
 }

I am using the following code on the client side to get files:

 private void SendWsFileRequestOut()
 {
   
  long startTime, endTime, elapseTime;

  startTime = DateTime.Now.Ticks;
 
  //Call Web service for the specified file
  fileFetcher.GetLocalFile(fileName);
 
  endTime = DateTime.Now.Ticks;  

  elapseTime = endTime - startTime;

 }

Can anyone help me figure out what the reason could be? Thanks a lot!

J.J.


Randy A. Ynchausti - 14 Dec 2005 08:14 GMT
J.J,

> The file sizes and results are listed below (in millisecond):
>
> FileSize:     1K       2K      4K      8K      16K    32K     64K    128K
> 256K
> TimeUsed:  10.0   10.5   10.5     12.0    14.5    116.0   140.5   141
> 151

FYI, the profiles that I did (running a local incantation of the code you
posted) showed these times:

File Size    Time Spent in SendWsFileRequestOut
(kb)            (milliseconds)
======    ========================
262            70
554            80
1108          95

Regards,

Randy
J.J. - 14 Dec 2005 16:27 GMT
Hello Randy,

For the times you measured, are they logged in IIS log file, or you use some
kind of profiler to get them? Also, are you using XP sp2 too?

I think your results should be the normal ones. I just don't know why this
happened on my computer.

Actually I tried to install the Web service on another clean XP sp2 machine,
and request files from the same client machine. I still got the same jump
between 16K and 32K.

> J.J,
>
[quoted text clipped - 18 lines]
>
> Randy
Randy A. Ynchausti - 15 Dec 2005 06:26 GMT
J.J.,

> For the times you measured, are they logged in IIS log file, or you use
> some
> kind of profiler to get them? Also, are you using XP sp2 too?

To get an off-the-cuff understanding of the code, I created a Console
Application and pasted your code into it with minor changes.  I ran the
DevPartner Profiler free community edition to accumulate the statistics I
noted previously.  I am running Windows XP SP2 on an 2.8GHz Pentinum 4
machine.  Here is part of the profiler output:

     Method Name % in Method % with Children Called Average
     [Program Start] 0 99.6 0 0
     FileReader.Class1.Main 1 25.5 1 3.3
     FileReader.Class1.SendWsFileRequestOut 0.8 24.3 1 2.4
     System.Security.SecurityManager.ResolvePolicy 0.6 23.7 2 1
     FileReader.Class1.GetLocalFile 0.3 23.2 1 0.9
     System.Security.SecurityManager.ResolvePolicy 0.9 22.6 2 1.4
     System.Reflection.Assembly.CreateSecurityIdentity 0.9 13.8 2 1.5
     System.Security.PolicyManager.Resolve 1.8 12.9 2 2.9
     System.IO.File.OpenText 0.3 12.8 1 0.9
     System.AppDomain.SetupDomain 6.3 12.4 1 19.7
     System.IO.StreamReader..ctor 1.2 11.9 1 3.6
     System.Security.Policy.Url..ctor 0.1 11.6 2 0.2
     System.Security.Util.URLString..ctor 1.6 11.4 2 2.5
     System.Security.SecurityManager..cctor 0.1 11.2 1 0.3
     System.Security.SecurityManager.Init 0.1 11.1 1 0.4
     System.Security.SecurityManager.DoInitSecurity 0.2 11 1 0.7
     System.Security.CodeAccessSecurityEngine..ctor 5.5 10.5 1 17.4
     System.IO.StreamReader..ctor 0.5 10.1 1 1.5
     System.Security.Util.URLString.ParseString 1.5 9.6 2 2.4
     System.IO.StreamReader.ReadToEnd 0.5 9.2 1 1.4
     System.IO.FileStream..ctor 2.5 9 1 8
     System.Security.SecurityManager.InitPolicy 0.1 7.8 2 0.1
     System.Security.PolicyManager..ctor 0.7 7.7 1 2.2
     System.Security.Policy.PolicyLevel.Resolve 0.3 7.1 6 0.1
     System.Security.PolicyManager.InitData 1.4 6.8 1 4.4
     System.Security.Policy.PolicyLevel.CheckCache 0.3 6.7 6 0.2
     System.IO.StreamReader.Read 0.2 6.1 555 0
     System.IO.FileStream..ctor 1 5.9 1 3.3
     System.IO.StreamReader.ReadBuffer 0.9 5.9 555 0

> I think your results should be the normal ones. I just don't know why this
> happened on my computer.

Profiling will probably help you understand what is going on.

> Actually I tried to install the Web service on another clean XP sp2
> machine,
> and request files from the same client machine. I still got the same jump
> between 16K and 32K.

Interesting.  Sounds like fun figuring it out.

Regards,

Randy
J.J. - 16 Dec 2005 02:36 GMT
Hi Randy,

Seems you were testing it as a console application instead of a Web service?
Also, seems to me the client and the service were on the same machine, right?

Actually when I test on the same machine, I can also get quite normal
result. But, if I test the Web service by initiating requests from another
machine, the results will be the ones I described before.

Also, I am trying DevPartner free community edition. Since an IE window will
be opened for the Web service, what I get are all for the IE session while
not for the Webmethod of the Web service.

Any thoughts?

Thank you and best wishes,

J.J.

> J.J.,
>
[quoted text clipped - 54 lines]
>
> Randy
J.J. - 14 Dec 2005 18:31 GMT
Hello Randy,

I saw your another answer to my problem in another discussion group. Thank
you so much for your help.

For the "automatic growth" problem, why it doesn't happen in your system?

Thank you and best wishes,

J.J.

> This is probably a result of "automatic growth" (a.k.a. object
> creation/allocation) in the stream reading the file.  You can confirm this
> by using a good allocation profiling tool.

> J.J,
>
[quoted text clipped - 18 lines]
>
> Randy

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.