-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Enhance performance tests and add insertion_and_removal (#53)
- Loading branch information
1 parent
882d9fc
commit 2495b5e
Showing
5 changed files
with
172 additions
and
109 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 |
---|---|---|
|
@@ -11,7 +11,7 @@ jobs: | |
- uses: dart-lang/setup-dart@v1 | ||
- run: dart pub get | ||
|
||
- uses: luanpotter/[email protected].10 | ||
- uses: luanpotter/[email protected].11 | ||
with: | ||
paths: "." | ||
ignore-tag: "no-benchmark" | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:benchmark_harness/benchmark_harness.dart'; | ||
import 'package:ordered_set/ordered_set.dart'; | ||
|
||
import '../test/comparable_object.dart'; | ||
|
||
const _iterationAmount = 1000; | ||
|
||
class InsertionAndRemovalBenchmark extends BenchmarkBase { | ||
late final OrderedSet<ComparableObject> set; | ||
late final Map<int, ComparableObject> objects; | ||
|
||
InsertionAndRemovalBenchmark() : super('Insertion and Removal Benchmark'); | ||
|
||
static void main() { | ||
InsertionAndRemovalBenchmark().report(); | ||
} | ||
|
||
@override | ||
void setup() { | ||
set = OrderedSet<ComparableObject>(); | ||
objects = { | ||
for (var i = 0; i < _iterationAmount; i++) i: ComparableObject(i, '$i'), | ||
}; | ||
} | ||
|
||
@override | ||
void exercise() { | ||
for (var i = 0; i < _iterationAmount; i++) { | ||
set.add(objects[i]!); | ||
} | ||
|
||
for (var i = 0; i < _iterationAmount; i++) { | ||
set.remove(objects[i]!); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import 'comprehensive_benchmark.dart'; | ||
import 'insertion_and_removal_benchmark.dart'; | ||
import 'iteration_benchmark.dart'; | ||
|
||
void main() { | ||
IterationBenchmark.main(); | ||
InsertionAndRemovalBenchmark.main(); | ||
ComprehensiveBenchmark.main(); | ||
} |