Skip to content

Instantly share code, notes, and snippets.

View mlyubarskyy's full-sized avatar

Michael Liubarskyi mlyubarskyy

View GitHub Profile
diff --git a/app/services/car_importer.rb b/app/services/car_importer.rb
index d0a8d8f..f48319e 100644
--- a/app/services/car_importer.rb
+++ b/app/services/car_importer.rb
@@ -1,5 +1,6 @@
require 'open-uri'
require 'net/smtp'
+require 'benchmark'
module CarImporter
class QuickieParallel
attr_accessor :results
def initialize(args)
@num_procs = args.fetch(:num_processes, 4)
@using_db = args.fetch(:using_db, false)
@debug = args.fetch(:debug, false)
@results = {}
end
def finish_callback(val, index, result)
class Object
def log_with_time txt=nil, thld=100, with_stat=nil, &block
with_stat ||= false
start = Time.now
result = yield
taken = ((Time.now - start) * 1000).round(1)
dbg = ["===="]
dbg << txt.to_s.ljust(50) if txt