StartTransaction(); for( $i = 0; $i < $max_jobs; $i++ ) { $sjqf->setStatus( 10 ); //10=Pending $sjqf->setName( 'Job' . time() ); $sjqf->setUser( TTUUID::getZeroID() ); $sjqf->setEffectiveDate( microtime( true ) ); $sjqf->setClass( 'Misc' ); $sjqf->setMethod( 'ArrayAvg' ); $sjqf->setArguments( [ 0 => [ 1, 2, 3 ] ] ); //Each top level array element is an argument. if ( $sjqf->isValid() ) { $sjqf->Save(); } } $generated_time = ( ( microtime(true) - $generate_jobs_start_epoch ) ); echo " Completed in ". round( $generated_time, 4 ) ."s Rate: ". round( ( $max_jobs / $generated_time ), 4 ) ."/s\n"; //Before commiting transaction, count how many jobs are pending. $sjqlf = new SystemJobQueueListFactory(); $initial_queue_status = $sjqlf->getQueueStatus(); $sjqf->CommitTransaction(); // // Monitor how many jobs are being processed per second. // $initial_pending_jobs = $initial_queue_status[10]; $monitor_start_epoch = microtime( true ); global $config_vars; if ( !isset( $config_vars['other']['max_processes'] ) ) { $config_vars['other']['max_processes'] = 2; } echo "Monitoring Completed Jobs: ". date('r') ." Total Worker Processes: ". $config_vars['other']['max_processes'] ."\n"; $i = 0; while( 1 ) { $queue_status_arr = $sjqlf->getQueueStatus(); $jobs_completed = ( $initial_pending_jobs - $queue_status_arr[10] ); $elapsed_time_seconds = ( ( microtime( true ) - $monitor_start_epoch ) ); if ( $jobs_completed > 0 ) { $processing_rate = ( $jobs_completed / $elapsed_time_seconds ); } else { $processing_rate = 0; } echo " Pending Jobs: ". $queue_status_arr[10] .' Completed: '. $jobs_completed .' Elapsed Time: '. round( $elapsed_time_seconds, 4 ) .'s Rate: '. round( $processing_rate, 4 ) ."/s \n"; if ( $queue_status_arr[10] == 0 ) { echo "All Jobs Completed: ". date('r') ." Total Worker Processes: ". $config_vars['other']['max_processes'] ."\n"; break; } if ( $i < 100 ) { usleep( 100000 ); } else { sleep( 1 ); } $i++; } } echo "Done...\n"; Debug::WriteToLog(); //Debug::Display(); ?>