-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from IO-Design-Team/feature/better-storage-ben…
…chmark Better storage benchmark
- Loading branch information
Showing
21 changed files
with
115 additions
and
91 deletions.
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 |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
# Created by `dart pub` | ||
.dart_tool/ | ||
|
||
hive_registrar.g.dart | ||
hive_registrar.g.dart | ||
results.csv |
File renamed without changes.
File renamed without changes.
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,80 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:csv/csv.dart'; | ||
import 'package:hive/hive.dart' as v4; | ||
import 'package:hive_ce/hive.dart' as ce; | ||
import 'package:hive_storage_benchmark/bench_result.dart'; | ||
import 'package:hive_storage_benchmark/benchmark.dart'; | ||
import 'package:hive_storage_benchmark/db_type.dart'; | ||
import 'package:hive_storage_benchmark/test_model.dart'; | ||
import 'package:isar/isar.dart'; | ||
|
||
const benchmarks = [ | ||
10, | ||
100, | ||
1000, | ||
10000, | ||
100000, | ||
1000000, | ||
]; | ||
|
||
void main() async { | ||
ce.Hive | ||
..init('.') | ||
..registerAdapter(TestModelAdapter()); | ||
|
||
await Isar.initialize('assets/libisar_macos.dylib'); | ||
|
||
v4.Hive.defaultDirectory = '.'; | ||
v4.Hive.registerAdapter('TestModel', (json) => TestModel.fromJson(json)); | ||
|
||
final ceResults = <BenchResult>[]; | ||
final v4Results = <BenchResult>[]; | ||
|
||
for (final operations in benchmarks) { | ||
final ceResult = await runBenchmark( | ||
operations: operations, | ||
type: DbType.hive, | ||
openBox: ce.Hive.openBox, | ||
); | ||
|
||
final v4Result = await runBenchmark( | ||
operations: operations, | ||
type: DbType.isar, | ||
openBox: (name) => v4.Hive.box(name: name, maxSizeMiB: 1024), | ||
); | ||
|
||
ceResults.add(ceResult); | ||
v4Results.add(v4Result); | ||
} | ||
|
||
final csv = const ListToCsvConverter().convert([ | ||
[ | ||
'Operations', | ||
'Hive CE Time', | ||
'Hive CE Size', | ||
'Hive v4 Time', | ||
'Hive v4 Size', | ||
], | ||
for (var i = 0; i < benchmarks.length; i++) | ||
[ | ||
benchmarks[i], | ||
formatTime(ceResults[i].time), | ||
formatSize(ceResults[i].size), | ||
formatTime(v4Results[i].time), | ||
formatSize(v4Results[i].size), | ||
], | ||
]); | ||
|
||
File('results.csv').writeAsStringSync(csv); | ||
} | ||
|
||
// Format a duration to "00.00 s" | ||
String formatTime(Duration duration) { | ||
final seconds = duration.inMilliseconds / 1000; | ||
return '${seconds.toStringAsFixed(2)} s'; | ||
} | ||
|
||
String formatSize(double size) { | ||
return '${size.toStringAsFixed(2)} MB'; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,9 @@ | ||
class BenchResult { | ||
final Duration time; | ||
final double size; | ||
|
||
const BenchResult({ | ||
required this.time, | ||
required this.size, | ||
}); | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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