lib/rocket_job/batch/performance.rb in rocketjob-5.4.1 vs lib/rocket_job/batch/performance.rb in rocketjob-6.0.0.rc1

- old
+ new

@@ -20,26 +20,37 @@ raise "Please start workers before starting the performance test" if servers.zero? count_running_workers puts "Loading job with #{count} records/lines" - args = {log_level: :warn, slice_size: slice_size} - if defined?(::RocketJob) - args[:compress] = compress - args[:encrypt] = encrypt + job = RocketJob::Jobs::PerformanceJob.new(log_level: :warn) + job.input_category.slice_size = slice_size + if encrypt + job.input_category.serializer = :encrypt + job.output_category.serializer = :encrypt + elsif !compress + job.input_category.serializer = :none + job.output_category.serializer = :none end - job = RocketJob::Jobs::PerformanceJob.new(args) job.upload do |writer| count.times { |i| writer << i } end job.save! puts "Waiting for job to complete" sleep 3 until job.reload.completed? duration = job.completed_at - job.started_at - {count: count, duration: duration, records_per_second: (count.to_f / duration).round(3), workers: workers, servers: servers, compress: compress, encrypt: encrypt} + { + count: count, + duration: duration, + records_per_second: (count.to_f / duration).round(3), + workers: workers, + servers: servers, + compress: compress, + encrypt: encrypt + } end # Export the Results hash to a CSV file def export_results(results) ruby = defined?(JRuby) ? "jruby_#{JRUBY_VERSION}" : "ruby_#{RUBY_VERSION}" @@ -51,17 +62,18 @@ end end # Parse command line options def parse(argv) - parser = OptionParser.new do |o| + parser = OptionParser.new do |o| o.on("-c", "--count COUNT", "Count of records to enqueue") do |arg| self.count = arg.to_i end o.on("-m", "--mongo MONGO_CONFIG_FILE_NAME", "Location of mongoid.yml config file") do |arg| self.mongo_config = arg end - o.on("-e", "--environment ENVIRONMENT", "The environment to run the app on (Default: RAILS_ENV || RACK_ENV || development)") do |arg| + o.on("-e", "--environment ENVIRONMENT", + "The environment to run the app on (Default: RAILS_ENV || RACK_ENV || development)") do |arg| self.environment = arg end o.on("-z", "--compress", "Turn on compression") do self.compress = true end