File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -1404,4 +1404,45 @@ mod bench {
14041404 posix_home_path. ends_with_path ( & Path :: new ( "jome" ) ) ;
14051405 } ) ;
14061406 }
1407+
1408+ #[ bench]
1409+ fn is_ancestor_of_path_with_10_dirs ( bh : & mut BenchHarness ) {
1410+ let path = Path :: new ( "/home/1/2/3/4/5/6/7/8/9" ) ;
1411+ let mut sub = path. clone ( ) ;
1412+ sub. pop ( ) ;
1413+ bh. iter ( || {
1414+ path. is_ancestor_of ( & sub) ;
1415+ } ) ;
1416+ }
1417+
1418+ #[ bench]
1419+ fn path_relative_from_forward ( bh : & mut BenchHarness ) {
1420+ let path = Path :: new ( "/a/b/c" ) ;
1421+ let mut other = path. clone ( ) ;
1422+ other. pop ( ) ;
1423+ bh. iter ( || {
1424+ path. path_relative_from ( & other) ;
1425+ } ) ;
1426+ }
1427+
1428+ #[ bench]
1429+ fn path_relative_from_same_level ( bh : & mut BenchHarness ) {
1430+ let path = Path :: new ( "/a/b/c" ) ;
1431+ let mut other = path. clone ( ) ;
1432+ other. pop ( ) ;
1433+ other. push ( "d" ) ;
1434+ bh. iter ( || {
1435+ path. path_relative_from ( & other) ;
1436+ } ) ;
1437+ }
1438+
1439+ #[ bench]
1440+ fn path_relative_from_backward ( bh : & mut BenchHarness ) {
1441+ let path = Path :: new ( "/a/b" ) ;
1442+ let mut other = path. clone ( ) ;
1443+ other. push ( "c" ) ;
1444+ bh. iter ( || {
1445+ path. path_relative_from ( & other) ;
1446+ } ) ;
1447+ }
14071448}
You can’t perform that action at this time.
0 commit comments