Skip to content

Commit

Permalink
Add prototype for new query builder
Browse files Browse the repository at this point in the history
  • Loading branch information
simolus3 committed Feb 1, 2025
1 parent 087afb8 commit d17b4b0
Show file tree
Hide file tree
Showing 19 changed files with 1,303 additions and 1 deletion.
33 changes: 33 additions & 0 deletions drift/benchmark/reads.dart
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}');
}
319 changes: 319 additions & 0 deletions drift/benchmark/reads.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d17b4b0

Please sign in to comment.