help, simple codes always takes 15 milliseconds to finish 
Author Message
 help, simple codes always takes 15 milliseconds to finish

Any help will be appreciated.

I am developing a httphandler class to process http request, in the dll, I
have the following code to read snippet info from db:
........
DateTime _start=DateTime.Now;

if(sqlSnippet==null){
   sqlSnippet = sqlConn.CreateCommand();
   sqlSnippet.CommandType = CommandType.StoredProcedure;
   sqlSnippet.CommandText = "NET_Snippet_test";


   sqlSnippet.Prepare();

Quote:
}

sqlSnippet.Parameters[0].Value=sessionID.ToString();
sqlSnippet.Parameters[1].Value=tagContent;

#if (DEBUG)
  WriteTrace("position 1",tagContent,_start);
#endif
        sqlReader = sqlSnippet.ExecuteReader();
#if (DEBUG)
  WriteTrace("position 2",tagContent,_start);
#endif

and for testing, I changed the SP, now it will just return a constant table


As
Begin

int


  begin
  select type=1202,xml='',xsl='select string,id from stringslong where
identitycol=5000433',name='[5000321] Header - Functions Only'
  return
  end
....

I expect the code will run very quickly, but on most situation, it will take
15 milliseconds, since this SP get called very frequently, I have to
optimize it, any idea why it does like that? by the way, the time seems
always 15 milliseconds.

Thanks.



Sun, 30 Jan 2005 01:27:20 GMT  
 help, simple codes always takes 15 milliseconds to finish
David,

1) DateTime is not very accurate for timing short intervals.  Call the
stored procedure many times in a loop for a better measurement or check out
the QueryPerformanceCounter() and QueryPerformanceFrequency api's.

2) I'm not seeing where in code you are taking the difference of the start
time and end times of the block of code you are wanting to time.  Have you
left something out of this post?

3) Measuring the performance of stored procedures is better performed with
the tools provided by the database vendor.  Query Analyzer is great if you
have SQL Server.

Brian


Quote:
> Any help will be appreciated.

> I am developing a httphandler class to process http request, in the dll, I
> have the following code to read snippet info from db:
> ........
> DateTime _start=DateTime.Now;

> if(sqlSnippet==null){
>    sqlSnippet = sqlConn.CreateCommand();
>    sqlSnippet.CommandType = CommandType.StoredProcedure;
>    sqlSnippet.CommandText = "NET_Snippet_test";


>    sqlSnippet.Prepare();
> }

> sqlSnippet.Parameters[0].Value=sessionID.ToString();
> sqlSnippet.Parameters[1].Value=tagContent;

> #if (DEBUG)
>   WriteTrace("position 1",tagContent,_start);
> #endif
>         sqlReader = sqlSnippet.ExecuteReader();
> #if (DEBUG)
>   WriteTrace("position 2",tagContent,_start);
> #endif

> and for testing, I changed the SP, now it will just return a constant
table


> As
> Begin

> int


>   begin
>   select type=1202,xml='',xsl='select string,id from stringslong where
> identitycol=5000433',name='[5000321] Header - Functions Only'
>   return
>   end
> ....

> I expect the code will run very quickly, but on most situation, it will
take
> 15 milliseconds, since this SP get called very frequently, I have to
> optimize it, any idea why it does like that? by the way, the time seems
> always 15 milliseconds.

> Thanks.



Sun, 30 Jan 2005 02:38:04 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. HELP: Open files limit = 15

2. Convert "15.3.1999" or "15.03.99" into CTime

3. Convert "15.3.1999" or "15.03.99" into CTime

4. Just a simple query from a student who just finished a course in C.

5. HELP! conditional code always executes

6. 15+ Digits in C?

7. Will January 15 be the final .NET-Day ?

8. TERM v1.15 on Ultrix

9. Classwizard can only pass 15 args?

10. Not getting DCOM events after 15-20 minutes of proper functioning

11. An excellent OLEDB library with 15 examples

12. bug#15 ddj p124

 

 
Powered by phpBB® Forum Software