Sha256: 06cef76065bca54d5af349b169ecf6ce7702ba34f96657f1be328ba384420753
Contents?: true
Size: 1.52 KB
Versions: 8
Compression:
Stored size: 1.52 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' gemspec = Dir.glob(File.expand_path("../../*.gemspec", __FILE__)).first spec = Gem::Specification.load(gemspec) # Add the require paths to the $LOAD_PATH spec.require_paths.each do |path| full_path = File.expand_path("../" + path, __dir__) $LOAD_PATH.unshift(full_path) unless $LOAD_PATH.include?(full_path) end spec.require_paths.each do |path| require "./lib/prefab-cloud-ruby" end require 'prefab-cloud-ruby' $prefab = Prefab::Client.new(collect_logger_counts: false, collect_evaluation_summaries: false, context_upload_mode: :none) $prefab.get('prefab.auth.allowed_origins') puts '-' * 80 require 'allocation_stats' $runs = 100 def measure(description) puts "Measuring #{description}..." stats = $prefab.with_context(user: { email_suffix: 'yahoo.com' }) do AllocationStats.trace do $runs.times do yield end end end allocations = stats.allocations(alias_paths: true).group_by(:sourcefile, :sourceline, :class) if ENV['TOP'] puts allocations.sort_by_size.to_text.split("\n").first(20) end puts "Total allocations: #{allocations.all.values.map(&:size).sum}" puts "Total memory: #{allocations.all.values.flatten.map(&:memsize).sum}" puts stats.gc_profiler_report end measure "no-JIT context (#{$runs} runs)" do $prefab.get('prefab.auth.allowed_origins') end puts "\n\n" measure "with JIT context (#{$runs} runs)" do $prefab.get('prefab.auth.allowed_origins', { a: { b: "c" } }) end
Version data entries
8 entries across 8 versions & 1 rubygems