File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
crates/divan_compat/examples/benches Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -2,27 +2,32 @@ fn main() {
22 divan:: main ( ) ;
33}
44
5+ fn busy_sleeping ( duration : std:: time:: Duration ) {
6+ let start = std:: time:: Instant :: now ( ) ;
7+ while start. elapsed ( ) < duration { }
8+ }
9+
510#[ divan:: bench]
611fn sleep_1ns ( ) {
7- std :: thread :: sleep ( std:: time:: Duration :: from_nanos ( 1 ) ) ;
12+ busy_sleeping ( std:: time:: Duration :: from_nanos ( 1 ) ) ;
813}
914
1015#[ divan:: bench]
1116fn sleep_100ns ( ) {
12- std :: thread :: sleep ( std:: time:: Duration :: from_nanos ( 100 ) ) ;
17+ busy_sleeping ( std:: time:: Duration :: from_nanos ( 100 ) ) ;
1318}
1419
1520#[ divan:: bench]
1621fn sleep_1us ( ) {
17- std :: thread :: sleep ( std:: time:: Duration :: from_micros ( 1 ) ) ;
22+ busy_sleeping ( std:: time:: Duration :: from_micros ( 1 ) ) ;
1823}
1924
2025#[ divan:: bench]
2126fn sleep_100us ( ) {
22- std :: thread :: sleep ( std:: time:: Duration :: from_micros ( 100 ) ) ;
27+ busy_sleeping ( std:: time:: Duration :: from_micros ( 100 ) ) ;
2328}
2429
2530#[ divan:: bench]
2631fn sleep_1ms ( ) {
27- std :: thread :: sleep ( std:: time:: Duration :: from_millis ( 1 ) ) ;
32+ busy_sleeping ( std:: time:: Duration :: from_millis ( 1 ) ) ;
2833}
You can’t perform that action at this time.
0 commit comments