@@ -1319,3 +1319,89 @@ mod tests {
13191319 // the full set of tests
13201320 }
13211321}
1322+
1323+ #[ cfg( test) ]
1324+ mod bench {
1325+ use extra:: test:: BenchHarness ;
1326+ use super :: * ;
1327+
1328+ #[ bench]
1329+ fn join_home_dir ( bh : & mut BenchHarness ) {
1330+ let posix_path = Path :: new ( "/" ) ;
1331+ bh. iter ( || {
1332+ posix_path. join ( "home" ) ;
1333+ } ) ;
1334+ }
1335+
1336+ #[ bench]
1337+ fn join_abs_path_home_dir ( bh : & mut BenchHarness ) {
1338+ let posix_path = Path :: new ( "/" ) ;
1339+ bh. iter ( || {
1340+ posix_path. join ( "/home" ) ;
1341+ } ) ;
1342+ }
1343+
1344+ #[ bench]
1345+ fn join_many_home_dir ( bh : & mut BenchHarness ) {
1346+ let posix_path = Path :: new ( "/" ) ;
1347+ bh. iter ( || {
1348+ posix_path. join_many ( & [ "home" ] ) ;
1349+ } ) ;
1350+ }
1351+
1352+ #[ bench]
1353+ fn join_many_abs_path_home_dir ( bh : & mut BenchHarness ) {
1354+ let posix_path = Path :: new ( "/" ) ;
1355+ bh. iter ( || {
1356+ posix_path. join_many ( & [ "/home" ] ) ;
1357+ } ) ;
1358+ }
1359+
1360+ #[ bench]
1361+ fn push_home_dir ( bh : & mut BenchHarness ) {
1362+ let mut posix_path = Path :: new ( "/" ) ;
1363+ bh. iter ( || {
1364+ posix_path. push ( "home" ) ;
1365+ } ) ;
1366+ }
1367+
1368+ #[ bench]
1369+ fn push_abs_path_home_dir ( bh : & mut BenchHarness ) {
1370+ let mut posix_path = Path :: new ( "/" ) ;
1371+ bh. iter ( || {
1372+ posix_path. push ( "/home" ) ;
1373+ } ) ;
1374+ }
1375+
1376+ #[ bench]
1377+ fn push_many_home_dir ( bh : & mut BenchHarness ) {
1378+ let mut posix_path = Path :: new ( "/" ) ;
1379+ bh. iter ( || {
1380+ posix_path. push_many ( & [ "home" ] ) ;
1381+ } ) ;
1382+ }
1383+
1384+ #[ bench]
1385+ fn push_many_abs_path_home_dir ( bh : & mut BenchHarness ) {
1386+ let mut posix_path = Path :: new ( "/" ) ;
1387+ bh. iter ( || {
1388+ posix_path. push_many ( & [ "/home" ] ) ;
1389+ } ) ;
1390+ }
1391+
1392+ #[ bench]
1393+ fn ends_with_path_home_dir ( bh : & mut BenchHarness ) {
1394+ let posix_home_path = Path :: new ( "/home" ) ;
1395+ bh. iter ( || {
1396+ posix_home_path. ends_with_path ( & Path :: new ( "home" ) ) ;
1397+ } ) ;
1398+ }
1399+
1400+ #[ bench]
1401+ fn ends_with_path_missmatch_jome_home ( bh : & mut BenchHarness ) {
1402+ let posix_home_path = Path :: new ( "/home" ) ;
1403+ bh. iter ( || {
1404+ posix_home_path. ends_with_path ( & Path :: new ( "jome" ) ) ;
1405+ } ) ;
1406+ }
1407+ }
0 commit comments