-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,303 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:drift/drift.dart'; | ||
import 'package:drift/native.dart'; | ||
|
||
part 'reads.g.dart'; | ||
|
||
class Items extends Table { | ||
IntColumn get id => integer().autoIncrement()(); | ||
TextColumn get content => text()(); | ||
} | ||
|
||
@DriftDatabase(tables: [Items]) | ||
final class BenchmarkReadsDatabase extends _$BenchmarkReadsDatabase { | ||
BenchmarkReadsDatabase(super.e); | ||
|
||
@override | ||
int get schemaVersion => 1; | ||
} | ||
|
||
void main() async { | ||
final db = BenchmarkReadsDatabase(NativeDatabase.memory()); | ||
await db.customStatement(''' | ||
WITH RECURSIVE | ||
cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<1000000) | ||
INSERT INTO items (content) SELECT x FROM cnt; | ||
'''); | ||
|
||
print('has items'); | ||
final sw = Stopwatch()..start(); | ||
final items = await db.items.all().get(); | ||
sw.stop(); | ||
|
||
print('Selecting ${items.length}: ${sw.elapsed}'); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.