1
1
use criterion:: { black_box, criterion_group, criterion_main, Criterion } ;
2
2
use std:: path:: Path ;
3
+ use std:: time:: Duration ;
3
4
use pnp:: fs:: VPath ;
4
5
5
6
fn bench_vpath_native ( c : & mut Criterion ) {
@@ -9,7 +10,7 @@ fn bench_vpath_native(c: &mut Criterion) {
9
10
"/home/user/project/src/main.rs" ,
10
11
"/very/long/path/with/many/segments/that/could/be/expensive/to/parse" ,
11
12
] ;
12
-
13
+
13
14
c. bench_function ( "vpath_native" , |b| {
14
15
b. iter ( || {
15
16
for path in & paths {
@@ -26,7 +27,7 @@ fn bench_vpath_virtual(c: &mut Criterion) {
26
27
"/deep/path/__virtual__/ghi789/1/node_modules/nested/package/src/file.ts" ,
27
28
"/complex/__virtual__/jkl012/3/node_modules/very-long-package-name/dist/bundle.js" ,
28
29
] ;
29
-
30
+
30
31
c. bench_function ( "vpath_virtual" , |b| {
31
32
b. iter ( || {
32
33
for path in & paths {
@@ -43,7 +44,7 @@ fn bench_vpath_zip(c: &mut Criterion) {
43
44
"/project/deps/bundle.zip/dist/app.js" ,
44
45
"/deep/path/to/package.zip/nested/file.json" ,
45
46
] ;
46
-
47
+
47
48
c. bench_function ( "vpath_zip" , |b| {
48
49
b. iter ( || {
49
50
for path in & paths {
@@ -59,7 +60,7 @@ fn bench_vpath_virtual_zip(c: &mut Criterion) {
59
60
"/project/__virtual__/def456/2/node_modules/some-package/bundle.zip/dist/app.js" ,
60
61
"/deep/path/__virtual__/ghi789/1/node_modules/nested/package.zip/src/file.ts" ,
61
62
] ;
62
-
63
+
63
64
c. bench_function ( "vpath_virtual_zip" , |b| {
64
65
b. iter ( || {
65
66
for path in & paths {
@@ -81,7 +82,7 @@ fn bench_vpath_edge_cases(c: &mut Criterion) {
81
82
"/malformed/__virtual__/incomplete" ,
82
83
"/fake/__virtual__/abc123/not_a_number/path" ,
83
84
] ;
84
-
85
+
85
86
c. bench_function ( "vpath_edge_cases" , |b| {
86
87
b. iter ( || {
87
88
for path in & paths {
@@ -102,7 +103,7 @@ fn bench_vpath_mixed_workload(c: &mut Criterion) {
102
103
"/project/deps/bundle.zip/nested/file.json" ,
103
104
"/home/user/project/src/main.rs" ,
104
105
] ;
105
-
106
+
106
107
c. bench_function ( "vpath_mixed_workload" , |b| {
107
108
b. iter ( || {
108
109
for path in & paths {
@@ -112,13 +113,10 @@ fn bench_vpath_mixed_workload(c: &mut Criterion) {
112
113
} ) ;
113
114
}
114
115
115
- criterion_group ! (
116
- benches,
117
- bench_vpath_native,
118
- bench_vpath_virtual,
119
- bench_vpath_zip,
120
- bench_vpath_virtual_zip,
121
- bench_vpath_edge_cases,
122
- bench_vpath_mixed_workload,
123
- ) ;
116
+ criterion_group ! {
117
+ name = benches;
118
+ config = Criterion :: default ( ) . sample_size( 1000 ) . measurement_time( Duration :: from_secs( 10 ) ) ;
119
+ targets = bench_vpath_native, bench_vpath_virtual, bench_vpath_zip, bench_vpath_virtual_zip, bench_vpath_edge_cases, bench_vpath_mixed_workload
120
+ }
121
+
124
122
criterion_main ! ( benches) ;
0 commit comments