I used to think that Repeater is more efficient than DataGrid, but I don't know if I don't test it. A test is a fright!
I used the stress testing software (ACT) that comes with vs to test the performance of the two, and measured by the number of accessible users per second.
However, the result is beyond my expectation that the DataGrid is more efficient than the Repeater!
Let's take a closer look at my testing methods. Are there any problems with my testing methods? If there are no problems, what is the cause of this imagination?
Hardware: cpu: AMD XP2000 +, 80 GB hard disk, MB memory.
Software: windows 2003 + sp1, Vs2003, SQL Server 2000 + sp4
Test data: displays data in a table (city table) with four fields and 349 records.
Objective: To view Data efficiency on a website page. Only test the data display function, regardless of other aspects.
Test conditions:
1. Whether ViewState is enabled
2. 10 records and 349 records are displayed.
3. DataGrid and Repeater
In general, the DataGrid is always "accommodating" dozens of people more than the Repeater.
Especially when ViewState is disabled.
The DataGrid uses the automatic filling and repeater code.
<Table id = "DG">
<Asp: repeater id = "Rpt_Test" runat = "server">
<ItemTemplate>
<Tr>
<Td> <% # DataBinder. Eval (Container, "DataItem. CityID") %> </td>
<Td> <% # DataBinder. Eval (Container, "DataItem. ProvinceID") %>
</Td>
<Td> <% # DataBinder. Eval (Container, "DataItem. City") %>
</Td>
<Td> <% # DataBinder. Eval (Container, "DataItem. AeraCode") %>
</Td>
</Tr>
</ItemTemplate>
</Asp: repeater> </table>
Is there any other binding method for repeater?
I often see some articles saying that repeater is better than DataGrid, but what is the result of my test?
We recommend that you perform such a test. I doubt my test results, but I cannot find any reason.
I hope you can study it together.
Latest test results:
10 records are displayed without ViewState. DataTable binds the control, and DataGrid binds the column.
1. DataGrid: around 250 rps.
2. Repeater: <% # DataBinder. Eval (Container, "DataItem. CityID") %> method: around 200 rps.
3. Repeater: <% # (DataRowView) Container. DataItem) ["CityID"] %> method: 250 rps a little more.
4. Repeater: <% # (DataRowView) Container. DataItem) [0] %> method: 250 rps a little more.
Among them, 3 and 4 are a data binding method I just found.
It seems that the binding method <% # DataBinder. Eval (Container, "DataItem. CityID") %> is too inefficient.
I have been using this method all the time. What about you?
Multi-Data Testing
349 records are displayed on one page. No ViewState is displayed. The DataTable is bound to the control, and the DataGrid is bound to the column.
1. DataGrid: Between 50 and 60 rps.
2. Repeater: <% # DataBinder. Eval (Container, "DataItem. CityID") %> method: around 20 rps.
3. Repeater: <% # (DataRowView) Container. DataItem) ["CityID"] %> method: around 88 rps.
4. Repeater: <% # (DataRowView) Container. DataItem) [0] %> method: About 90 rps.
1 DataGrid
Reprinted ==============================
3. Data Binding DataBinder
General Binding method <% # DataBinder. Eval (Container. DataItem, "field name") %> Use DataBinder. eval to bind data source (Dataread or dataset ). The data type eval will convert the data object into a string. It does a lot of work on the underlying binding and uses the reflection performance. This is because it is easy to use, but affects data performance. Let's see <% # DataBinder. Eval (Container. DataItem, "field name") %>. When dataset is bound, DataItem is actually a DataRowView (if it is bound to a data reader (dataread), it is an IdataRecord .) Therefore, directly converting to DataRowView will greatly improve the performance.
<% # Ctype (Container. DataItem, DataRowView). Row ("field name") %>
* We recommend that you use <% # ctype (Container. DataItem, DataRowView). Row ("field name") %> to bind data. When the data volume is large, the speed can be increased by several hundred times. NOTE 2: 1. Add <% @ Import namespace = "System. Data" %>. 2. Note the case sensitivity of the field name ). If it is inconsistent with the query, it may be slower than <% # DataBinder. Eval (Container. DataItem, "field name") %> in some cases. To further increase the speed, you can use the <% # ctype (Container. DataItem, DataRowView). Row (0) %> method. But its readability is not high.
The above is the vb.net method. In c #: <@ % (DataRowView) Container. DataItem) ["field name"] %>