I have to admit this was a surprising benchmark. I've been on the "native code always smokes managed code" side of the fence up until seeing this with my own eyes. Consider also that there is almost no error-checking in the C++ native test, while the ADO.NET code has full error-checking, automatic statement rebuilding on schema changes, type verification, parameter validation, etc. If I were to strip the C# code to the wires it probably would have been an even closer race. If anything, this test validates my assertion that the ADO.NET 2.0 wrapper performs extremely well.
ADO.NET 2.0 Data Provider Comparison
SQLite version 3.2.5 w/ ADO.NET 2.0 Provider version 1.0.18
vs.
SQLite version 3.2.5 native C++ (unmanaged)
Machine:
Intel Pentium 4 3.0ghz, 1gb RAM, SATA HD, Windows Server 2003 SP1 Standard Ed.
Table Definition:
CREATE TABLE Foo ([Id] INTEGER PRIMARY KEY)
Insert Test |
INSERT INTO Foo VALUES(?) Inserting 100,000 rows |
| SQLite |
|
1016ms |
| SQLite C++ |
|
953ms |
| 0 |
(Time in ms, less is better) |
1100 |
| |
DataReader Test |
SELECT * FROM [Foo] Iterating 100,000 rows |
| SQLite |
|
47ms |
| SQLite C++ |
|
31ms |
| 0 |
(Time in ms, less is better) |
100 |
| |
Update Test |
UPDATE [Foo] SET [Id] = ? WHERE [Id] = ? Updating 100,000 rows one at a time |
| SQLite |
|
2937ms |
| SQLite C++ |
|
2593ms |
| 0 |
(Time in ms, less is better) |
3000 |
| |
| Final Database File Size |
| SQLite |
819,200 bytes |
|
| SQLite C++ |
819,200 bytes |
|