@@ -42,6 +42,11 @@ const THREAD_STACK_SIZE: usize = 2048;
42
42
/// Stack size to use for the work queue.
43
43
const WORK_STACK_SIZE : usize = 2048 ;
44
44
45
+ /// This is a global iteration. Small numbers still test functionality within CI, and large numbers
46
+ /// give more meaningful benchmark results.
47
+ const TOTAL_ITERS : usize = 1_000 ;
48
+ // const TOTAL_ITERS: usize = 10_000;
49
+
45
50
#[ no_mangle]
46
51
extern "C" fn rust_main ( ) {
47
52
let tester = ThreadTests :: new ( NUM_THREADS ) ;
@@ -54,33 +59,33 @@ extern "C" fn rust_main() {
54
59
let simple = Simple :: new ( tester. workq . clone ( ) ) ;
55
60
let mut num = 6 ;
56
61
while num < 500 {
57
- simple. run ( num, 10_000 / num) ;
62
+ simple. run ( num, TOTAL_ITERS / num) ;
58
63
num = num * 13 / 10 ;
59
64
}
60
65
61
66
tester. run ( Command :: Empty ) ;
62
- tester. run ( Command :: SimpleSem ( 10_000 ) ) ;
63
- tester. run ( Command :: SimpleSemAsync ( 10_000 ) ) ;
64
- tester. run ( Command :: SimpleSemYield ( 10_000 ) ) ;
65
- tester. run ( Command :: SimpleSemYieldAsync ( 10_000 ) ) ;
66
- tester. run ( Command :: SemWait ( 10_000 ) ) ;
67
- tester. run ( Command :: SemWaitAsync ( 10_000 ) ) ;
68
- tester. run ( Command :: SemWaitSameAsync ( 10_000 ) ) ;
69
- tester. run ( Command :: SemHigh ( 10_000 ) ) ;
70
- tester. run ( Command :: SemPingPong ( 10_000 ) ) ;
71
- tester. run ( Command :: SemPingPongAsync ( 10_000 ) ) ;
72
- tester. run ( Command :: SemOnePingPong ( 10_000 ) ) ;
67
+ tester. run ( Command :: SimpleSem ( TOTAL_ITERS ) ) ;
68
+ tester. run ( Command :: SimpleSemAsync ( TOTAL_ITERS ) ) ;
69
+ tester. run ( Command :: SimpleSemYield ( TOTAL_ITERS ) ) ;
70
+ tester. run ( Command :: SimpleSemYieldAsync ( TOTAL_ITERS ) ) ;
71
+ tester. run ( Command :: SemWait ( TOTAL_ITERS ) ) ;
72
+ tester. run ( Command :: SemWaitAsync ( TOTAL_ITERS ) ) ;
73
+ tester. run ( Command :: SemWaitSameAsync ( TOTAL_ITERS ) ) ;
74
+ tester. run ( Command :: SemHigh ( TOTAL_ITERS ) ) ;
75
+ tester. run ( Command :: SemPingPong ( TOTAL_ITERS ) ) ;
76
+ tester. run ( Command :: SemPingPongAsync ( TOTAL_ITERS ) ) ;
77
+ tester. run ( Command :: SemOnePingPong ( TOTAL_ITERS ) ) ;
73
78
/*
74
- tester.run(Command::SemOnePingPongAsync(NUM_THREADS, 10_000 / 6));
75
- tester.run(Command::SemOnePingPongAsync(20, 10_000 / 20));
76
- tester.run(Command::SemOnePingPongAsync(50, 10_000 / 50));
77
- tester.run(Command::SemOnePingPongAsync(100, 10_000 / 100));
78
- tester.run(Command::SemOnePingPongAsync(500, 10_000 / 500));
79
+ tester.run(Command::SemOnePingPongAsync(NUM_THREADS, TOTAL_ITERS / 6));
80
+ tester.run(Command::SemOnePingPongAsync(20, TOTAL_ITERS / 20));
81
+ tester.run(Command::SemOnePingPongAsync(50, TOTAL_ITERS / 50));
82
+ tester.run(Command::SemOnePingPongAsync(100, TOTAL_ITERS / 100));
83
+ tester.run(Command::SemOnePingPongAsync(500, TOTAL_ITERS / 500));
79
84
tester.run(Command::Empty);
80
85
*/
81
86
let mut num = 6 ;
82
- while num < 500 {
83
- tester. run ( Command :: SemOnePingPongAsync ( num, 10_000 / num) ) ;
87
+ while num < 100 {
88
+ tester. run ( Command :: SemOnePingPongAsync ( num, TOTAL_ITERS / num) ) ;
84
89
num = num * 13 / 10 ;
85
90
}
86
91
@@ -889,8 +894,8 @@ impl Locked {
889
894
/// Benchmark the performance of Arc.
890
895
fn arc_bench ( ) {
891
896
let thing = Arc :: new ( 123 ) ;
892
- let timer = BenchTimer :: new ( "Arc clone+drop" , 10_000 ) ;
893
- for _ in 0 ..10_000 {
897
+ let timer = BenchTimer :: new ( "Arc clone+drop" , TOTAL_ITERS ) ;
898
+ for _ in 0 ..TOTAL_ITERS {
894
899
let _ = thing. clone ( ) ;
895
900
}
896
901
timer. stop ( ) ;
@@ -900,7 +905,7 @@ fn arc_bench() {
900
905
#[ inline( never) ]
901
906
#[ no_mangle]
902
907
fn spin_bench ( ) {
903
- let iters = 10_000 ;
908
+ let iters = TOTAL_ITERS ;
904
909
let thing = SpinMutex :: new ( 123 ) ;
905
910
let timer = BenchTimer :: new ( "SpinMutex lock" , iters) ;
906
911
for _ in 0 ..iters {
@@ -916,7 +921,7 @@ fn spin_bench() {
916
921
#[ inline( never) ]
917
922
#[ no_mangle]
918
923
fn sem_bench ( ) {
919
- let iters = 10_000 ;
924
+ let iters = TOTAL_ITERS ;
920
925
let sem = Semaphore :: new ( iters as u32 , iters as u32 ) ;
921
926
let timer = BenchTimer :: new ( "Semaphore take" , iters) ;
922
927
for _ in 0 ..iters {
0 commit comments