github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/examples/tracing/jaeger/ruby/rideshare/app/helpers/application_helper.rb (about)

     1  module ApplicationHelper
     2    class << self
     3      def find_nearest_vehicle(radius, vehicle)
     4        burn_cpu(radius)
     5  
     6        check_driver_availability(radius) if vehicle == "car"
     7      end
     8  
     9      private
    10  
    11      def check_driver_availability(radius)
    12        burn_cpu(radius)
    13  
    14        mutex_lock(radius) if "eu-north" == ENV['REGION']
    15      end
    16  
    17      def mutex_lock(radius)
    18        burn_cpu(30 * radius)
    19      end
    20  
    21      def burn_cpu(radius)
    22        from = Time.now.to_f
    23        to = from + radius * 0.1
    24        while Time.now.to_f < to
    25        end
    26      end
    27    end
    28  
    29  end