Several methods of achieving performance goals

xiaoxiao2021-03-06  61

The first time I wrote blog, I hope not to be smiled! First. Adjust the program code 1. Avoid reading the same data multiple times in the cycle statement, if you do not include the unprocessed duplicate execution, such as while (Dr.Read ()) {IF (Dr.Item ["LastName"] == Request.Params ["LastName"]) Return True; Elsereturn False;} In the above loop, each record returned by DataReader is required to request.Params ["Lastname "] For one evaluation, if DR returns 100 records, we evaluate 10 times for Request.Params [" Lastname "], and this 100 times is more than enough, the following code is relative. String strlastname = Request.Params ["LastName"]; while (Dr.Read ()) {if (Dr.Item ["Lastname"] == strlastname) Return True; Elsereturn False;

Summary: The read value from any type of collection is relatively slow, we need to access it multiple times, you can save a copy in local variables.

转载请注明原文地址:https://www.9cbs.com/read-113301.html

New Post(0)