Sha256: dcd3adcef4e1b96168bb610e39d73f457bc550a8481ee15583a377439b15b534

Contents?: true

Size: 1.28 KB

Versions: 21

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'
require 'benchmark'

module Sandthorn
  module AggregateRoot
    class TestClass
      include Sandthorn::AggregateRoot
      attr_reader :name
      
      
      def initialize args = {}
      end

      def change_name value
        unless name == value
          @name = value
          commit
        end
      end

    end

    describe "benchmark", benchmark: true do

      let(:test_object) { 
        o = TestClass.new().save
        o
      }
      n = 500
      it "should new, change_name, save and find 500 aggregates" do

        Benchmark.bm do |x|
          x.report("new change save find") { for i in 1..n; s = TestClass.new().change_name("benchmark").save(); TestClass.find(s.id);  end }
        end

      end
      it "should find 500 aggregates" do
        Benchmark.bm do |x|
          x.report("find") { for i in 1..n; TestClass.find(test_object.id);  end }
        end
      end
      it "should commit 500 actions" do
        Benchmark.bm do |x|
          x.report("commit") { for i in 1..n; test_object.change_name "#{i}";  end }
        end
      end
      it "should commit and save 500 actions" do
        Benchmark.bm do |x|
          x.report("commit save") { for i in 1..n; test_object.change_name("#{i}").save;  end }
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
sandthorn-1.3.0 spec/benchmark_spec.rb
sandthorn-1.2.0 spec/benchmark_spec.rb
sandthorn-1.1.0 spec/benchmark_spec.rb
sandthorn-1.0.0 spec/benchmark_spec.rb
sandthorn-0.13.0 spec/benchmark_spec.rb
sandthorn-0.12.0 spec/benchmark_spec.rb
sandthorn-0.11.0 spec/benchmark_spec.rb
sandthorn-0.10.3 spec/benchmark_spec.rb
sandthorn-0.10.2 spec/benchmark_spec.rb
sandthorn-0.10.1 spec/benchmark_spec.rb
sandthorn-0.10.0 spec/benchmark_spec.rb
sandthorn-0.9.2 spec/benchmark_spec.rb
sandthorn-0.9.1 spec/benchmark_spec.rb
sandthorn-0.9.0 spec/benchmark_spec.rb
sandthorn-0.8.1 spec/benchmark_spec.rb
sandthorn-0.8.0 spec/benchmark_spec.rb
sandthorn-0.7.0 spec/benchmark_spec.rb
sandthorn-0.6.0 spec/benchmark_spec.rb
sandthorn-0.5.1 spec/benchmark_spec.rb
sandthorn-0.5.0 spec/benchmark_spec.rb