Skip to content

Commit

Permalink
Simple benchmark for validation
Browse files Browse the repository at this point in the history
  • Loading branch information
leoafarias committed Oct 4, 2023
1 parent b601c7b commit 019c23e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ packages:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051
sha256: ae92f5d747aee634b87f89d9946000c2de774be1d6ac3e58268224348cd0101a
url: "https://pub.dev"
source: hosted
version: "64.0.0"
version: "61.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893"
sha256: ea3d8652bda62982addfd92fdc2d0214e5f82e43325104990d4f4c4a2a313562
url: "https://pub.dev"
source: hosted
version: "6.2.0"
version: "5.13.0"
archive:
dependency: transitive
description:
Expand Down
23 changes: 23 additions & 0 deletions test/utils/which_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:fvm/src/utils/which.dart';
import 'package:test/test.dart';

void main() {
// Benchmark test for `which` function
// Using a simplistic loop to measure performance.
// For a more accurate benchmark, consider using a benchmarking package.
test('Benchmark: which function', () {
const totalIterations = 1000;
// Setup specific environment variables, as above.
var startTime = DateTime.now();
for (int i = 0; i < totalIterations; i++) {
which('command', binDir: false);
}
var endTime = DateTime.now();
var elapsedTime = endTime.difference(startTime);
print(
'Time taken for $totalIterations iterations: ${elapsedTime.inMilliseconds}ms');
print(
'Time taken for 1 iteration: ${elapsedTime.inMilliseconds / totalIterations}ms',
);
});
}

0 comments on commit 019c23e

Please sign in to comment.