@@ -11,6 +11,8 @@ const argv = require('yargs')
11
11
. help ( 'h' )
12
12
. describe ( 'workload' , 'Simulate a read workload' )
13
13
. describe ( 'writeWorkload' , 'Simulate a write workload' )
14
+ . describe ( 'writeWorkloadInterval' , 'Time interval between write workload write attempts' )
15
+ . describe ( 'writeWorkloadSampleSize' , 'Sample size between status display for write workload' )
14
16
. describe ( 'legacy' , 'Use the legacy topology types' )
15
17
. alias ( 'l' , 'legacy' )
16
18
. alias ( 'w' , 'workload' )
@@ -76,10 +78,13 @@ async function scheduleWorkload(client) {
76
78
let writeWorkloadTimer ;
77
79
let writeWorkloadCounter = 0 ;
78
80
let averageWriteMS = 0 ;
81
+ let completedWriteWorkloads = 0 ;
82
+ const writeWorkloadSampleSize = argv . writeWorkloadSampleSize || 100 ;
83
+ const writeWorkloadInterval = argv . writeWorkloadInterval || 100 ;
79
84
async function scheduleWriteWorkload ( client ) {
80
85
if ( ! workloadInterrupt ) {
81
86
// immediately reschedule work
82
- writeWorkloadTimer = setTimeout ( ( ) => scheduleWriteWorkload ( client ) , 200 ) ;
87
+ writeWorkloadTimer = setTimeout ( ( ) => scheduleWriteWorkload ( client ) , writeWorkloadInterval ) ;
83
88
}
84
89
85
90
const currentWriteWorkload = writeWorkloadCounter ++ ;
@@ -89,8 +94,9 @@ async function scheduleWriteWorkload(client) {
89
94
const result = await client . db ( 'test' ) . collection ( 'test' ) . insertOne ( { a : 42 } ) ;
90
95
averageWriteMS = 0.2 * calculateDurationInMs ( start ) + 0.8 * averageWriteMS ;
91
96
92
- if ( currentWriteWorkload % 100 ) {
93
- print ( `${ chalk . yellow ( `workload#${ currentWriteWorkload } ` ) } completed 100 writes with average time: ${ averageWriteMS } ` ) ;
97
+ completedWriteWorkloads ++ ;
98
+ if ( completedWriteWorkloads % writeWorkloadSampleSize === 0 ) {
99
+ print ( `${ chalk . yellow ( `workload#${ currentWriteWorkload } ` ) } completed ${ completedWriteWorkloads } writes with average time: ${ averageWriteMS } ` ) ;
94
100
}
95
101
96
102
} catch ( e ) {
0 commit comments