Sha256: 3aa07bc8c4e17f81abb23b442afe4eccf69975f80f7d08bc69364599ecf36886

Contents?: true

Size: 1.74 KB

Versions: 2

Compression:

Stored size: 1.74 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require "benchmark"
require "bundler/setup"
require "globus_client"

Benchmark.bm(20) do |benchmark|
  user_id, path = *ARGV

  benchmark.report("Configure:") do
    GlobusClient.configure(
      client_id: ENV["GLOBUS_CLIENT_ID"],
      client_secret: ENV["GLOBUS_CLIENT_SECRET"],
      uploads_directory: ENV["GLOBUS_UPLOADS_DIRECTORY"],
      transfer_endpoint_id: ENV["GLOBUS_ENDPOINT"]
    )
  end

  benchmark.report("mkdir:") do
    GlobusClient.mkdir(user_id:, path:)
  end

  benchmark.report("user_exists?:") do
    @user_exists = GlobusClient.user_exists?(user_id)
  end

  benchmark.report("before_perms:") do
    # Not part of the public API but this allows us to test access changes
    @before_permissions = GlobusClient::Endpoint.new(GlobusClient.config, user_id:, path:).send(:access_rule)["permissions"]
  end

  benchmark.report("list_files:") do
    GlobusClient.list_files(user_id:, path:) do |files|
      @files_count = files.count
      @total_size = files.sum(&:size)
      @files_list = files.map(&:name)
    end
  end

  benchmark.report("disallow_writes:") do
    GlobusClient.disallow_writes(user_id:, path:)
  end

  benchmark.report("after_perms:") do
    # Not part of the public API but this allows us to test access changes
    @after_permissions = GlobusClient::Endpoint.new(GlobusClient.config, user_id:, path:).send(:access_rule)["permissions"]
  end

  puts "User #{user_id} exists: #{@user_exists}"
  puts "Initial directory permissions: #{@before_permissions}"
  puts "Number of files in directory: #{@files_count}"
  puts "Total size of files in directory: #{@total_size}"
  puts "List of files in directory: #{@files_list}"
  puts "Final directory permissions: #{@after_permissions}"
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
globus_client-0.8.0 api_test.rb
globus_client-0.7.0 api_test.rb