You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: speed_improvement.rb
    path of file: ./repos/hyperstack/ruby/hyper-model/spec/batch6
    
    the code of the file until where you have to start completion: require 'spec_helper'
require 'test_components'
#require 'reactive_record_factory'
#require 'rspec-steps'

#RSpec::Steps.steps 'Load From Json', js: true do
describe "speed tests", js: true do

  def build_records(users, todos_per_user, comments_per_user)
    User.destroy_all
    Comment.destroy_all
    TodoItem.destroy_all
    users.times do |u|
      user = User.create(name: "User#{u}")
      todos_per_user.times do |t|
        todo = TodoItem.create(title: "Todo #{u} - #{t}", user: user)
        comments_per_user.times do |c|
          Comment.create(comment: "Comment #{c}  #{u} - #{t}", user: user, todo_item: todo)
        end
      end
    end
  end

  def measure(test, users, todos_per_user, comments_per_user)
    build_records(users, todos_per_user, comments_per_user)
    evaluate_promise("SpeedTester.load_all(#{test})")
  end

  before(:all) do
    Hyperstack.configuration do |config|
      config.transport = :crud_only
    end
  end

  before(:each) do
    stub_const 'TestApplication', Class.new
    stub_const 'TestApplicationPolicy', Class.new
    TestApplicationPolicy.class_eval do
      always_allow_connection
      regulate_all_broadcasts { |policy| policy.send_all }
      allow_change(to: :all, on: [:create, :update, :destroy]) { true }
    end
    on_client do
      class SpeedTester < HyperComponent
        def self.load_all(id)
          Hyperstack::Component::IsomorphicHelpers.load_context
          start_time = Time.now
          timer_promise = Promise.new
          case id
          when 1
            ReactiveRecord.load do
              Comment.all.collect { |todo| todo.id }
            end.then do |ids|
              ReactiveRecord.load do
                ids.each do |id|
                  Comment.find(i
    
        def self.load_all(id)
          Hyperstack::Component::IsomorphicHelpers.load_context
          start_time = Time.now
          timer_promise = Promise.new
          case id
          when 1
            ReactiveRecord.load do
              Comment.all.collect { |todo| todo.id }
            end.then do |ids|
              ReactiveRecord.load do
                ids.each do |id|
                  Comment.find(id).todo_item.user.name
                end
              end
            end
          when 2
            ReactiveRecord.load do
              User.each do |user|
                user.name
                user.todo_items.each do |todo|
                  todo.title
                  todo.comments.each do |comment|
                    comment.comment
                  end
                end
              end
            end
          when 3
            ReactiveRecord.load do
              Comment.all.collect { |todo| todo.id }
            end.then do |ids|
              ReactiveRecord.load do
                ids.each do |id|
                  Comment.find(id).comment
                end
              end
            end
            # puts gets clock to sync otherwise its slightly inaccurate
          end.then do
            after(0) { timer_promise.resolve(Time.now-start_time) }
          end
          timer_promise
        end

        after_mount do
          @start_time = Time.now
        end

        render(DIV) do
          DIV { "fetched in #{Time.now-@start_time} seconds"} if @start_time
          User.each do |user|
            LI do
              DIV do
                user.name.span
                UL do
                  user.todo_items.each do |todo|
                    LI do
                      DIV do
                        todo.title.span
                        UL do
                          todo.comments.each do |comment|
                            LI { comment.comment }
                          end
                        end
                      end
                    end
                  end
                end
              end
            end
          end
        end
      end
    end